ContainerBuilderDebugDumpPass.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
  11. use Symfony\Component\Config\ConfigCache;
  12. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\DependencyInjection\Dumper\XmlDumper;
  15. /**
  16. * Dumps the ContainerBuilder to a cache file so that it can be used by
  17. * debugging tools such as the debug:container console command.
  18. *
  19. * @author Ryan Weaver <ryan@thatsquality.com>
  20. * @author Fabien Potencier <fabien@symfony.com>
  21. */
  22. class ContainerBuilderDebugDumpPass implements CompilerPassInterface
  23. {
  24. public function process(ContainerBuilder $container)
  25. {
  26. $cache = new ConfigCache($container->getParameter('debug.container.dump'), true);
  27. if (!$cache->isFresh()) {
  28. $cache->write((new XmlDumper($container))->dump(), $container->getResources());
  29. }
  30. }
  31. }