/** * Adds a compiler pass. * * @param CompilerPassInterface $pass A compiler pass * @param string $type The type of compiler pass * * @return ContainerBuilder The current instance * * @api */ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) { if (null === $this->compiler) { $this->compiler = new Compiler(); } $this->compiler->addPass($pass, $type); $this->addObjectResource($pass); return $this; }