This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

135 lines
3.5 KiB
PHP
Raw Normal View History

2010-12-29 19:12:24 +00:00
<?php
namespace Symfony\Component\DependencyInjection\Compiler;
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
* Compiler Pass Configuration
*
* This class has a default configuration embedded.
*
2010-12-29 19:12:24 +00:00
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class PassConfig
{
const TYPE_AFTER_REMOVING = 'afterRemoving';
const TYPE_BEFORE_OPTIMIZATION = 'beforeOptimization';
const TYPE_BEFORE_REMOVING = 'beforeRemoving';
2010-12-29 19:12:24 +00:00
const TYPE_OPTIMIZE = 'optimization';
const TYPE_REMOVE = 'removing';
protected $mergePass;
protected $afterRemovingPasses;
protected $beforeOptimizationPasses;
protected $beforeRemovingPasses;
2010-12-29 19:12:24 +00:00
protected $optimizationPasses;
protected $removingPasses;
public function __construct()
{
$this->mergePass = new MergeExtensionConfigurationPass();
$this->afterRemovingPasses = array();
$this->beforeOptimizationPasses = array();
$this->beforeRemovingPasses = array();
2010-12-29 19:12:24 +00:00
$this->optimizationPasses = array(
new ResolveParameterPlaceHoldersPass(),
2011-01-05 11:13:27 +00:00
new ResolveReferencesToAliasesPass(),
2010-12-29 19:12:24 +00:00
new ResolveInterfaceInjectorsPass(),
2011-01-05 11:13:27 +00:00
new ResolveInvalidReferencesPass(),
2010-12-29 19:12:24 +00:00
);
$this->removingPasses = array(
2011-01-07 14:44:29 +00:00
new RemovePrivateAliasesPass(),
new ReplaceAliasByActualDefinitionPass(),
new RepeatedPass(array(
new AnalyzeServiceReferencesPass(),
new InlineServiceDefinitionsPass(),
new AnalyzeServiceReferencesPass(),
new RemoveUnusedDefinitionsPass(),
)),
2010-12-29 19:12:24 +00:00
);
}
public function getPasses()
{
return array_merge(
array($this->mergePass),
$this->beforeOptimizationPasses,
2010-12-29 19:12:24 +00:00
$this->optimizationPasses,
$this->beforeRemovingPasses,
$this->removingPasses,
$this->afterRemovingPasses
2010-12-29 19:12:24 +00:00
);
}
public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION)
2010-12-29 19:12:24 +00:00
{
$property = $type.'Passes';
if (!isset($this->$property)) {
throw new \InvalidArgumentException(sprintf('Invalid type "%s".', $type));
}
$passes = &$this->$property;
$passes[] = $pass;
}
public function getBeforeOptimizationPasses()
{
return $this->beforeOptimizationPasses;
}
public function getBeforeRemovingPasses()
{
return $this->beforeRemovingPasses;
}
2010-12-29 19:12:24 +00:00
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 setBeforeOptimizationPasses(array $passes)
{
$this->beforeOptimizationPasses = $passes;
}
public function setBeforeRemovingPasses(array $passes)
{
$this->beforeRemovingPasses = $passes;
}
2010-12-29 19:12:24 +00:00
public function setOptimizationPasses(array $passes)
{
$this->optimizationPasses = $passes;
}
public function setRemovingPasses(array $passes)
{
$this->removingPasses = $passes;
}
}