* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Argument\ArgumentInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\ExpressionLanguage; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\ExpressionLanguage\Expression; /** * Run this pass before passes that need to know more about the relation of * your services. * * This class will populate the ServiceReferenceGraph with information. You can * retrieve the graph in other passes from the compiler. * * @author Johannes M. Schmitt */ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements RepeatablePassInterface { private $graph; private $currentDefinition; private $onlyConstructorArguments; private $lazy; private $expressionLanguage; /** * @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls */ public function __construct($onlyConstructorArguments = false) { $this->onlyConstructorArguments = (bool) $onlyConstructorArguments; } /** * {@inheritdoc} */ public function setRepeatedPass(RepeatedPass $repeatedPass) { // no-op for BC } /** * Processes a ContainerBuilder object to populate the service reference graph. */ public function process(ContainerBuilder $container) { $this->container = $container; $this->graph = $container->getCompiler()->getServiceReferenceGraph(); $this->graph->clear(); $this->lazy = false; foreach ($container->getAliases() as $id => $alias) { $targetId = $this->getDefinitionId((string) $alias); $this->graph->connect($id, $alias, $targetId, $this->getDefinition($targetId), null); } parent::process($container); } protected function processValue($value, $isRoot = false) { $lazy = $this->lazy; if ($value instanceof ArgumentInterface) { $this->lazy = true; parent::processValue($value->getValues()); $this->lazy = $lazy; return $value; } if ($value instanceof Expression) { $this->getExpressionLanguage()->compile((string) $value, array('this' => 'container')); return $value; } if ($value instanceof Reference) { $targetId = $this->getDefinitionId((string) $value); $targetDefinition = $this->getDefinition($targetId); $this->graph->connect( $this->currentId, $this->currentDefinition, $targetId, $targetDefinition, $value, $this->lazy || ($targetDefinition && $targetDefinition->isLazy()), ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior() ); return $value; } if (!$value instanceof Definition) { return parent::processValue($value, $isRoot); } if ($isRoot) { if ($value->isSynthetic() || $value->isAbstract()) { return $value; } $this->currentDefinition = $value; } $this->lazy = false; $this->processValue($value->getFactory()); $this->processValue($value->getArguments()); if (!$this->onlyConstructorArguments) { $this->processValue($value->getProperties()); $this->processValue($value->getMethodCalls()); $this->processValue($value->getConfigurator()); } $this->lazy = $lazy; return $value; } /** * Returns a service definition given the full name or an alias. * * @param string $id A full id or alias for a service definition * * @return Definition|null The definition related to the supplied id */ private function getDefinition($id) { return null === $id ? null : $this->container->getDefinition($id); } private function getDefinitionId($id) { while ($this->container->hasAlias($id)) { $id = (string) $this->container->getAlias($id); } if (!$this->container->hasDefinition($id)) { return; } return $this->container->normalizeId($id); } private function getExpressionLanguage() { if (null === $this->expressionLanguage) { if (!class_exists(ExpressionLanguage::class)) { throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } $providers = $this->container->getExpressionLanguageProviders(); $this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) { if ('""' === substr_replace($arg, '', 1, -1)) { $id = stripcslashes(substr($arg, 1, -1)); $id = $this->getDefinitionId($id); $this->graph->connect( $this->currentId, $this->currentDefinition, $id, $this->getDefinition($id) ); } return sprintf('$this->get(%s)', $arg); }); } return $this->expressionLanguage; } } __halt_compiler();----SIGNATURE:----H1z7UdOBBA6KA8fsonpa0GjjKX0KSvtv3DJ1GFrlCC5mtqCZb1mY/g66s5cVHVS4uWWfoAeF5xe4LjDNGPfVQqSYkwM7rmN1hB+DobhTHX8GIBxTlbHbJIcyp9E5ksaLGMhEh8cA6DVlTFGn3zZekOeXsaYwojkJ0JgSkkU/D2rlh6CLVO+Zy3EzcmvTS096/guYa3/WguXyZB/B2qflgffrH4dR4xFp1W4MsHeKHzYkbHhOt0Ef7h5EpGwBMnmkDF8+MFNZclIcLMPtEigEf7kf8ToVykoRn6Tk1d5imgelqvLYrUNWVE2ryg9jsUcjiWTdgaDreKtVkEJVRAuhDPBVKB7PCBZ28tj9t9KoiEf8bYfI/KR3aF7Ork0PuMASgPcTZA1Im3W6gP3i4AWvBw0v8tvkpRzc0QvGcSDT+ZNkFaufTtHbuyu9Pdb9+UJPCBduKX1gRj428TOhG1PFCXpjlQ+LtRtvW96Sqj4Fv6XvVx84AjrB4OSXFPyUAsWvCDz21/q+vrtNYdPP5ikOG0CfIDnwmEPl8Lsz+eSn9pcNr7hejXMczoNrIlGHyqVbZSuTUwW0eS2onMKz54kEqTZkp2kEBE73DGWQeqp1jnsaR3+hwRqR4xf8jLIPxdIUTCs+RKeml/e+G2wSp+sNkHk9Gyl/7M1uCzihThIiYzA=----ATTACHMENT:----Mzg0NjEzODQxODgzODk1MSA2MTMzNjk5NzU4MjcwNTgxIDUzMzUzNzI4MTk0Njk2Mzk=