ZendExtension.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace Symfony\Framework\ZendBundle\DependencyInjection;
  3. use Symfony\Components\DependencyInjection\Loader\LoaderExtension;
  4. use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
  5. use Symfony\Components\DependencyInjection\BuilderConfiguration;
  6. /*
  7. * This file is part of the Symfony framework.
  8. *
  9. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  10. *
  11. * This source file is subject to the MIT license that is bundled
  12. * with this source code in the file LICENSE.
  13. */
  14. /**
  15. * ZendExtension is an extension for the Zend Framework libraries.
  16. *
  17. * @package Symfony
  18. * @subpackage Framework_ZendBundle
  19. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  20. */
  21. class ZendExtension extends LoaderExtension
  22. {
  23. protected $resources = array(
  24. 'logger' => 'logger.xml',
  25. );
  26. /**
  27. * Loads the logger configuration.
  28. *
  29. * Usage example:
  30. *
  31. * <zend:logger priority="info" path="/path/to/some.log" />
  32. *
  33. * @param array $config A configuration array
  34. * @param BuilderConfiguration $configuration A BuilderConfiguration instance
  35. *
  36. * @return BuilderConfiguration A BuilderConfiguration instance
  37. */
  38. public function loggerLoad($config, BuilderConfiguration $configuration)
  39. {
  40. if (!$configuration->hasDefinition('zend.logger')) {
  41. $loader = new XmlFileLoader(__DIR__.'/../Resources/config');
  42. $configuration->merge($loader->load($this->resources['logger']));
  43. $configuration->setAlias('logger', 'zend.logger');
  44. }
  45. if (isset($config['priority'])) {
  46. $configuration->setParameter('zend.logger.priority', is_int($config['priority']) ? $config['priority'] : constant('\\Zend\\Log\\Logger::'.strtoupper($config['priority'])));
  47. }
  48. if (isset($config['path'])) {
  49. $configuration->setParameter('zend.logger.path', $config['path']);
  50. }
  51. return $configuration;
  52. }
  53. /**
  54. * Returns the base path for the XSD files.
  55. *
  56. * @return string The XSD base path
  57. */
  58. public function getXsdValidationBasePath()
  59. {
  60. return __DIR__.'/../Resources/config/';
  61. }
  62. public function getNamespace()
  63. {
  64. return 'http://www.symfony-project.org/schema/dic/zend';
  65. }
  66. public function getAlias()
  67. {
  68. return 'zend';
  69. }
  70. }