Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba2b1aa
commit db5e180
Showing
15 changed files
with
376 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?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 | ||
* | ||
* @author Johannes M. Schmitt <schmittjoh@gmail.com> | ||
*/ | ||
class PassConfig | ||
{ | ||
const TYPE_OPTIMIZE = 'optimization'; | ||
const TYPE_REMOVE = 'removing'; | ||
|
||
protected $mergePass; | ||
protected $optimizationPasses; | ||
protected $removingPasses; | ||
|
||
public function __construct() | ||
{ | ||
$this->mergePass = new MergeExtensionConfigurationPass(); | ||
|
||
$this->optimizationPasses = array( | ||
new ResolveParameterPlaceHoldersPass(), | ||
new ResolveInterfaceInjectorsPass(), | ||
); | ||
|
||
$this->removingPasses = array( | ||
new RemoveUnusedDefinitionsPass(), | ||
); | ||
} | ||
|
||
public function getPasses() | ||
{ | ||
return array_merge( | ||
array($this->mergePass), | ||
$this->optimizationPasses, | ||
$this->removingPasses | ||
); | ||
} | ||
|
||
public function addPass(CompilerPassInterface $pass, $type = self::TYPE_OPTIMIZE) | ||
{ | ||
$property = $type.'Passes'; | ||
if (!isset($this->$property)) { | ||
throw new \InvalidArgumentException(sprintf('Invalid type "%s".', $type)); | ||
} | ||
|
||
$passes = &$this->$property; | ||
$passes[] = $pass; | ||
} | ||
|
||
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 setOptimizationPasses(array $passes) | ||
{ | ||
$this->optimizationPasses = $passes; | ||
} | ||
|
||
public function setRemovingPasses(array $passes) | ||
{ | ||
$this->removingPasses = $passes; | ||
} | ||
} |
Oops, something went wrong.