Skip to content

Commit

Permalink
Replace tabs with spaces to please Symfony2 coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorbrandao committed Feb 11, 2012
1 parent 9017b48 commit 90aa50e
Show file tree
Hide file tree
Showing 35 changed files with 2,113 additions and 2,118 deletions.
24 changes: 12 additions & 12 deletions DependencyInjection/Compiler/RegisterExtensionsPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@
*/
class RegisterExtensionsPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (false === $container->hasDefinition('templating.engine.smarty')) {
return;
}
public function process(ContainerBuilder $container)
{
if (false === $container->hasDefinition('templating.engine.smarty')) {
return;
}

$definition = $container->getDefinition('templating.engine.smarty');
$definition = $container->getDefinition('templating.engine.smarty');

$calls = $definition->getMethodCalls();
$definition->setMethodCalls(array());
foreach ($container->findTaggedServiceIds('smarty.extension') as $id => $attributes) {
$definition->addMethodCall('addExtension', array(new Reference($id)));
}
$definition->setMethodCalls(array_merge($definition->getMethodCalls(), $calls));
$calls = $definition->getMethodCalls();
$definition->setMethodCalls(array());
foreach ($container->findTaggedServiceIds('smarty.extension') as $id => $attributes) {
$definition->addMethodCall('addExtension', array(new Reference($id)));
}
$definition->setMethodCalls(array_merge($definition->getMethodCalls(), $calls));
}
}
326 changes: 163 additions & 163 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,176 +46,176 @@
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*
* Example configuration (YAML):
* <code>
* smarty:
*
* # Smarty options
* options:
* cache_dir: %kernel.cache_dir%/smarty/cache
* compile_dir: %kernel.cache_dir%/smarty/templates_c
* config_dir: %kernel.root_dir%/config/smarty
* template_dir: %kernel.root_dir%/Resources/views
* use_sub_dirs: true
* </code>
*
* @since 0.1.0
* @author Vítor Brandão <[email protected]>
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('smarty');
/**
* {@inheritDoc}
*
* Example configuration (YAML):
* <code>
* smarty:
*
* # Smarty options
* options:
* cache_dir: %kernel.cache_dir%/smarty/cache
* compile_dir: %kernel.cache_dir%/smarty/templates_c
* config_dir: %kernel.root_dir%/config/smarty
* template_dir: %kernel.root_dir%/Resources/views
* use_sub_dirs: true
* </code>
*
* @since 0.1.0
* @author Vítor Brandão <[email protected]>
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('smarty');

$rootNode
->treatNullLike(array('enabled' => true))
->end();
$rootNode
->treatNullLike(array('enabled' => true))
->end();

$this->addFormSection($rootNode);
$this->addGlobalsSection($rootNode);
$this->addSmartyOptions($rootNode);
$this->addFormSection($rootNode);
$this->addGlobalsSection($rootNode);
$this->addSmartyOptions($rootNode);

return $treeBuilder;
}
return $treeBuilder;
}

/**
* @since 0.2.0
* @author Vítor Brandão <[email protected]>
*/
protected function addFormSection(ArrayNodeDefinition $rootNode)
{
$rootNode
->children()
->arrayNode('form')
->addDefaultsIfNotSet()
->fixXmlConfig('resource')
->children()
->arrayNode('resources')
->addDefaultsIfNotSet()
->defaultValue(array('SmartyBundle:Form:form_div_layout.html.tpl'))
->validate()
->ifTrue(function($v) { return !in_array('SmartyBundle:Form:form_div_layout.html.tpl', $v); })
->then(function($v){
return array_merge(array('SmartyBundle:Form:form_div_layout.html.tpl'), $v);
})
->end()
->prototype('scalar')->end()
->end()
->end()
->end()
->end()
;
}
/**
* @since 0.2.0
* @author Vítor Brandão <[email protected]>
*/
protected function addFormSection(ArrayNodeDefinition $rootNode)
{
$rootNode
->children()
->arrayNode('form')
->addDefaultsIfNotSet()
->fixXmlConfig('resource')
->children()
->arrayNode('resources')
->addDefaultsIfNotSet()
->defaultValue(array('SmartyBundle:Form:form_div_layout.html.tpl'))
->validate()
->ifTrue(function($v) { return !in_array('SmartyBundle:Form:form_div_layout.html.tpl', $v); })
->then(function($v){
return array_merge(array('SmartyBundle:Form:form_div_layout.html.tpl'), $v);
})
->end()
->prototype('scalar')->end()
->end()
->end()
->end()
->end()
;
}


/**
* @since 0.1.0
* @author Vítor Brandão <[email protected]>
*/
protected function addGlobalsSection(ArrayNodeDefinition $rootNode)
{
$rootNode
->fixXmlConfig('global')
->children()
->arrayNode('globals')
->useAttributeAsKey('key')
->prototype('array')
->beforeNormalization()
->ifTrue(function($v){ return is_string($v) && '@' === substr($v, 0, 1); })
->then(function($v){ return array('id' => substr($v, 1), 'type' => 'service'); })
->end()
->beforeNormalization()
->ifTrue(function($v){
if (is_array($v)) {
$keys = array_keys($v);
sort($keys);
/**
* @since 0.1.0
* @author Vítor Brandão <[email protected]>
*/
protected function addGlobalsSection(ArrayNodeDefinition $rootNode)
{
$rootNode
->fixXmlConfig('global')
->children()
->arrayNode('globals')
->useAttributeAsKey('key')
->prototype('array')
->beforeNormalization()
->ifTrue(function($v){ return is_string($v) && '@' === substr($v, 0, 1); })
->then(function($v){ return array('id' => substr($v, 1), 'type' => 'service'); })
->end()
->beforeNormalization()
->ifTrue(function($v){
if (is_array($v)) {
$keys = array_keys($v);
sort($keys);

return $keys !== array('id', 'type') && $keys !== array('value');
}
return $keys !== array('id', 'type') && $keys !== array('value');
}

return true;
})
->then(function($v){ return array('value' => $v); })
->end()
->children()
->scalarNode('id')->end()
->scalarNode('type')
->validate()
->ifNotInArray(array('service'))
->thenInvalid('The %s type is not supported')
->end()
->end()
->variableNode('value')->end()
->end()
->end()
->end()
->end()
;
}
return true;
})
->then(function($v){ return array('value' => $v); })
->end()
->children()
->scalarNode('id')->end()
->scalarNode('type')
->validate()
->ifNotInArray(array('service'))
->thenInvalid('The %s type is not supported')
->end()
->end()
->variableNode('value')->end()
->end()
->end()
->end()
->end()
;
}

