Loader.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Symfony\Components\DependencyInjection\Loader;
  3. /*
  4. * This file is part of the symfony framework.
  5. *
  6. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. /**
  12. * Loader is the abstract class used by all built-in loaders.
  13. *
  14. * @package symfony
  15. * @subpackage dependency_injection
  16. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  17. */
  18. abstract class Loader implements LoaderInterface
  19. {
  20. static protected $extensions = array();
  21. /**
  22. * Registers an extension.
  23. *
  24. * @param LoaderExtensionInterface $extension An extension instance
  25. */
  26. static public function registerExtension(LoaderExtensionInterface $extension)
  27. {
  28. static::$extensions[$extension->getAlias()] = static::$extensions[$extension->getNamespace()] = $extension;
  29. }
  30. /**
  31. * Returns an extension by alias or namespace.
  32. *
  33. * @param string $name An alias or a namespace
  34. *
  35. * @return LoaderExtensionInterface An extension instance
  36. */
  37. static public function getExtension($name)
  38. {
  39. return isset(static::$extensions[$name]) ? static::$extensions[$name] : null;
  40. }
  41. }