[DependencyInjection] Remove get*Alias*Service methods from compiled containers
This commit is contained in:
parent
379f5e08b4
commit
bb797ee755
@ -594,39 +594,6 @@ EOF;
|
|||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a service alias.
|
|
||||||
*
|
|
||||||
* @param string $alias
|
|
||||||
* @param string $id
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function addServiceAlias($alias, $id)
|
|
||||||
{
|
|
||||||
$name = Container::camelize($alias);
|
|
||||||
$type = 'Object';
|
|
||||||
|
|
||||||
if ($this->container->hasDefinition($id)) {
|
|
||||||
$class = $this->container->getDefinition($id)->getClass();
|
|
||||||
$type = 0 === strpos($class, '%') ? 'Object' : $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <<<EOF
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the $alias service alias.
|
|
||||||
*
|
|
||||||
* @return $type An instance of the $id service
|
|
||||||
*/
|
|
||||||
protected function get{$name}Service()
|
|
||||||
{
|
|
||||||
return {$this->getServiceCall($id)};
|
|
||||||
}
|
|
||||||
|
|
||||||
EOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds multiple services
|
* Adds multiple services
|
||||||
*
|
*
|
||||||
@ -634,7 +601,7 @@ EOF;
|
|||||||
*/
|
*/
|
||||||
private function addServices()
|
private function addServices()
|
||||||
{
|
{
|
||||||
$publicServices = $privateServices = $aliasServices = $synchronizers = '';
|
$publicServices = $privateServices = $synchronizers = '';
|
||||||
$definitions = $this->container->getDefinitions();
|
$definitions = $this->container->getDefinitions();
|
||||||
ksort($definitions);
|
ksort($definitions);
|
||||||
foreach ($definitions as $id => $definition) {
|
foreach ($definitions as $id => $definition) {
|
||||||
@ -647,13 +614,7 @@ EOF;
|
|||||||
$synchronizers .= $this->addServiceSynchronizer($id, $definition);
|
$synchronizers .= $this->addServiceSynchronizer($id, $definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
$aliases = $this->container->getAliases();
|
return $publicServices.$synchronizers.$privateServices;
|
||||||
ksort($aliases);
|
|
||||||
foreach ($aliases as $alias => $id) {
|
|
||||||
$aliasServices .= $this->addServiceAlias($alias, $id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $publicServices.$aliasServices.$synchronizers.$privateServices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,16 +214,6 @@ class ProjectServiceContainer extends Container
|
|||||||
throw new RuntimeException('You have requested a synthetic service ("request"). The DIC does not know how to construct this service.');
|
throw new RuntimeException('You have requested a synthetic service ("request"). The DIC does not know how to construct this service.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the alias_for_foo service alias.
|
|
||||||
*
|
|
||||||
* @return FooClass An instance of the foo service
|
|
||||||
*/
|
|
||||||
protected function getAliasForFooService()
|
|
||||||
{
|
|
||||||
return $this->get('foo');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the 'request' service.
|
* Updates the 'request' service.
|
||||||
*/
|
*/
|
||||||
|
@ -219,16 +219,6 @@ class ProjectServiceContainer extends Container
|
|||||||
throw new RuntimeException('You have requested a synthetic service ("request"). The DIC does not know how to construct this service.');
|
throw new RuntimeException('You have requested a synthetic service ("request"). The DIC does not know how to construct this service.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the alias_for_foo service alias.
|
|
||||||
*
|
|
||||||
* @return FooClass An instance of the foo service
|
|
||||||
*/
|
|
||||||
protected function getAliasForFooService()
|
|
||||||
{
|
|
||||||
return $this->get('foo');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the 'request' service.
|
* Updates the 'request' service.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user