/**
* Smarty options.
*
* The whole list can be seen here: {@link http://www.smarty.net/docs/en/api.variables.tpl}
*
* @since 0.1.0
* @author Vítor Brandão <[email protected]>
*/
protected function addSmartyOptions(ArrayNodeDefinition $rootNode)
{
$rootNode
->children()
->arrayNode('options')
->canBeUnset()
->addDefaultsIfNotSet()
->children()
->scalarNode('allow_php_templates')->end()
->scalarNode('auto_literal')->end()
->scalarNode('autoload_filters')->end()
->scalarNode('cache_dir')->defaultValue('%kernel.cache_dir%/smarty/cache')->cannotBeEmpty()->end()
->scalarNode('cache_id')->end()
->scalarNode('cache_lifetime')->end()
->scalarNode('cache_locking')->end()
->scalarNode('cache_modified_check')->end()
->scalarNode('caching')->end()
->scalarNode('caching_type')->end()
->scalarNode('compile_check')->end()
->scalarNode('compile_dir')->defaultValue('%kernel.cache_dir%/smarty/templates_c')->cannotBeEmpty()->end()
->scalarNode('compile_id')->end()
->scalarNode('compile_locking')->end()
->scalarNode('compiler_class')->end()
->scalarNode('config_booleanize')->end()
->scalarNode('config_dir')->defaultValue('%kernel.root_dir%/config/smarty')->cannotBeEmpty()->end()
->scalarNode('config_overwrite')->end()
->scalarNode('config_read_hidden')->end()
->scalarNode('debug_tpl')->end()
->scalarNode('debugging')->end()
->scalarNode('debugging_ctrl')->end()
->scalarNode('default_config_type')->end()
->scalarNode('default_modifiers')->end()
->scalarNode('default_resource_type')->defaultValue('file')->end()
->scalarNode('default_config_handler_func')->end()
->scalarNode('default_template_handler_func')->end()
->scalarNode('direct_access_security')->end()
->scalarNode('error_reporting')->end()
->scalarNode('escape_html')->end()
->scalarNode('force_cache')->end()
->scalarNode('force_compile')->end()
->scalarNode('locking_timeout')->end()
->scalarNode('merge_compiled_includes')->end()
->scalarNode('php_handling')->end()
->scalarNode('plugins_dir')->end()
->scalarNode('smarty_debug_id')->end()
->scalarNode('template_dir')->defaultValue('%kernel.root_dir%/Resources/views')->cannotBeEmpty()->end()
->scalarNode('trusted_dir')->end()
->scalarNode('use_include_path')->defaultFalse()->end()
->scalarNode('use_sub_dirs')->defaultTrue()->end()
->end()
->end()
->end()
;
}
/**
* Smarty options.
*
* The whole list can be seen here: {@link http://www.smarty.net/docs/en/api.variables.tpl}
*
* @since 0.1.0
* @author Vítor Brandão <[email protected]>
*/
protected function addSmartyOptions(ArrayNodeDefinition $rootNode)
{
$rootNode
->children()
->arrayNode('options')
->canBeUnset()
->addDefaultsIfNotSet()
->children()
->scalarNode('allow_php_templates')->end()
->scalarNode('auto_literal')->end()
->scalarNode('autoload_filters')->end()
->scalarNode('cache_dir')->defaultValue('%kernel.cache_dir%/smarty/cache')->cannotBeEmpty()->end()
->scalarNode('cache_id')->end()
->scalarNode('cache_lifetime')->end()
->scalarNode('cache_locking')->end()
->scalarNode('cache_modified_check')->end()
->scalarNode('caching')->end()
->scalarNode('caching_type')->end()
->scalarNode('compile_check')->end()
->scalarNode('compile_dir')->defaultValue('%kernel.cache_dir%/smarty/templates_c')->cannotBeEmpty()->end()
->scalarNode('compile_id')->end()
->scalarNode('compile_locking')->end()
->scalarNode('compiler_class')->end()
->scalarNode('config_booleanize')->end()
->scalarNode('config_dir')->defaultValue('%kernel.root_dir%/config/smarty')->cannotBeEmpty()->end()
->scalarNode('config_overwrite')->end()
->scalarNode('config_read_hidden')->end()
->scalarNode('debug_tpl')->end()
->scalarNode('debugging')->end()
->scalarNode('debugging_ctrl')->end()
->scalarNode('default_config_type')->end()
->scalarNode('default_modifiers')->end()
->scalarNode('default_resource_type')->defaultValue('file')->end()
->scalarNode('default_config_handler_func')->end()
->scalarNode('default_template_handler_func')->end()
->scalarNode('direct_access_security')->end()
->scalarNode('error_reporting')->end()
->scalarNode('escape_html')->end()
->scalarNode('force_cache')->end()
->scalarNode('force_compile')->end()
->scalarNode('locking_timeout')->end()
->scalarNode('merge_compiled_includes')->end()
->scalarNode('php_handling')->end()
->scalarNode('plugins_dir')->end()
->scalarNode('smarty_debug_id')->end()
->scalarNode('template_dir')->defaultValue('%kernel.root_dir%/Resources/views')->cannotBeEmpty()->end()
->scalarNode('trusted_dir')->end()
->scalarNode('use_include_path')->defaultFalse()->end()
->scalarNode('use_sub_dirs')->defaultTrue()->end()
->end()
->end()
->end()
;
}
}
Loading

0 comments on commit 90aa50e

Please sign in to comment.