View source
<?php
namespace Symfony\Component\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
class PassConfig {
const TYPE_AFTER_REMOVING = 'afterRemoving';
const TYPE_BEFORE_OPTIMIZATION = 'beforeOptimization';
const TYPE_BEFORE_REMOVING = 'beforeRemoving';
const TYPE_OPTIMIZE = 'optimization';
const TYPE_REMOVE = 'removing';
private $mergePass;
private $afterRemovingPasses = array();
private $beforeOptimizationPasses = array();
private $beforeRemovingPasses = array();
private $optimizationPasses;
private $removingPasses;
public function __construct() {
$this->mergePass = new MergeExtensionConfigurationPass();
$this->optimizationPasses = array(
new ExtensionCompilerPass(),
new ResolveDefinitionTemplatesPass(),
new DecoratorServicePass(),
new ResolveParameterPlaceHoldersPass(),
new CheckDefinitionValidityPass(),
new ResolveReferencesToAliasesPass(),
new ResolveInvalidReferencesPass(),
new AnalyzeServiceReferencesPass(true),
new CheckCircularReferencesPass(),
new CheckReferenceValidityPass(),
);
$this->removingPasses = array(
new RemovePrivateAliasesPass(),
new RemoveAbstractDefinitionsPass(),
new ReplaceAliasByActualDefinitionPass(),
new RepeatedPass(array(
new AnalyzeServiceReferencesPass(),
new InlineServiceDefinitionsPass(),
new AnalyzeServiceReferencesPass(),
new RemoveUnusedDefinitionsPass(),
)),
new CheckExceptionOnInvalidReferenceBehaviorPass(),
);
}
public function getPasses() {
return array_merge(array(
$this->mergePass,
), $this->beforeOptimizationPasses, $this->optimizationPasses, $this->beforeRemovingPasses, $this->removingPasses, $this->afterRemovingPasses);
}
public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION) {
$property = $type . 'Passes';
if (!isset($this->{$property})) {
throw new InvalidArgumentException(sprintf('Invalid type "%s".', $type));
}
$passes =& $this->{$property};
$passes[] = $pass;
}
public function getAfterRemovingPasses() {
return $this->afterRemovingPasses;
}
public function getBeforeOptimizationPasses() {
return $this->beforeOptimizationPasses;
}
public function getBeforeRemovingPasses() {
return $this->beforeRemovingPasses;
}
public function getOptimizationPasses() {
return $this->optimizationPasses;
}
public function getRemovingPasses() {
return $this->removingPasses;
}
public function getMergePass() {
return $this->mergePass;
}
public function setMergePass(CompilerPassInterface $pass) {
$this->mergePass = $pass;
}
public function setAfterRemovingPasses(array $passes) {
$this->afterRemovingPasses = $passes;
}
public function setBeforeOptimizationPasses(array $passes) {
$this->beforeOptimizationPasses = $passes;
}
public function setBeforeRemovingPasses(array $passes) {
$this->beforeRemovingPasses = $passes;
}
public function setOptimizationPasses(array $passes) {
$this->optimizationPasses = $passes;
}
public function setRemovingPasses(array $passes) {
$this->removingPasses = $passes;
}
}