CompilerDebugDumpPass.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\DependencyInjection\Compiler\CompilerPassInterface;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\DependencyInjection\ContainerInterface;
  14. use Symfony\Component\Filesystem\Exception\IOException;
  15. use Symfony\Component\Filesystem\Filesystem;
  16. class CompilerDebugDumpPass implements CompilerPassInterface
  17. {
  18. public function process(ContainerBuilder $container)
  19. {
  20. $filename = self::getCompilerLogFilename($container);
  21. $filesystem = new Filesystem();
  22. $filesystem->dumpFile($filename, implode("\n", $container->getCompiler()->getLog()), null);
  23. try {
  24. $filesystem->chmod($filename, 0666, umask());
  25. } catch (IOException $e) {
  26. // discard chmod failure (some filesystem may not support it)
  27. }
  28. }
  29. public static function getCompilerLogFilename(ContainerInterface $container)
  30. {
  31. $class = $container->getParameter('kernel.container_class');
  32. return $container->getParameter('kernel.cache_dir').'/'.$class.'Compiler.log';
  33. }
  34. }