-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace tabs with spaces to please Symfony2 coding standards
- Loading branch information
1 parent
9017b48
commit 90aa50e
Showing
35 changed files
with
2,113 additions
and
2,118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
; | ||
} | ||
} |
Oops, something went wrong.