diff --git a/src/Symfony/Bundle/ZendBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/ZendBundle/DependencyInjection/Configuration.php new file mode 100644 index 0000000000000..e97ea8e93980e --- /dev/null +++ b/src/Symfony/Bundle/ZendBundle/DependencyInjection/Configuration.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\ZendBundle\DependencyInjection; + +use Symfony\Component\Config\Definition\Builder\NodeBuilder; +use Symfony\Component\Config\Definition\Builder\TreeBuilder; + +/** + * This class contains the configuration information for the bundle + * + * This information is solely responsible for how the different configuration + * sections are normalized, and merged. + * + * @author Christophe Coevoet + */ +class Configuration +{ + /** + * Generates the configuration tree. + * + * @return \Symfony\Component\Config\Definition\NodeInterface + */ + public function getConfigTree() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('zend', 'array'); + + $rootNode + ->arrayNode('logger') + ->canBeUnset() + ->scalarNode('priority')->defaultValue('INFO')->end() + ->scalarNode('path')->defaultValue('%kernel.logs_dir%/%kernel.environment%.log')->end() + ->booleanNode('log_errors')->defaultFalse()->end() + ->end() + ; + + return $treeBuilder->buildTree(); + } +} diff --git a/src/Symfony/Bundle/ZendBundle/DependencyInjection/ZendExtension.php b/src/Symfony/Bundle/ZendBundle/DependencyInjection/ZendExtension.php index 8656484013d7a..c21d3e2a0c6e3 100644 --- a/src/Symfony/Bundle/ZendBundle/DependencyInjection/ZendExtension.php +++ b/src/Symfony/Bundle/ZendBundle/DependencyInjection/ZendExtension.php @@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; +use Symfony\Component\Config\Definition\Processor; /** * ZendExtension is an extension for the Zend Framework libraries. @@ -37,52 +38,27 @@ class ZendExtension extends Extension */ public function load(array $configs, ContainerBuilder $container) { - $first = true; - foreach ($configs as $config) { - if (!isset($config['logger'])) { - continue; - } - - if ($first) { - $first = false; + $configuration = new Configuration(); + $processor = new Processor(); + $config = $processor->process($configuration->getConfigTree(), $configs); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('logger.xml'); - $container->setAlias('logger', 'zend.logger'); - } - - $this->registerLoggerConfiguration($config, $container); - } - } + if (isset($config['logger'])) { + $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('logger.xml'); + $container->setAlias('logger', 'zend.logger'); - /** - * Loads the logger configuration. - * - * Usage example: - * - * - * - * @param array $config An array of configuration settings - * @param ContainerBuilder $container A ContainerBuilder instance - */ - protected function registerLoggerConfiguration($config, ContainerBuilder $container) - { - $config = $config['logger']; + $config = $config['logger']; - if (isset($config['priority'])) { $container->setParameter('zend.logger.priority', is_int($config['priority']) ? $config['priority'] : constant('\\Zend\\Log\\Logger::'.strtoupper($config['priority']))); - } - - if (isset($config['path'])) { $container->setParameter('zend.logger.path', $config['path']); - } - if (isset($config['log_errors'])) { $definition = $container->findDefinition('zend.logger'); - if (false === $config['log_errors'] && $definition->hasMethodCall('registerErrorHandler')) { - $container->findDefinition('zend.logger')->removeMethodCall('registerErrorHandler'); - } else { + if ($config['log_errors']) { $container->findDefinition('zend.logger')->addMethodCall('registerErrorHandler'); + } else { + if ($definition->hasMethodCall('registerErrorHandler')) { + $container->findDefinition('zend.logger')->removeMethodCall('registerErrorHandler'); + } } } } diff --git a/src/Symfony/Bundle/ZendBundle/Resources/config/logger.xml b/src/Symfony/Bundle/ZendBundle/Resources/config/logger.xml index ec1d5a488b5c8..2fcfda890b0b3 100644 --- a/src/Symfony/Bundle/ZendBundle/Resources/config/logger.xml +++ b/src/Symfony/Bundle/ZendBundle/Resources/config/logger.xml @@ -6,7 +6,6 @@ Symfony\Bundle\ZendBundle\Logger\Logger - Zend\Log\Logger::CRIT true Symfony\Bundle\ZendBundle\Logger\DebugLogger Zend\Log\Writer\Stream pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy