Skip to content

Instantly share code, notes, and snippets.

var globalConfigs = {
env : '<?php echo sfConfig::get('sf_environment') ?>',
userCulture : '<?php echo $sf_user->getCulture() ?>',
urls: {
ajaxAutocomplete : '<?php echo url_for('@homepage') ?>',
ajaxModalBox : '<?php echo url_for('@homepage') ?>'
},
i18n: {
example : "<?php echo esc_specialchars(__('example')) ?>",
exampleModalboxTitle : "<?php echo esc_specialchars(__('example_modalbox_title')) ?>"
javascript_configs:
url: /js/configs.:sf_format
param: { module: js, action: configs, sf_format: js }
public function configure()
{
$this->dispatcher->connect('context.load_factories', array($this, 'listenToContextLoadFactoriesEvent'));
}
public function listenToContextLoadFactoriesEvent(sfEvent $event)
{
$event->getSubject()->getResponse()->addJavascript($event->getSubject()->getRouting()->generate('javascript_configs'));
}
// env condition:
if (globalConfigs.env == 'dev') {}
// jQuery DOM manipulation:
$('#example').html(globalConfigs.i18n.example);
// jQuery ajax call:
$.get(globalConfigs.urls.ajaxAutocomplete, function(data) {});
// enjoy!
var globalConfigs = {
// ...
wysiwyg: {
script_url: '/js/tiny_mce/tiny_mce.js',
theme: "advanced",
element_format : "xhtml",
cleanup : true,
theme_advanced_buttons1: "<?php echo sfConfig::get('app_tinymce_theme_advanced_buttons1') ?>",
theme_advanced_buttons2: "<?php echo sfConfig::get('app_tinymce_theme_advanced_buttons2') ?>",
// TinyMCE via jQuery plugin:
$('#wysiwyg').tinymce(globalConfigs.wysiwyg);
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@jeremyb
jeremyb / documents.yaml
Last active October 5, 2020 15:54 — forked from anonymous/documents.yaml
Hierarchical facets with Elasticsearch
_type: product
category_level0: Books
category_level1: Computers & Technology
category_level2: Network Programming
name: Pro AngularJS
---
_type: product
category_level0: Books
@jeremyb
jeremyb / 1. UsernameType.php
Last active November 28, 2015 20:16
Username value object mapped to a form
<?php
namespace AppBundle\Form;
use AppBundle\Model\Username;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\DataMapperInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
@jeremyb
jeremyb / 1. UserRepository.php
Created June 23, 2015 17:08
Repository interface example
<?php
namespace AppBundle\Model;
interface UserRepository
{
public function add(User $user);
public function remove(User $user);