4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Compiler;
14 use Symfony\Component\DependencyInjection\ContainerBuilder;
17 * This class is used to remove circular dependencies between individual passes.
19 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
24 private $log = array();
25 private $loggingFormatter;
26 private $serviceReferenceGraph;
28 public function __construct()
30 $this->passConfig = new PassConfig();
31 $this->serviceReferenceGraph = new ServiceReferenceGraph();
32 $this->loggingFormatter = new LoggingFormatter();
36 * Returns the PassConfig.
38 * @return PassConfig The PassConfig instance
40 public function getPassConfig()
42 return $this->passConfig;
46 * Returns the ServiceReferenceGraph.
48 * @return ServiceReferenceGraph The ServiceReferenceGraph instance
50 public function getServiceReferenceGraph()
52 return $this->serviceReferenceGraph;
56 * Returns the logging formatter which can be used by compilation passes.
58 * @return LoggingFormatter
60 public function getLoggingFormatter()
62 return $this->loggingFormatter;
66 * Adds a pass to the PassConfig.
68 * @param CompilerPassInterface $pass A compiler pass
69 * @param string $type The type of the pass
71 public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION)
73 $this->passConfig->addPass($pass, $type);
79 * @param string $string The log message
81 public function addLogMessage($string)
83 $this->log[] = $string;
89 * @return array Log array
91 public function getLog()
97 * Run the Compiler and process all Passes.
99 * @param ContainerBuilder $container
101 public function compile(ContainerBuilder $container)
103 foreach ($this->passConfig->getPasses() as $pass) {
104 $pass->process($container);