[DI] Turn services and aliases private by default, with BC layer
This commit is contained in:
parent
c4159b12c7
commit
9948b09c6d
@ -4,6 +4,9 @@ UPGRADE FROM 3.3 to 3.4
|
|||||||
DependencyInjection
|
DependencyInjection
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* Definitions and aliases will be made private by default in 4.0. You should either use service injection
|
||||||
|
or explicitly define your services as public if you really need to inject the container.
|
||||||
|
|
||||||
* Relying on service auto-registration while autowiring is deprecated and won't be supported
|
* Relying on service auto-registration while autowiring is deprecated and won't be supported
|
||||||
in Symfony 4.0. Explicitly inject your dependencies or create services
|
in Symfony 4.0. Explicitly inject your dependencies or create services
|
||||||
whose ids are their fully-qualified class name.
|
whose ids are their fully-qualified class name.
|
||||||
|
@ -77,6 +77,9 @@ Debug
|
|||||||
DependencyInjection
|
DependencyInjection
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* Definitions and aliases are now private by default in 4.0. You should either use service injection
|
||||||
|
or explicitly define your services as public if you really need to inject the container.
|
||||||
|
|
||||||
* Relying on service auto-registration while autowiring is not supported anymore.
|
* Relying on service auto-registration while autowiring is not supported anymore.
|
||||||
Explicitly inject your dependencies or create services whose ids are
|
Explicitly inject your dependencies or create services whose ids are
|
||||||
their fully-qualified class name.
|
their fully-qualified class name.
|
||||||
|
@ -61,7 +61,7 @@ class PhpDumperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
$container->register('foo', 'stdClass');
|
$container->register('foo', 'stdClass')->setPublic(true);
|
||||||
$container->getDefinition('foo')->setLazy(true);
|
$container->getDefinition('foo')->setLazy(true);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
|
@ -1012,12 +1012,12 @@ class FrameworkExtension extends Extension
|
|||||||
|
|
||||||
// Use a delegation unless only a single engine was registered
|
// Use a delegation unless only a single engine was registered
|
||||||
if (1 === count($engines)) {
|
if (1 === count($engines)) {
|
||||||
$container->setAlias('templating', (string) reset($engines));
|
$container->setAlias('templating', (string) reset($engines))->setPublic(true);
|
||||||
} else {
|
} else {
|
||||||
foreach ($engines as $engine) {
|
foreach ($engines as $engine) {
|
||||||
$container->getDefinition('templating.engine.delegating')->addMethodCall('addEngine', array($engine));
|
$container->getDefinition('templating.engine.delegating')->addMethodCall('addEngine', array($engine));
|
||||||
}
|
}
|
||||||
$container->setAlias('templating', 'templating.engine.delegating');
|
$container->setAlias('templating', 'templating.engine.delegating')->setPublic(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$container->getDefinition('fragment.renderer.hinclude')
|
$container->getDefinition('fragment.renderer.hinclude')
|
||||||
@ -1213,7 +1213,7 @@ class FrameworkExtension extends Extension
|
|||||||
$container->getDefinition('translation.writer')->setPrivate(true);
|
$container->getDefinition('translation.writer')->setPrivate(true);
|
||||||
|
|
||||||
// Use the "real" translator instead of the identity default
|
// Use the "real" translator instead of the identity default
|
||||||
$container->setAlias('translator', 'translator.default');
|
$container->setAlias('translator', 'translator.default')->setPublic(true);
|
||||||
$container->setAlias('translator.formatter', new Alias($config['formatter'], false));
|
$container->setAlias('translator.formatter', new Alias($config['formatter'], false));
|
||||||
$translator = $container->findDefinition('translator.default');
|
$translator = $container->findDefinition('translator.default');
|
||||||
$translator->addMethodCall('setFallbackLocales', array($config['fallbacks']));
|
$translator->addMethodCall('setFallbackLocales', array($config['fallbacks']));
|
||||||
|
@ -72,6 +72,7 @@ trait MicroKernelTrait
|
|||||||
if ($this instanceof EventSubscriberInterface) {
|
if ($this instanceof EventSubscriberInterface) {
|
||||||
$container->register('kernel', static::class)
|
$container->register('kernel', static::class)
|
||||||
->setSynthetic(true)
|
->setSynthetic(true)
|
||||||
|
->setPublic(true)
|
||||||
->addTag('kernel.event_subscriber')
|
->addTag('kernel.event_subscriber')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ imports:
|
|||||||
- { resource: ../config/default.yml }
|
- { resource: ../config/default.yml }
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
_defaults: { public: true }
|
||||||
test.autowiring_types.autowired_services:
|
test.autowiring_types.autowired_services:
|
||||||
class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\AutowiredServices
|
class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\AutowiredServices
|
||||||
autowire: true
|
autowire: true
|
||||||
|
@ -2,6 +2,7 @@ imports:
|
|||||||
- { resource: ../config/default.yml }
|
- { resource: ../config/default.yml }
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
_defaults: { public: true }
|
||||||
public:
|
public:
|
||||||
class: Symfony\Bundle\FrameworkBundle\Tests\Fixtures\DeclaredClass
|
class: Symfony\Bundle\FrameworkBundle\Tests\Fixtures\DeclaredClass
|
||||||
private_alias:
|
private_alias:
|
||||||
|
@ -2,6 +2,7 @@ imports:
|
|||||||
- { resource: ../config/default.yml }
|
- { resource: ../config/default.yml }
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
_defaults: { public: true }
|
||||||
test.property_info: '@property_info'
|
test.property_info: '@property_info'
|
||||||
|
|
||||||
framework:
|
framework:
|
||||||
|
@ -82,7 +82,7 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface
|
|||||||
));
|
));
|
||||||
|
|
||||||
$c->setParameter('halloween', 'Have a great day!');
|
$c->setParameter('halloween', 'Have a great day!');
|
||||||
$c->register('halloween', 'stdClass');
|
$c->register('halloween', 'stdClass')->setPublic(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,7 +185,7 @@ class SecurityExtension extends Extension
|
|||||||
$container->getAlias('security.acl.provider')->setPrivate(true);
|
$container->getAlias('security.acl.provider')->setPrivate(true);
|
||||||
|
|
||||||
if (null !== $config['connection']) {
|
if (null !== $config['connection']) {
|
||||||
$container->setAlias('security.acl.dbal.connection', sprintf('doctrine.dbal.%s_connection', $config['connection']));
|
$container->setAlias('security.acl.dbal.connection', sprintf('doctrine.dbal.%s_connection', $config['connection']))->setPrivate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$container
|
$container
|
||||||
|
@ -2,6 +2,7 @@ imports:
|
|||||||
- { resource: ./../config/framework.yml }
|
- { resource: ./../config/framework.yml }
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
_defaults: { public: true }
|
||||||
test.security.acl.provider: '@security.acl.provider'
|
test.security.acl.provider: '@security.acl.provider'
|
||||||
|
|
||||||
doctrine:
|
doctrine:
|
||||||
|
@ -2,6 +2,7 @@ imports:
|
|||||||
- { resource: ../config/framework.yml }
|
- { resource: ../config/framework.yml }
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
_defaults: { public: true }
|
||||||
test.autowiring_types.autowired_services:
|
test.autowiring_types.autowired_services:
|
||||||
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle\AutowiredServices
|
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle\AutowiredServices
|
||||||
autowire: true
|
autowire: true
|
||||||
|
@ -65,8 +65,8 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
|||||||
if (isset($serviceIds[$commandId]) || $container->hasAlias($commandId)) {
|
if (isset($serviceIds[$commandId]) || $container->hasAlias($commandId)) {
|
||||||
$commandId = $commandId.'_'.$id;
|
$commandId = $commandId.'_'.$id;
|
||||||
}
|
}
|
||||||
if (!$definition->isPublic()) {
|
if (!$definition->isPublic() || $definition->isPrivate()) {
|
||||||
$container->setAlias($commandId, $id);
|
$container->setAlias($commandId, $id)->setPublic(true);
|
||||||
$id = $commandId;
|
$id = $commandId;
|
||||||
}
|
}
|
||||||
$serviceIds[$commandId] = $id;
|
$serviceIds[$commandId] = $id;
|
||||||
@ -97,6 +97,7 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
|||||||
|
|
||||||
$container
|
$container
|
||||||
->register($this->commandLoaderServiceId, ContainerCommandLoader::class)
|
->register($this->commandLoaderServiceId, ContainerCommandLoader::class)
|
||||||
|
->setPublic(true)
|
||||||
->setArguments(array(ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap));
|
->setArguments(array(ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap));
|
||||||
|
|
||||||
$container->setParameter('console.command.ids', $serviceIds);
|
$container->setParameter('console.command.ids', $serviceIds);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/config": "~3.3|~4.0",
|
"symfony/config": "~3.3|~4.0",
|
||||||
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
|
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
|
||||||
"symfony/dependency-injection": "~3.3|~4.0",
|
"symfony/dependency-injection": "~3.4|~4.0",
|
||||||
"symfony/lock": "~3.4|~4.0",
|
"symfony/lock": "~3.4|~4.0",
|
||||||
"symfony/process": "~3.3|~4.0",
|
"symfony/process": "~3.3|~4.0",
|
||||||
"psr/log": "~1.0"
|
"psr/log": "~1.0"
|
||||||
@ -35,7 +35,7 @@
|
|||||||
"psr/log": "For using the console logger"
|
"psr/log": "For using the console logger"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"symfony/dependency-injection": "<3.3",
|
"symfony/dependency-injection": "<3.4",
|
||||||
"symfony/process": "<3.3"
|
"symfony/process": "<3.3"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -15,7 +15,7 @@ class Alias
|
|||||||
{
|
{
|
||||||
private $id;
|
private $id;
|
||||||
private $public;
|
private $public;
|
||||||
private $private = false;
|
private $private;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $id Alias identifier
|
* @param string $id Alias identifier
|
||||||
@ -25,6 +25,7 @@ class Alias
|
|||||||
{
|
{
|
||||||
$this->id = (string) $id;
|
$this->id = (string) $id;
|
||||||
$this->public = $public;
|
$this->public = $public;
|
||||||
|
$this->private = 2 > func_num_args();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,6 +48,7 @@ class Alias
|
|||||||
public function setPublic($boolean)
|
public function setPublic($boolean)
|
||||||
{
|
{
|
||||||
$this->public = (bool) $boolean;
|
$this->public = (bool) $boolean;
|
||||||
|
$this->private = false;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ CHANGELOG
|
|||||||
3.4.0
|
3.4.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* deprecated "public-by-default" definitions and aliases, the new default will be "private" in 4.0
|
||||||
* added `EnvVarProcessorInterface` and corresponding "container.env_var_processor" tag for processing env vars
|
* added `EnvVarProcessorInterface` and corresponding "container.env_var_processor" tag for processing env vars
|
||||||
* added support for ignore-on-uninitialized references
|
* added support for ignore-on-uninitialized references
|
||||||
* deprecated service auto-registration while autowiring
|
* deprecated service auto-registration while autowiring
|
||||||
|
@ -33,7 +33,7 @@ class AutoAliasServicePass implements CompilerPassInterface
|
|||||||
|
|
||||||
$aliasId = $container->getParameterBag()->resolveValue($tag['format']);
|
$aliasId = $container->getParameterBag()->resolveValue($tag['format']);
|
||||||
if ($container->hasDefinition($aliasId) || $container->hasAlias($aliasId)) {
|
if ($container->hasDefinition($aliasId) || $container->hasAlias($aliasId)) {
|
||||||
$container->setAlias($serviceId, new Alias($aliasId));
|
$container->setAlias($serviceId, new Alias($aliasId, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class CheckDefinitionValidityPass implements CompilerPassInterface
|
|||||||
{
|
{
|
||||||
foreach ($container->getDefinitions() as $id => $definition) {
|
foreach ($container->getDefinitions() as $id => $definition) {
|
||||||
// synthetic service is public
|
// synthetic service is public
|
||||||
if ($definition->isSynthetic() && (!$definition->isPublic() || $definition->isPrivate())) {
|
if ($definition->isSynthetic() && !($definition->isPublic() || $definition->isPrivate())) {
|
||||||
throw new RuntimeException(sprintf('A synthetic service ("%s") must be public.', $id));
|
throw new RuntimeException(sprintf('A synthetic service ("%s") must be public.', $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class DecoratorServicePass implements CompilerPassInterface
|
|||||||
$container->setDefinition($renamedId, $decoratedDefinition);
|
$container->setDefinition($renamedId, $decoratedDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
$container->setAlias($inner, $id)->setPublic($public && !$private)->setPrivate($private);
|
$container->setAlias($inner, $id)->setPublic($public)->setPrivate($private);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ class RegisterEnvVarProcessorsPass implements CompilerPassInterface
|
|||||||
$bag->setProvidedTypes($types);
|
$bag->setProvidedTypes($types);
|
||||||
}
|
}
|
||||||
$container->register('container.env_var_processors_locator', ServiceLocator::class)
|
$container->register('container.env_var_processors_locator', ServiceLocator::class)
|
||||||
|
->setPublic(true)
|
||||||
->setArguments(array($processors))
|
->setArguments(array($processors))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class ReplaceAliasByActualDefinitionPass extends AbstractRecursivePass
|
|||||||
}
|
}
|
||||||
// Check if target needs to be replaces
|
// Check if target needs to be replaces
|
||||||
if (isset($replacements[$targetId])) {
|
if (isset($replacements[$targetId])) {
|
||||||
$container->setAlias($definitionId, $replacements[$targetId]);
|
$container->setAlias($definitionId, $replacements[$targetId])->setPublic($target->isPublic())->setPrivate($target->isPrivate());
|
||||||
}
|
}
|
||||||
// No need to process the same target twice
|
// No need to process the same target twice
|
||||||
if (isset($seenAliasTargets[$targetId])) {
|
if (isset($seenAliasTargets[$targetId])) {
|
||||||
|
@ -36,12 +36,14 @@ class ResolveChildDefinitionsPass extends AbstractRecursivePass
|
|||||||
foreach ($container->getDefinitions() as $definition) {
|
foreach ($container->getDefinitions() as $definition) {
|
||||||
if ($definition->isPrivate()) {
|
if ($definition->isPrivate()) {
|
||||||
$definition->setPublic(false);
|
$definition->setPublic(false);
|
||||||
|
$definition->setPrivate(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($container->getAliases() as $alias) {
|
foreach ($container->getAliases() as $alias) {
|
||||||
if ($alias->isPrivate()) {
|
if ($alias->isPrivate()) {
|
||||||
$alias->setPublic(false);
|
$alias->setPublic(false);
|
||||||
|
$alias->setPrivate(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class ResolveReferencesToAliasesPass extends AbstractRecursivePass
|
|||||||
foreach ($container->getAliases() as $id => $alias) {
|
foreach ($container->getAliases() as $id => $alias) {
|
||||||
$aliasId = (string) $alias;
|
$aliasId = (string) $alias;
|
||||||
if ($aliasId !== $defId = $this->getDefinitionId($aliasId, $container)) {
|
if ($aliasId !== $defId = $this->getDefinitionId($aliasId, $container)) {
|
||||||
$container->setAlias($id, $defId)->setPublic($alias->isPublic() && !$alias->isPrivate())->setPrivate($alias->isPrivate());
|
$container->setAlias($id, $defId)->setPublic($alias->isPublic())->setPrivate($alias->isPrivate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class Definition
|
|||||||
private $configurator;
|
private $configurator;
|
||||||
private $tags = array();
|
private $tags = array();
|
||||||
private $public = true;
|
private $public = true;
|
||||||
private $private = false;
|
private $private = true;
|
||||||
private $synthetic = false;
|
private $synthetic = false;
|
||||||
private $abstract = false;
|
private $abstract = false;
|
||||||
private $lazy = false;
|
private $lazy = false;
|
||||||
@ -603,6 +603,7 @@ class Definition
|
|||||||
$this->changes['public'] = true;
|
$this->changes['public'] = true;
|
||||||
|
|
||||||
$this->public = (bool) $boolean;
|
$this->public = (bool) $boolean;
|
||||||
|
$this->private = false;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ class XmlDumper extends Dumper
|
|||||||
if (!$definition->isShared()) {
|
if (!$definition->isShared()) {
|
||||||
$service->setAttribute('shared', 'false');
|
$service->setAttribute('shared', 'false');
|
||||||
}
|
}
|
||||||
if (!$definition->isPublic()) {
|
if (!$definition->isPrivate()) {
|
||||||
$service->setAttribute('public', 'false');
|
$service->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
|
||||||
}
|
}
|
||||||
if ($definition->isSynthetic()) {
|
if ($definition->isSynthetic()) {
|
||||||
$service->setAttribute('synthetic', 'true');
|
$service->setAttribute('synthetic', 'true');
|
||||||
@ -242,8 +242,8 @@ class XmlDumper extends Dumper
|
|||||||
$service = $this->document->createElement('service');
|
$service = $this->document->createElement('service');
|
||||||
$service->setAttribute('id', $alias);
|
$service->setAttribute('id', $alias);
|
||||||
$service->setAttribute('alias', $id);
|
$service->setAttribute('alias', $id);
|
||||||
if (!$id->isPublic()) {
|
if (!$id->isPrivate()) {
|
||||||
$service->setAttribute('public', 'false');
|
$service->setAttribute('public', $id->isPublic() ? 'true' : 'false');
|
||||||
}
|
}
|
||||||
$parent->appendChild($service);
|
$parent->appendChild($service);
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,8 @@ class YamlDumper extends Dumper
|
|||||||
$code .= sprintf(" class: %s\n", $this->dumper->dump($class));
|
$code .= sprintf(" class: %s\n", $this->dumper->dump($class));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$definition->isPublic()) {
|
if (!$definition->isPrivate()) {
|
||||||
$code .= " public: false\n";
|
$code .= sprintf(" public: %s\n", $definition->isPublic() ? 'true' : 'false');
|
||||||
}
|
}
|
||||||
|
|
||||||
$tagsCode = '';
|
$tagsCode = '';
|
||||||
@ -178,11 +178,11 @@ class YamlDumper extends Dumper
|
|||||||
*/
|
*/
|
||||||
private function addServiceAlias($alias, $id)
|
private function addServiceAlias($alias, $id)
|
||||||
{
|
{
|
||||||
if ($id->isPublic()) {
|
if ($id->isPrivate()) {
|
||||||
return sprintf(" %s: '@%s'\n", $alias, $id);
|
return sprintf(" %s: '@%s'\n", $alias, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf(" %s:\n alias: %s\n public: false\n", $alias, $id);
|
return sprintf(" %s:\n alias: %s\n public: %s\n", $alias, $id, $id->isPublic() ? 'true' : 'false');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,13 +203,12 @@ class XmlFileLoader extends FileLoader
|
|||||||
if ($alias = $service->getAttribute('alias')) {
|
if ($alias = $service->getAttribute('alias')) {
|
||||||
$this->validateAlias($service, $file);
|
$this->validateAlias($service, $file);
|
||||||
|
|
||||||
$public = true;
|
$this->container->setAlias((string) $service->getAttribute('id'), $alias = new Alias($alias));
|
||||||
if ($publicAttr = $service->getAttribute('public')) {
|
if ($publicAttr = $service->getAttribute('public')) {
|
||||||
$public = XmlUtils::phpize($publicAttr);
|
$alias->setPublic(XmlUtils::phpize($publicAttr));
|
||||||
} elseif (isset($defaults['public'])) {
|
} elseif (isset($defaults['public'])) {
|
||||||
$public = $defaults['public'];
|
$alias->setPublic($defaults['public']);
|
||||||
}
|
}
|
||||||
$this->container->setAlias((string) $service->getAttribute('id'), new Alias($alias, $public));
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -336,8 +336,10 @@ class YamlFileLoader extends FileLoader
|
|||||||
@trigger_error(sprintf('Service names that start with an underscore are deprecated since Symfony 3.3 and will be reserved in 4.0. Rename the "%s" service or define it in XML instead.', $id), E_USER_DEPRECATED);
|
@trigger_error(sprintf('Service names that start with an underscore are deprecated since Symfony 3.3 and will be reserved in 4.0. Rename the "%s" service or define it in XML instead.', $id), E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
if (is_string($service) && 0 === strpos($service, '@')) {
|
if (is_string($service) && 0 === strpos($service, '@')) {
|
||||||
$public = isset($defaults['public']) ? $defaults['public'] : true;
|
$this->container->setAlias($id, $alias = new Alias(substr($service, 1)));
|
||||||
$this->container->setAlias($id, new Alias(substr($service, 1), $public));
|
if (isset($defaults['public'])) {
|
||||||
|
$alias->setPublic($defaults['public']);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -357,8 +359,12 @@ class YamlFileLoader extends FileLoader
|
|||||||
$this->checkDefinition($id, $service, $file);
|
$this->checkDefinition($id, $service, $file);
|
||||||
|
|
||||||
if (isset($service['alias'])) {
|
if (isset($service['alias'])) {
|
||||||
$public = array_key_exists('public', $service) ? (bool) $service['public'] : (isset($defaults['public']) ? $defaults['public'] : true);
|
$this->container->setAlias($id, $alias = new Alias($service['alias']));
|
||||||
$this->container->setAlias($id, new Alias($service['alias'], $public));
|
if (array_key_exists('public', $service)) {
|
||||||
|
$alias->setPublic($service['public']);
|
||||||
|
} elseif (isset($defaults['public'])) {
|
||||||
|
$alias->setPublic($defaults['public']);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($service as $key => $value) {
|
foreach ($service as $key => $value) {
|
||||||
if (!in_array($key, array('alias', 'public'))) {
|
if (!in_array($key, array('alias', 'public'))) {
|
||||||
|
@ -402,13 +402,13 @@ class ResolveChildDefinitionsPassTest extends TestCase
|
|||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
$container->register('foo', 'stdClass')
|
$container->register('foo', 'stdClass')
|
||||||
->setPrivate(true)
|
|
||||||
->setPublic(true)
|
->setPublic(true)
|
||||||
|
->setPrivate(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
$container->setAlias('bar', 'foo')
|
$container->setAlias('bar', 'foo')
|
||||||
->setPrivate(false)
|
|
||||||
->setPublic(false)
|
->setPublic(false)
|
||||||
|
->setPrivate(false)
|
||||||
;
|
;
|
||||||
|
|
||||||
$this->process($container);
|
$this->process($container);
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Config\FileLocator;
|
|||||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||||
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
|
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
|
||||||
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
||||||
|
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface;
|
||||||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||||
@ -71,6 +72,7 @@ class PhpDumperTest extends TestCase
|
|||||||
'optimize concatenation from the start' => '%empty_value%start',
|
'optimize concatenation from the start' => '%empty_value%start',
|
||||||
'optimize concatenation at the end' => 'end%empty_value%',
|
'optimize concatenation at the end' => 'end%empty_value%',
|
||||||
));
|
));
|
||||||
|
$definition->setPublic(true);
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->setResourceTracking(false);
|
$container->setResourceTracking(false);
|
||||||
@ -89,6 +91,7 @@ class PhpDumperTest extends TestCase
|
|||||||
$definition->setClass('stdClass');
|
$definition->setClass('stdClass');
|
||||||
$definition->addArgument('%foo%');
|
$definition->addArgument('%foo%');
|
||||||
$definition->addArgument(array('%foo%' => '%buz%/'));
|
$definition->addArgument(array('%foo%' => '%buz%/'));
|
||||||
|
$definition->setPublic(true);
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->setDefinition('test', $definition);
|
$container->setDefinition('test', $definition);
|
||||||
@ -151,7 +154,7 @@ class PhpDumperTest extends TestCase
|
|||||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services9_compiled.php', str_replace(str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), '%path%', $dumper->dump()), '->dump() dumps services');
|
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services9_compiled.php', str_replace(str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), '%path%', $dumper->dump()), '->dump() dumps services');
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
|
$container->register('foo', 'FooClass')->addArgument(new \stdClass())->setPublic(true);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
try {
|
try {
|
||||||
@ -188,8 +191,8 @@ class PhpDumperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$class = 'Symfony_DI_PhpDumper_Test_Unsupported_Characters';
|
$class = 'Symfony_DI_PhpDumper_Test_Unsupported_Characters';
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('bar$', 'FooClass');
|
$container->register('bar$', 'FooClass')->setPublic(true);
|
||||||
$container->register('bar$!', 'FooClass');
|
$container->register('bar$!', 'FooClass')->setPublic(true);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
eval('?>'.$dumper->dump(array('class' => $class)));
|
eval('?>'.$dumper->dump(array('class' => $class)));
|
||||||
@ -202,8 +205,8 @@ class PhpDumperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$class = 'Symfony_DI_PhpDumper_Test_Conflicting_Service_Ids';
|
$class = 'Symfony_DI_PhpDumper_Test_Conflicting_Service_Ids';
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo_bar', 'FooClass');
|
$container->register('foo_bar', 'FooClass')->setPublic(true);
|
||||||
$container->register('foobar', 'FooClass');
|
$container->register('foobar', 'FooClass')->setPublic(true);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
eval('?>'.$dumper->dump(array('class' => $class)));
|
eval('?>'.$dumper->dump(array('class' => $class)));
|
||||||
@ -216,8 +219,8 @@ class PhpDumperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$class = 'Symfony_DI_PhpDumper_Test_Conflicting_Method_With_Parent';
|
$class = 'Symfony_DI_PhpDumper_Test_Conflicting_Method_With_Parent';
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('bar', 'FooClass');
|
$container->register('bar', 'FooClass')->setPublic(true);
|
||||||
$container->register('foo_bar', 'FooClass');
|
$container->register('foo_bar', 'FooClass')->setPublic(true);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
eval('?>'.$dumper->dump(array(
|
eval('?>'.$dumper->dump(array(
|
||||||
@ -238,6 +241,7 @@ class PhpDumperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$def = new Definition('stdClass');
|
$def = new Definition('stdClass');
|
||||||
|
$def->setPublic(true);
|
||||||
$def->setFactory($factory);
|
$def->setFactory($factory);
|
||||||
$container->setDefinition('bar', $def);
|
$container->setDefinition('bar', $def);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
@ -319,9 +323,9 @@ class PhpDumperTest extends TestCase
|
|||||||
public function testCircularReference()
|
public function testCircularReference()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo', 'stdClass')->addArgument(new Reference('bar'));
|
$container->register('foo', 'stdClass')->addArgument(new Reference('bar'))->setPublic(true);
|
||||||
$container->register('bar', 'stdClass')->setPublic(false)->addMethodCall('setA', array(new Reference('baz')));
|
$container->register('bar', 'stdClass')->setPublic(false)->addMethodCall('setA', array(new Reference('baz')));
|
||||||
$container->register('baz', 'stdClass')->addMethodCall('setA', array(new Reference('foo')));
|
$container->register('baz', 'stdClass')->addMethodCall('setA', array(new Reference('foo')))->setPublic(true);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
@ -394,7 +398,7 @@ class PhpDumperTest extends TestCase
|
|||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->setParameter('env(foo)', str_rot13('world'));
|
$container->setParameter('env(foo)', str_rot13('world'));
|
||||||
$container->setParameter('hello', '%env(rot13:foo)%');
|
$container->setParameter('hello', '%env(rot13:foo)%');
|
||||||
$container->register(Rot13EnvVarProcessor::class)->addTag('container.env_var_processor');
|
$container->register(Rot13EnvVarProcessor::class)->addTag('container.env_var_processor')->setPublic(true);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
@ -459,7 +463,7 @@ class PhpDumperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo', 'stdClass')->addMethodCall('add', array(new Reference('service_container')))->setPublic(false);
|
$container->register('foo', 'stdClass')->addMethodCall('add', array(new Reference('service_container')))->setPublic(false);
|
||||||
$container->register('bar', 'stdClass')->addArgument(new Reference('foo'));
|
$container->register('bar', 'stdClass')->addArgument(new Reference('foo'))->setPublic(true);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
@ -471,8 +475,9 @@ class PhpDumperTest extends TestCase
|
|||||||
require_once self::$fixturesPath.'/includes/classes.php';
|
require_once self::$fixturesPath.'/includes/classes.php';
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo', 'stdClass');
|
$container->register('foo', 'stdClass')->setPublic(true);
|
||||||
$container->register('bar', 'MethodCallClass')
|
$container->register('bar', 'MethodCallClass')
|
||||||
|
->setPublic(true)
|
||||||
->setProperty('simple', 'bar')
|
->setProperty('simple', 'bar')
|
||||||
->setProperty('complex', new Reference('foo'))
|
->setProperty('complex', new Reference('foo'))
|
||||||
->addMethodCall('callMe');
|
->addMethodCall('callMe');
|
||||||
@ -488,8 +493,8 @@ class PhpDumperTest extends TestCase
|
|||||||
public function testCircularReferenceAllowanceForLazyServices()
|
public function testCircularReferenceAllowanceForLazyServices()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo', 'stdClass')->addArgument(new Reference('bar'));
|
$container->register('foo', 'stdClass')->addArgument(new Reference('bar'))->setPublic(true);
|
||||||
$container->register('bar', 'stdClass')->setLazy(true)->addArgument(new Reference('foo'));
|
$container->register('bar', 'stdClass')->setLazy(true)->addArgument(new Reference('foo'))->setPublic(true);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
@ -514,14 +519,16 @@ class PhpDumperTest extends TestCase
|
|||||||
|
|
||||||
$eventManagerDefinition = new Definition('stdClass');
|
$eventManagerDefinition = new Definition('stdClass');
|
||||||
|
|
||||||
$connectionDefinition = $container->register('connection', 'stdClass');
|
$connectionDefinition = $container->register('connection', 'stdClass')->setPublic(true);
|
||||||
$connectionDefinition->addArgument($eventManagerDefinition);
|
$connectionDefinition->addArgument($eventManagerDefinition);
|
||||||
|
|
||||||
$container->register('entity_manager', 'stdClass')
|
$container->register('entity_manager', 'stdClass')
|
||||||
|
->setPublic(true)
|
||||||
->setLazy(true)
|
->setLazy(true)
|
||||||
->addArgument(new Reference('connection'));
|
->addArgument(new Reference('connection'));
|
||||||
|
|
||||||
$lazyServiceDefinition = $container->register('lazy_service', 'stdClass');
|
$lazyServiceDefinition = $container->register('lazy_service', 'stdClass');
|
||||||
|
$lazyServiceDefinition->setPublic(true);
|
||||||
$lazyServiceDefinition->setLazy(true);
|
$lazyServiceDefinition->setLazy(true);
|
||||||
$lazyServiceDefinition->addArgument(new Reference('entity_manager'));
|
$lazyServiceDefinition->addArgument(new Reference('entity_manager'));
|
||||||
|
|
||||||
@ -542,9 +549,10 @@ class PhpDumperTest extends TestCase
|
|||||||
require_once self::$fixturesPath.'/includes/classes.php';
|
require_once self::$fixturesPath.'/includes/classes.php';
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('lazy_referenced', 'stdClass');
|
$container->register('lazy_referenced', 'stdClass')->setPublic(true);
|
||||||
$container
|
$container
|
||||||
->register('lazy_context', 'LazyContext')
|
->register('lazy_context', 'LazyContext')
|
||||||
|
->setPublic(true)
|
||||||
->setArguments(array(
|
->setArguments(array(
|
||||||
new IteratorArgument(array('k1' => new Reference('lazy_referenced'), 'k2' => new Reference('service_container'))),
|
new IteratorArgument(array('k1' => new Reference('lazy_referenced'), 'k2' => new Reference('service_container'))),
|
||||||
new IteratorArgument(array()),
|
new IteratorArgument(array()),
|
||||||
@ -592,8 +600,8 @@ class PhpDumperTest extends TestCase
|
|||||||
public function testDumpContainerBuilderWithFrozenConstructorIncludingPrivateServices()
|
public function testDumpContainerBuilderWithFrozenConstructorIncludingPrivateServices()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo_service', 'stdClass')->setArguments(array(new Reference('baz_service')));
|
$container->register('foo_service', 'stdClass')->setArguments(array(new Reference('baz_service')))->setPublic(true);
|
||||||
$container->register('bar_service', 'stdClass')->setArguments(array(new Reference('baz_service')));
|
$container->register('bar_service', 'stdClass')->setArguments(array(new Reference('baz_service')))->setPublic(true);
|
||||||
$container->register('baz_service', 'stdClass')->setPublic(false);
|
$container->register('baz_service', 'stdClass')->setPublic(false);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
@ -606,6 +614,7 @@ class PhpDumperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo_service', ServiceLocator::class)
|
$container->register('foo_service', ServiceLocator::class)
|
||||||
|
->setPublic(true)
|
||||||
->addArgument(array(
|
->addArgument(array(
|
||||||
'bar' => new ServiceClosureArgument(new Reference('bar_service')),
|
'bar' => new ServiceClosureArgument(new Reference('bar_service')),
|
||||||
'baz' => new ServiceClosureArgument(new TypedReference('baz_service', 'stdClass')),
|
'baz' => new ServiceClosureArgument(new TypedReference('baz_service', 'stdClass')),
|
||||||
@ -614,40 +623,43 @@ class PhpDumperTest extends TestCase
|
|||||||
;
|
;
|
||||||
|
|
||||||
// no method calls
|
// no method calls
|
||||||
$container->register('translator.loader_1', 'stdClass');
|
$container->register('translator.loader_1', 'stdClass')->setPublic(true);
|
||||||
$container->register('translator.loader_1_locator', ServiceLocator::class)
|
$container->register('translator.loader_1_locator', ServiceLocator::class)
|
||||||
->setPublic(false)
|
->setPublic(false)
|
||||||
->addArgument(array(
|
->addArgument(array(
|
||||||
'translator.loader_1' => new ServiceClosureArgument(new Reference('translator.loader_1')),
|
'translator.loader_1' => new ServiceClosureArgument(new Reference('translator.loader_1')),
|
||||||
));
|
));
|
||||||
$container->register('translator_1', StubbedTranslator::class)
|
$container->register('translator_1', StubbedTranslator::class)
|
||||||
|
->setPublic(true)
|
||||||
->addArgument(new Reference('translator.loader_1_locator'));
|
->addArgument(new Reference('translator.loader_1_locator'));
|
||||||
|
|
||||||
// one method calls
|
// one method calls
|
||||||
$container->register('translator.loader_2', 'stdClass');
|
$container->register('translator.loader_2', 'stdClass')->setPublic(true);
|
||||||
$container->register('translator.loader_2_locator', ServiceLocator::class)
|
$container->register('translator.loader_2_locator', ServiceLocator::class)
|
||||||
->setPublic(false)
|
->setPublic(false)
|
||||||
->addArgument(array(
|
->addArgument(array(
|
||||||
'translator.loader_2' => new ServiceClosureArgument(new Reference('translator.loader_2')),
|
'translator.loader_2' => new ServiceClosureArgument(new Reference('translator.loader_2')),
|
||||||
));
|
));
|
||||||
$container->register('translator_2', StubbedTranslator::class)
|
$container->register('translator_2', StubbedTranslator::class)
|
||||||
|
->setPublic(true)
|
||||||
->addArgument(new Reference('translator.loader_2_locator'))
|
->addArgument(new Reference('translator.loader_2_locator'))
|
||||||
->addMethodCall('addResource', array('db', new Reference('translator.loader_2'), 'nl'));
|
->addMethodCall('addResource', array('db', new Reference('translator.loader_2'), 'nl'));
|
||||||
|
|
||||||
// two method calls
|
// two method calls
|
||||||
$container->register('translator.loader_3', 'stdClass');
|
$container->register('translator.loader_3', 'stdClass')->setPublic(true);
|
||||||
$container->register('translator.loader_3_locator', ServiceLocator::class)
|
$container->register('translator.loader_3_locator', ServiceLocator::class)
|
||||||
->setPublic(false)
|
->setPublic(false)
|
||||||
->addArgument(array(
|
->addArgument(array(
|
||||||
'translator.loader_3' => new ServiceClosureArgument(new Reference('translator.loader_3')),
|
'translator.loader_3' => new ServiceClosureArgument(new Reference('translator.loader_3')),
|
||||||
));
|
));
|
||||||
$container->register('translator_3', StubbedTranslator::class)
|
$container->register('translator_3', StubbedTranslator::class)
|
||||||
|
->setPublic(true)
|
||||||
->addArgument(new Reference('translator.loader_3_locator'))
|
->addArgument(new Reference('translator.loader_3_locator'))
|
||||||
->addMethodCall('addResource', array('db', new Reference('translator.loader_3'), 'nl'))
|
->addMethodCall('addResource', array('db', new Reference('translator.loader_3'), 'nl'))
|
||||||
->addMethodCall('addResource', array('db', new Reference('translator.loader_3'), 'en'));
|
->addMethodCall('addResource', array('db', new Reference('translator.loader_3'), 'en'));
|
||||||
|
|
||||||
$nil->setValues(array(null));
|
$nil->setValues(array(null));
|
||||||
$container->register('bar_service', 'stdClass')->setArguments(array(new Reference('baz_service')));
|
$container->register('bar_service', 'stdClass')->setArguments(array(new Reference('baz_service')))->setPublic(true);
|
||||||
$container->register('baz_service', 'stdClass')->setPublic(false);
|
$container->register('baz_service', 'stdClass')->setPublic(false);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
@ -660,6 +672,7 @@ class PhpDumperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo_service', TestServiceSubscriber::class)
|
$container->register('foo_service', TestServiceSubscriber::class)
|
||||||
|
->setPublic(true)
|
||||||
->setAutowired(true)
|
->setAutowired(true)
|
||||||
->addArgument(new Reference(ContainerInterface::class))
|
->addArgument(new Reference(ContainerInterface::class))
|
||||||
->addTag('container.service_subscriber', array(
|
->addTag('container.service_subscriber', array(
|
||||||
@ -667,7 +680,7 @@ class PhpDumperTest extends TestCase
|
|||||||
'id' => TestServiceSubscriber::class,
|
'id' => TestServiceSubscriber::class,
|
||||||
))
|
))
|
||||||
;
|
;
|
||||||
$container->register(TestServiceSubscriber::class, TestServiceSubscriber::class);
|
$container->register(TestServiceSubscriber::class, TestServiceSubscriber::class)->setPublic(true);
|
||||||
|
|
||||||
$container->register(CustomDefinition::class, CustomDefinition::class)
|
$container->register(CustomDefinition::class, CustomDefinition::class)
|
||||||
->setPublic(false);
|
->setPublic(false);
|
||||||
@ -686,6 +699,7 @@ class PhpDumperTest extends TestCase
|
|||||||
$container->register('not_invalid', 'BazClass')
|
$container->register('not_invalid', 'BazClass')
|
||||||
->setPublic(false);
|
->setPublic(false);
|
||||||
$container->register('bar', 'BarClass')
|
$container->register('bar', 'BarClass')
|
||||||
|
->setPublic(true)
|
||||||
->addMethodCall('setBaz', array(new Reference('not_invalid', SymfonyContainerInterface::IGNORE_ON_INVALID_REFERENCE)));
|
->addMethodCall('setBaz', array(new Reference('not_invalid', SymfonyContainerInterface::IGNORE_ON_INVALID_REFERENCE)));
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
@ -702,6 +716,7 @@ class PhpDumperTest extends TestCase
|
|||||||
$container->setParameter('array_1', array(123));
|
$container->setParameter('array_1', array(123));
|
||||||
$container->setParameter('array_2', array(__DIR__));
|
$container->setParameter('array_2', array(__DIR__));
|
||||||
$container->register('bar', 'BarClass')
|
$container->register('bar', 'BarClass')
|
||||||
|
->setPublic(true)
|
||||||
->addMethodCall('setBaz', array('%array_1%', '%array_2%', '%%array_1%%', array(123)));
|
->addMethodCall('setBaz', array('%array_1%', '%array_2%', '%%array_1%%', array(123)));
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
@ -718,6 +733,7 @@ class PhpDumperTest extends TestCase
|
|||||||
$container->register('private_foo', 'stdClass')
|
$container->register('private_foo', 'stdClass')
|
||||||
->setPublic(false);
|
->setPublic(false);
|
||||||
$container->register('public_foo', 'stdClass')
|
$container->register('public_foo', 'stdClass')
|
||||||
|
->setPublic(true)
|
||||||
->addArgument(new Expression('service("private_foo")'));
|
->addArgument(new Expression('service("private_foo")'));
|
||||||
|
|
||||||
$container->compile();
|
$container->compile();
|
||||||
@ -767,7 +783,7 @@ class PhpDumperTest extends TestCase
|
|||||||
public function testDumpHandlesLiteralClassWithRootNamespace()
|
public function testDumpHandlesLiteralClassWithRootNamespace()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo', '\\stdClass');
|
$container->register('foo', '\\stdClass')->setPublic(true);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
@ -795,6 +811,9 @@ class PhpDumperTest extends TestCase
|
|||||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||||
$loader->load('services_legacy_privates.yml');
|
$loader->load('services_legacy_privates.yml');
|
||||||
|
|
||||||
|
$container->setDefinition('private_child', new ChildDefinition('foo'));
|
||||||
|
$container->setDefinition('private_parent', new ChildDefinition('private'));
|
||||||
|
|
||||||
$container->getDefinition('private')->setPrivate(true);
|
$container->getDefinition('private')->setPrivate(true);
|
||||||
$container->getDefinition('private_not_inlined')->setPrivate(true);
|
$container->getDefinition('private_not_inlined')->setPrivate(true);
|
||||||
$container->getDefinition('private_not_removed')->setPrivate(true);
|
$container->getDefinition('private_not_removed')->setPrivate(true);
|
||||||
|
@ -57,7 +57,7 @@ class XmlDumperTest extends TestCase
|
|||||||
$this->assertEquals(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/xml/services9.xml')), $dumper->dump(), '->dump() dumps services');
|
$this->assertEquals(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/xml/services9.xml')), $dumper->dump(), '->dump() dumps services');
|
||||||
|
|
||||||
$dumper = new XmlDumper($container = new ContainerBuilder());
|
$dumper = new XmlDumper($container = new ContainerBuilder());
|
||||||
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
|
$container->register('foo', 'FooClass')->addArgument(new \stdClass())->setPublic(true);
|
||||||
try {
|
try {
|
||||||
$dumper->dump();
|
$dumper->dump();
|
||||||
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||||
@ -75,7 +75,7 @@ class XmlDumperTest extends TestCase
|
|||||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
<services>
|
<services>
|
||||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||||
<service id="foo" class="FooClass">
|
<service id="foo" class="FooClass" public="true">
|
||||||
<argument type="service">
|
<argument type="service">
|
||||||
<service class="BarClass">
|
<service class="BarClass">
|
||||||
<argument type="service">
|
<argument type="service">
|
||||||
@ -99,7 +99,7 @@ class XmlDumperTest extends TestCase
|
|||||||
<container xmlns=\"http://symfony.com/schema/dic/services\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd\">
|
<container xmlns=\"http://symfony.com/schema/dic/services\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd\">
|
||||||
<services>
|
<services>
|
||||||
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" synthetic=\"true\"/>
|
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" synthetic=\"true\"/>
|
||||||
<service id=\"foo\" class=\"FooClass\Foo\">
|
<service id=\"foo\" class=\"FooClass\Foo\" public=\"true\">
|
||||||
<tag name=\"foo"bar\bar\" foo=\"foo"barřž€\"/>
|
<tag name=\"foo"bar\bar\" foo=\"foo"barřž€\"/>
|
||||||
<argument>foo<>&bar</argument>
|
<argument>foo<>&bar</argument>
|
||||||
</service>
|
</service>
|
||||||
@ -128,7 +128,7 @@ class XmlDumperTest extends TestCase
|
|||||||
<container xmlns=\"http://symfony.com/schema/dic/services\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd\">
|
<container xmlns=\"http://symfony.com/schema/dic/services\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd\">
|
||||||
<services>
|
<services>
|
||||||
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" synthetic=\"true\"/>
|
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" synthetic=\"true\"/>
|
||||||
<service id=\"foo\" class=\"FooClass\Foo\" decorates=\"bar\" decoration-inner-name=\"bar.woozy\"/>
|
<service id=\"foo\" class=\"FooClass\Foo\" public=\"true\" decorates=\"bar\" decoration-inner-name=\"bar.woozy\"/>
|
||||||
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
||||||
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
||||||
</services>
|
</services>
|
||||||
@ -138,7 +138,7 @@ class XmlDumperTest extends TestCase
|
|||||||
<container xmlns=\"http://symfony.com/schema/dic/services\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd\">
|
<container xmlns=\"http://symfony.com/schema/dic/services\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd\">
|
||||||
<services>
|
<services>
|
||||||
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" synthetic=\"true\"/>
|
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" synthetic=\"true\"/>
|
||||||
<service id=\"foo\" class=\"FooClass\Foo\" decorates=\"bar\"/>
|
<service id=\"foo\" class=\"FooClass\Foo\" public=\"true\" decorates=\"bar\"/>
|
||||||
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
||||||
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
||||||
</services>
|
</services>
|
||||||
|
@ -52,7 +52,7 @@ class YamlDumperTest extends TestCase
|
|||||||
$this->assertEqualYamlStructure(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/yaml/services9.yml')), $dumper->dump(), '->dump() dumps services');
|
$this->assertEqualYamlStructure(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/yaml/services9.yml')), $dumper->dump(), '->dump() dumps services');
|
||||||
|
|
||||||
$dumper = new YamlDumper($container = new ContainerBuilder());
|
$dumper = new YamlDumper($container = new ContainerBuilder());
|
||||||
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
|
$container->register('foo', 'FooClass')->addArgument(new \stdClass())->setPublic(true);
|
||||||
try {
|
try {
|
||||||
$dumper->dump();
|
$dumper->dump();
|
||||||
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||||
@ -85,6 +85,7 @@ class YamlDumperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('foo', 'Class1')
|
$container->register('foo', 'Class1')
|
||||||
|
->setPublic(true)
|
||||||
->addArgument((new Definition('Class2'))
|
->addArgument((new Definition('Class2'))
|
||||||
->addArgument(new Definition('Class2'))
|
->addArgument(new Definition('Class2'))
|
||||||
)
|
)
|
||||||
|
@ -9,6 +9,7 @@ $container = new ContainerBuilder();
|
|||||||
$container->
|
$container->
|
||||||
register('foo', 'FooClass')->
|
register('foo', 'FooClass')->
|
||||||
addArgument(new Reference('bar'))
|
addArgument(new Reference('bar'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -7,6 +7,7 @@ $container = new ContainerBuilder();
|
|||||||
$container->
|
$container->
|
||||||
register('foo', 'FooClass')->
|
register('foo', 'FooClass')->
|
||||||
addArgument(new Definition('BarClass', array(new Definition('BazClass'))))
|
addArgument(new Definition('BarClass', array(new Definition('BazClass'))))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -7,6 +7,7 @@ $container->
|
|||||||
register('foo', 'FooClass\\Foo')->
|
register('foo', 'FooClass\\Foo')->
|
||||||
addArgument('foo<>&bar')->
|
addArgument('foo<>&bar')->
|
||||||
addTag('foo"bar\\bar', array('foo' => 'foo"barřž€'))
|
addTag('foo"bar\\bar', array('foo' => 'foo"barřž€'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -7,9 +7,11 @@ $container = new ContainerBuilder();
|
|||||||
$container->
|
$container->
|
||||||
register('foo', 'FooClass')->
|
register('foo', 'FooClass')->
|
||||||
addArgument(new Reference('bar'))
|
addArgument(new Reference('bar'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container->
|
$container->
|
||||||
register('bar', 'BarClass')
|
register('bar', 'BarClass')
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ $container = new ContainerBuilder();
|
|||||||
$container
|
$container
|
||||||
->register('foo', 'FooClass\\Foo')
|
->register('foo', 'FooClass\\Foo')
|
||||||
->setDecoratedService('bar', 'bar.woozy')
|
->setDecoratedService('bar', 'bar.woozy')
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -6,6 +6,7 @@ $container = new ContainerBuilder();
|
|||||||
$container
|
$container
|
||||||
->register('foo', 'FooClass\\Foo')
|
->register('foo', 'FooClass\\Foo')
|
||||||
->setDecoratedService('bar')
|
->setDecoratedService('bar')
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -5,6 +5,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container
|
$container
|
||||||
->register('foo', '%foo.class%')
|
->register('foo', '%foo.class%')
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -10,6 +10,7 @@ $container = new ContainerBuilder();
|
|||||||
$container
|
$container
|
||||||
->register('service_from_anonymous_factory', 'Bar\FooClass')
|
->register('service_from_anonymous_factory', 'Bar\FooClass')
|
||||||
->setFactory(array(new Definition('Bar\FooClass'), 'getInstance'))
|
->setFactory(array(new Definition('Bar\FooClass'), 'getInstance'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
$anonymousServiceWithFactory = new Definition('Bar\FooClass');
|
$anonymousServiceWithFactory = new Definition('Bar\FooClass');
|
||||||
@ -17,6 +18,7 @@ $anonymousServiceWithFactory->setFactory('Bar\FooClass::getInstance');
|
|||||||
$container
|
$container
|
||||||
->register('service_with_method_call_and_factory', 'Bar\FooClass')
|
->register('service_with_method_call_and_factory', 'Bar\FooClass')
|
||||||
->addMethodCall('setBar', array($anonymousServiceWithFactory))
|
->addMethodCall('setBar', array($anonymousServiceWithFactory))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -15,6 +15,7 @@ $container
|
|||||||
->register('foo', 'Foo')
|
->register('foo', 'Foo')
|
||||||
->setFactory(array($fooFactory, 'createFoo'))
|
->setFactory(array($fooFactory, 'createFoo'))
|
||||||
->setConfigurator(array($bar, 'configureFoo'))
|
->setConfigurator(array($bar, 'configureFoo'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -7,6 +7,7 @@ $container = new ContainerBuilder();
|
|||||||
$container
|
$container
|
||||||
->register('foo', 'Foo')
|
->register('foo', 'Foo')
|
||||||
->setAutowired(true)
|
->setAutowired(true)
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -6,7 +6,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||||||
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
$container->register(\Foo\Foo::class);
|
$container->register(\Foo\Foo::class)->setPublic(true);
|
||||||
$container->register(\Bar\Foo::class);
|
$container->register(\Bar\Foo::class)->setPublic(true);
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -21,21 +21,25 @@ $container
|
|||||||
->addMethodCall('setBar', array(new Reference('bar')))
|
->addMethodCall('setBar', array(new Reference('bar')))
|
||||||
->addMethodCall('initialize')
|
->addMethodCall('initialize')
|
||||||
->setConfigurator('sc_configure')
|
->setConfigurator('sc_configure')
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('foo.baz', '%baz_class%')
|
->register('foo.baz', '%baz_class%')
|
||||||
->setFactory(array('%baz_class%', 'getInstance'))
|
->setFactory(array('%baz_class%', 'getInstance'))
|
||||||
->setConfigurator(array('%baz_class%', 'configureStatic1'))
|
->setConfigurator(array('%baz_class%', 'configureStatic1'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('bar', 'Bar\FooClass')
|
->register('bar', 'Bar\FooClass')
|
||||||
->setArguments(array('foo', new Reference('foo.baz'), new Parameter('foo_bar')))
|
->setArguments(array('foo', new Reference('foo.baz'), new Parameter('foo_bar')))
|
||||||
->setConfigurator(array(new Reference('foo.baz'), 'configure'))
|
->setConfigurator(array(new Reference('foo.baz'), 'configure'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('foo_bar', '%foo_class%')
|
->register('foo_bar', '%foo_class%')
|
||||||
->addArgument(new Reference('deprecated_service'))
|
->addArgument(new Reference('deprecated_service'))
|
||||||
->setShared(false)
|
->setShared(false)
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container->getParameterBag()->clear();
|
$container->getParameterBag()->clear();
|
||||||
$container->getParameterBag()->add(array(
|
$container->getParameterBag()->add(array(
|
||||||
@ -43,8 +47,8 @@ $container->getParameterBag()->add(array(
|
|||||||
'foo_class' => 'Bar\FooClass',
|
'foo_class' => 'Bar\FooClass',
|
||||||
'foo' => 'bar',
|
'foo' => 'bar',
|
||||||
));
|
));
|
||||||
$container->setAlias('alias_for_foo', 'foo');
|
$container->setAlias('alias_for_foo', 'foo')->setPublic(true);
|
||||||
$container->setAlias('alias_for_alias', 'alias_for_foo');
|
$container->setAlias('alias_for_alias', 'alias_for_foo')->setPublic(true);
|
||||||
$container
|
$container
|
||||||
->register('method_call1', 'Bar\FooClass')
|
->register('method_call1', 'Bar\FooClass')
|
||||||
->setFile(realpath(__DIR__.'/../includes/foo.php'))
|
->setFile(realpath(__DIR__.'/../includes/foo.php'))
|
||||||
@ -53,10 +57,12 @@ $container
|
|||||||
->addMethodCall('setBar', array(new Reference('foo3', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))
|
->addMethodCall('setBar', array(new Reference('foo3', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))
|
||||||
->addMethodCall('setBar', array(new Reference('foobaz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))
|
->addMethodCall('setBar', array(new Reference('foobaz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))
|
||||||
->addMethodCall('setBar', array(new Expression('service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")')))
|
->addMethodCall('setBar', array(new Expression('service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")')))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('foo_with_inline', 'Foo')
|
->register('foo_with_inline', 'Foo')
|
||||||
->addMethodCall('setBar', array(new Reference('inlined')))
|
->addMethodCall('setBar', array(new Reference('inlined')))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('inlined', 'Bar')
|
->register('inlined', 'Bar')
|
||||||
@ -67,10 +73,12 @@ $container
|
|||||||
$container
|
$container
|
||||||
->register('baz', 'Baz')
|
->register('baz', 'Baz')
|
||||||
->addMethodCall('setFoo', array(new Reference('foo_with_inline')))
|
->addMethodCall('setFoo', array(new Reference('foo_with_inline')))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('request', 'Request')
|
->register('request', 'Request')
|
||||||
->setSynthetic(true)
|
->setSynthetic(true)
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('configurator_service', 'ConfClass')
|
->register('configurator_service', 'ConfClass')
|
||||||
@ -80,6 +88,7 @@ $container
|
|||||||
$container
|
$container
|
||||||
->register('configured_service', 'stdClass')
|
->register('configured_service', 'stdClass')
|
||||||
->setConfigurator(array(new Reference('configurator_service'), 'configureStdClass'))
|
->setConfigurator(array(new Reference('configurator_service'), 'configureStdClass'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('configurator_service_simple', 'ConfClass')
|
->register('configurator_service_simple', 'ConfClass')
|
||||||
@ -89,21 +98,26 @@ $container
|
|||||||
$container
|
$container
|
||||||
->register('configured_service_simple', 'stdClass')
|
->register('configured_service_simple', 'stdClass')
|
||||||
->setConfigurator(array(new Reference('configurator_service_simple'), 'configureStdClass'))
|
->setConfigurator(array(new Reference('configurator_service_simple'), 'configureStdClass'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('decorated', 'stdClass')
|
->register('decorated', 'stdClass')
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('decorator_service', 'stdClass')
|
->register('decorator_service', 'stdClass')
|
||||||
->setDecoratedService('decorated')
|
->setDecoratedService('decorated')
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('decorator_service_with_name', 'stdClass')
|
->register('decorator_service_with_name', 'stdClass')
|
||||||
->setDecoratedService('decorated', 'decorated.pif-pouf')
|
->setDecoratedService('decorated', 'decorated.pif-pouf')
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('deprecated_service', 'stdClass')
|
->register('deprecated_service', 'stdClass')
|
||||||
->setDeprecated(true)
|
->setDeprecated(true)
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('new_factory', 'FactoryClass')
|
->register('new_factory', 'FactoryClass')
|
||||||
@ -113,15 +127,18 @@ $container
|
|||||||
$container
|
$container
|
||||||
->register('factory_service', 'Bar')
|
->register('factory_service', 'Bar')
|
||||||
->setFactory(array(new Reference('foo.baz'), 'getInstance'))
|
->setFactory(array(new Reference('foo.baz'), 'getInstance'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('new_factory_service', 'FooBarBaz')
|
->register('new_factory_service', 'FooBarBaz')
|
||||||
->setProperty('foo', 'bar')
|
->setProperty('foo', 'bar')
|
||||||
->setFactory(array(new Reference('new_factory'), 'getInstance'))
|
->setFactory(array(new Reference('new_factory'), 'getInstance'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('service_from_static_method', 'Bar\FooClass')
|
->register('service_from_static_method', 'Bar\FooClass')
|
||||||
->setFactory(array('Bar\FooClass', 'getInstance'))
|
->setFactory(array('Bar\FooClass', 'getInstance'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('factory_simple', 'SimpleFactoryClass')
|
->register('factory_simple', 'SimpleFactoryClass')
|
||||||
@ -132,14 +149,17 @@ $container
|
|||||||
$container
|
$container
|
||||||
->register('factory_service_simple', 'Bar')
|
->register('factory_service_simple', 'Bar')
|
||||||
->setFactory(array(new Reference('factory_simple'), 'getInstance'))
|
->setFactory(array(new Reference('factory_simple'), 'getInstance'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('lazy_context', 'LazyContext')
|
->register('lazy_context', 'LazyContext')
|
||||||
->setArguments(array(new IteratorArgument(array('k1' => new Reference('foo.baz'), 'k2' => new Reference('service_container'))), new IteratorArgument(array())))
|
->setArguments(array(new IteratorArgument(array('k1' => new Reference('foo.baz'), 'k2' => new Reference('service_container'))), new IteratorArgument(array())))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
$container
|
$container
|
||||||
->register('lazy_context_ignore_invalid_ref', 'LazyContext')
|
->register('lazy_context_ignore_invalid_ref', 'LazyContext')
|
||||||
->setArguments(array(new IteratorArgument(array(new Reference('foo.baz'), new Reference('invalid', ContainerInterface::IGNORE_ON_INVALID_REFERENCE))), new IteratorArgument(array())))
|
->setArguments(array(new IteratorArgument(array(new Reference('foo.baz'), new Reference('invalid', ContainerInterface::IGNORE_ON_INVALID_REFERENCE))), new IteratorArgument(array())))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -7,6 +7,7 @@ $container = new ContainerBuilder();
|
|||||||
$container
|
$container
|
||||||
->register('foo', 'Foo')
|
->register('foo', 'Foo')
|
||||||
->setAbstract(true)
|
->setAbstract(true)
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -9,6 +9,7 @@ $container = new ContainerBuilder();
|
|||||||
|
|
||||||
$container
|
$container
|
||||||
->register('foo1', 'stdClass')
|
->register('foo1', 'stdClass')
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
$container
|
$container
|
||||||
@ -24,6 +25,7 @@ $container
|
|||||||
$container
|
$container
|
||||||
->register('baz', 'stdClass')
|
->register('baz', 'stdClass')
|
||||||
->setProperty('foo3', new Reference('foo3'))
|
->setProperty('foo3', new Reference('foo3'))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
$container
|
$container
|
||||||
@ -41,6 +43,7 @@ $container
|
|||||||
'foo2' => new Reference('foo2', $container::IGNORE_ON_UNINITIALIZED_REFERENCE),
|
'foo2' => new Reference('foo2', $container::IGNORE_ON_UNINITIALIZED_REFERENCE),
|
||||||
'foo3' => new Reference('foo3', $container::IGNORE_ON_UNINITIALIZED_REFERENCE),
|
'foo3' => new Reference('foo3', $container::IGNORE_ON_UNINITIALIZED_REFERENCE),
|
||||||
)))
|
)))
|
||||||
|
->setPublic(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -29,6 +29,9 @@ class Container extends AbstractContainer
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ class ProjectServiceContainer extends Container
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,9 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'test' => 'getTestService',
|
'test' => 'getTestService',
|
||||||
);
|
);
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,9 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'test' => 'getTestService',
|
'test' => 'getTestService',
|
||||||
);
|
);
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'bar' => 'getBarService',
|
'bar' => 'getBarService',
|
||||||
);
|
);
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@ class ProjectServiceContainer extends Container
|
|||||||
'service_from_anonymous_factory' => 'getServiceFromAnonymousFactoryService',
|
'service_from_anonymous_factory' => 'getServiceFromAnonymousFactoryService',
|
||||||
'service_with_method_call_and_factory' => 'getServiceWithMethodCallAndFactoryService',
|
'service_with_method_call_and_factory' => 'getServiceWithMethodCallAndFactoryService',
|
||||||
);
|
);
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'foo' => 'getFooService',
|
'foo' => 'getFooService',
|
||||||
);
|
);
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,9 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container
|
|||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'test' => 'getTestService',
|
'test' => 'getTestService',
|
||||||
);
|
);
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,9 @@ class ProjectServiceContainer extends Container
|
|||||||
'Bar\\Foo' => 'getFooService',
|
'Bar\\Foo' => 'getFooService',
|
||||||
'Foo\\Foo' => 'getFoo2Service',
|
'Foo\\Foo' => 'getFoo2Service',
|
||||||
);
|
);
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,9 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->parameters = $this->getDefaultParameters();
|
$this->parameters = $this->getDefaultParameters();
|
||||||
|
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -295,6 +295,7 @@ class Container%s extends Container
|
|||||||
);
|
);
|
||||||
$this->privates = array(
|
$this->privates = array(
|
||||||
'factory_simple' => true,
|
'factory_simple' => true,
|
||||||
|
'service_container' => true,
|
||||||
);
|
);
|
||||||
$this->aliases = array(
|
$this->aliases = array(
|
||||||
'alias_for_alias' => 'foo',
|
'alias_for_alias' => 'foo',
|
||||||
|
@ -52,6 +52,7 @@ class ProjectServiceContainer extends Container
|
|||||||
);
|
);
|
||||||
$this->privates = array(
|
$this->privates = array(
|
||||||
'factory_simple' => true,
|
'factory_simple' => true,
|
||||||
|
'service_container' => true,
|
||||||
);
|
);
|
||||||
$this->aliases = array(
|
$this->aliases = array(
|
||||||
'alias_for_alias' => 'foo',
|
'alias_for_alias' => 'foo',
|
||||||
|
@ -36,6 +36,9 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'bar' => 'getBarService',
|
'bar' => 'getBarService',
|
||||||
);
|
);
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,9 @@ class Symfony_DI_PhpDumper_Test_Base64Parameters extends Container
|
|||||||
$this->parameters = $this->getDefaultParameters();
|
$this->parameters = $this->getDefaultParameters();
|
||||||
|
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ class Symfony_DI_PhpDumper_Test_Legacy_Privates extends Container
|
|||||||
'private_alias_decorator' => 'getPrivateAliasDecoratorService',
|
'private_alias_decorator' => 'getPrivateAliasDecoratorService',
|
||||||
'private_child' => 'getPrivateChildService',
|
'private_child' => 'getPrivateChildService',
|
||||||
'private_decorator' => 'getPrivateDecoratorService',
|
'private_decorator' => 'getPrivateDecoratorService',
|
||||||
'private_decorator.inner' => 'getPrivateDecorator_InnerService',
|
|
||||||
'private_not_inlined' => 'getPrivateNotInlinedService',
|
'private_not_inlined' => 'getPrivateNotInlinedService',
|
||||||
'private_not_removed' => 'getPrivateNotRemovedService',
|
'private_not_removed' => 'getPrivateNotRemovedService',
|
||||||
'private_parent' => 'getPrivateParentService',
|
'private_parent' => 'getPrivateParentService',
|
||||||
@ -50,10 +49,10 @@ class Symfony_DI_PhpDumper_Test_Legacy_Privates extends Container
|
|||||||
'private' => true,
|
'private' => true,
|
||||||
'private_alias' => true,
|
'private_alias' => true,
|
||||||
'private_child' => true,
|
'private_child' => true,
|
||||||
'private_decorator.inner' => true,
|
|
||||||
'private_not_inlined' => true,
|
'private_not_inlined' => true,
|
||||||
'private_not_removed' => true,
|
'private_not_removed' => true,
|
||||||
'private_parent' => true,
|
'private_parent' => true,
|
||||||
|
'service_container' => true,
|
||||||
);
|
);
|
||||||
$this->aliases = array(
|
$this->aliases = array(
|
||||||
'alias_to_private' => 'private',
|
'alias_to_private' => 'private',
|
||||||
@ -158,16 +157,6 @@ class Symfony_DI_PhpDumper_Test_Legacy_Privates extends Container
|
|||||||
return $this->services['private_child'] = new \stdClass();
|
return $this->services['private_child'] = new \stdClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the private 'private_decorator.inner' shared service.
|
|
||||||
*
|
|
||||||
* @return \stdClass
|
|
||||||
*/
|
|
||||||
protected function getPrivateDecorator_InnerService()
|
|
||||||
{
|
|
||||||
return $this->services['private_decorator.inner'] = new \stdClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the private 'private_not_inlined' shared service.
|
* Gets the private 'private_not_inlined' shared service.
|
||||||
*
|
*
|
||||||
|
@ -40,6 +40,7 @@ class ProjectServiceContainer extends Container
|
|||||||
);
|
);
|
||||||
$this->privates = array(
|
$this->privates = array(
|
||||||
'baz_service' => true,
|
'baz_service' => true,
|
||||||
|
'service_container' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
|
@ -34,6 +34,7 @@ class ProjectServiceContainer extends Container
|
|||||||
);
|
);
|
||||||
$this->privates = array(
|
$this->privates = array(
|
||||||
'baz_service' => true,
|
'baz_service' => true,
|
||||||
|
'service_container' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
|
@ -33,6 +33,7 @@ class ProjectServiceContainer extends Container
|
|||||||
);
|
);
|
||||||
$this->privates = array(
|
$this->privates = array(
|
||||||
'private_foo' => true,
|
'private_foo' => true,
|
||||||
|
'service_container' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
|
@ -36,6 +36,9 @@ class Symfony_DI_PhpDumper_Test_Rot13Parameters extends Container
|
|||||||
'Symfony\\Component\\DependencyInjection\\Tests\\Dumper\\Rot13EnvVarProcessor' => 'getRot13EnvVarProcessorService',
|
'Symfony\\Component\\DependencyInjection\\Tests\\Dumper\\Rot13EnvVarProcessor' => 'getRot13EnvVarProcessorService',
|
||||||
'container.env_var_processors_locator' => 'getContainer_EnvVarProcessorsLocatorService',
|
'container.env_var_processors_locator' => 'getContainer_EnvVarProcessorsLocatorService',
|
||||||
);
|
);
|
||||||
|
$this->privates = array(
|
||||||
|
'service_container' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ class ProjectServiceContainer extends Container
|
|||||||
);
|
);
|
||||||
$this->privates = array(
|
$this->privates = array(
|
||||||
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => true,
|
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => true,
|
||||||
|
'service_container' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
|
@ -35,6 +35,7 @@ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container
|
|||||||
);
|
);
|
||||||
$this->privates = array(
|
$this->privates = array(
|
||||||
'foo3' => true,
|
'foo3' => true,
|
||||||
|
'service_container' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
<services>
|
<services>
|
||||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||||
<service id="foo" class="Foo">
|
<service id="foo" class="Foo" public="true">
|
||||||
<factory method="createFoo">
|
<factory method="createFoo">
|
||||||
<service class="FooFactory">
|
<service class="FooFactory">
|
||||||
<factory method="createFooFactory">
|
<factory method="createFooFactory">
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
<services>
|
<services>
|
||||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||||
<service id="foo" class="Foo" autowire="true"/>
|
<service id="foo" class="Foo" public="true" autowire="true"/>
|
||||||
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
|
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
|
||||||
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
|
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
|
||||||
</services>
|
</services>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
</parameters>
|
</parameters>
|
||||||
<services>
|
<services>
|
||||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||||
<service id="foo" class="Bar\FooClass">
|
<service id="foo" class="Bar\FooClass" public="true">
|
||||||
<tag name="foo" foo="foo"/>
|
<tag name="foo" foo="foo"/>
|
||||||
<tag name="foo" bar="bar" baz="baz"/>
|
<tag name="foo" bar="bar" baz="baz"/>
|
||||||
<argument>foo</argument>
|
<argument>foo</argument>
|
||||||
@ -31,20 +31,20 @@
|
|||||||
<factory class="Bar\FooClass" method="getInstance"/>
|
<factory class="Bar\FooClass" method="getInstance"/>
|
||||||
<configurator function="sc_configure"/>
|
<configurator function="sc_configure"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="foo.baz" class="%baz_class%">
|
<service id="foo.baz" class="%baz_class%" public="true">
|
||||||
<factory class="%baz_class%" method="getInstance"/>
|
<factory class="%baz_class%" method="getInstance"/>
|
||||||
<configurator class="%baz_class%" method="configureStatic1"/>
|
<configurator class="%baz_class%" method="configureStatic1"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="bar" class="Bar\FooClass">
|
<service id="bar" class="Bar\FooClass" public="true">
|
||||||
<argument>foo</argument>
|
<argument>foo</argument>
|
||||||
<argument type="service" id="foo.baz"/>
|
<argument type="service" id="foo.baz"/>
|
||||||
<argument>%foo_bar%</argument>
|
<argument>%foo_bar%</argument>
|
||||||
<configurator service="foo.baz" method="configure"/>
|
<configurator service="foo.baz" method="configure"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="foo_bar" class="%foo_class%" shared="false">
|
<service id="foo_bar" class="%foo_class%" shared="false" public="true">
|
||||||
<argument type="service" id="deprecated_service"/>
|
<argument type="service" id="deprecated_service"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="method_call1" class="Bar\FooClass">
|
<service id="method_call1" class="Bar\FooClass" public="true">
|
||||||
<file>%path%foo.php</file>
|
<file>%path%foo.php</file>
|
||||||
<call method="setBar">
|
<call method="setBar">
|
||||||
<argument type="service" id="foo"/>
|
<argument type="service" id="foo"/>
|
||||||
@ -62,7 +62,7 @@
|
|||||||
<argument type="expression">service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")</argument>
|
<argument type="expression">service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")</argument>
|
||||||
</call>
|
</call>
|
||||||
</service>
|
</service>
|
||||||
<service id="foo_with_inline" class="Foo">
|
<service id="foo_with_inline" class="Foo" public="true">
|
||||||
<call method="setBar">
|
<call method="setBar">
|
||||||
<argument type="service" id="inlined"/>
|
<argument type="service" id="inlined"/>
|
||||||
</call>
|
</call>
|
||||||
@ -73,60 +73,60 @@
|
|||||||
<argument type="service" id="baz"/>
|
<argument type="service" id="baz"/>
|
||||||
</call>
|
</call>
|
||||||
</service>
|
</service>
|
||||||
<service id="baz" class="Baz">
|
<service id="baz" class="Baz" public="true">
|
||||||
<call method="setFoo">
|
<call method="setFoo">
|
||||||
<argument type="service" id="foo_with_inline"/>
|
<argument type="service" id="foo_with_inline"/>
|
||||||
</call>
|
</call>
|
||||||
</service>
|
</service>
|
||||||
<service id="request" class="Request" synthetic="true"/>
|
<service id="request" class="Request" public="true" synthetic="true"/>
|
||||||
<service id="configurator_service" class="ConfClass" public="false">
|
<service id="configurator_service" class="ConfClass" public="false">
|
||||||
<call method="setFoo">
|
<call method="setFoo">
|
||||||
<argument type="service" id="baz"/>
|
<argument type="service" id="baz"/>
|
||||||
</call>
|
</call>
|
||||||
</service>
|
</service>
|
||||||
<service id="configured_service" class="stdClass">
|
<service id="configured_service" class="stdClass" public="true">
|
||||||
<configurator service="configurator_service" method="configureStdClass"/>
|
<configurator service="configurator_service" method="configureStdClass"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="configurator_service_simple" class="ConfClass" public="false">
|
<service id="configurator_service_simple" class="ConfClass" public="false">
|
||||||
<argument>bar</argument>
|
<argument>bar</argument>
|
||||||
</service>
|
</service>
|
||||||
<service id="configured_service_simple" class="stdClass">
|
<service id="configured_service_simple" class="stdClass" public="true">
|
||||||
<configurator service="configurator_service_simple" method="configureStdClass"/>
|
<configurator service="configurator_service_simple" method="configureStdClass"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="decorated" class="stdClass"/>
|
<service id="decorated" class="stdClass" public="true"/>
|
||||||
<service id="decorator_service" class="stdClass" decorates="decorated"/>
|
<service id="decorator_service" class="stdClass" public="true" decorates="decorated"/>
|
||||||
<service id="decorator_service_with_name" class="stdClass" decorates="decorated" decoration-inner-name="decorated.pif-pouf"/>
|
<service id="decorator_service_with_name" class="stdClass" public="true" decorates="decorated" decoration-inner-name="decorated.pif-pouf"/>
|
||||||
<service id="deprecated_service" class="stdClass">
|
<service id="deprecated_service" class="stdClass" public="true">
|
||||||
<deprecated>The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.</deprecated>
|
<deprecated>The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.</deprecated>
|
||||||
</service>
|
</service>
|
||||||
<service id="new_factory" class="FactoryClass" public="false">
|
<service id="new_factory" class="FactoryClass" public="false">
|
||||||
<property name="foo">bar</property>
|
<property name="foo">bar</property>
|
||||||
</service>
|
</service>
|
||||||
<service id="factory_service" class="Bar">
|
<service id="factory_service" class="Bar" public="true">
|
||||||
<factory service="foo.baz" method="getInstance"/>
|
<factory service="foo.baz" method="getInstance"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="new_factory_service" class="FooBarBaz">
|
<service id="new_factory_service" class="FooBarBaz" public="true">
|
||||||
<property name="foo">bar</property>
|
<property name="foo">bar</property>
|
||||||
<factory service="new_factory" method="getInstance"/>
|
<factory service="new_factory" method="getInstance"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="service_from_static_method" class="Bar\FooClass">
|
<service id="service_from_static_method" class="Bar\FooClass" public="true">
|
||||||
<factory class="Bar\FooClass" method="getInstance"/>
|
<factory class="Bar\FooClass" method="getInstance"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="factory_simple" class="SimpleFactoryClass" public="false">
|
<service id="factory_simple" class="SimpleFactoryClass" public="false">
|
||||||
<argument>foo</argument>
|
<argument>foo</argument>
|
||||||
<deprecated>The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.</deprecated>
|
<deprecated>The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.</deprecated>
|
||||||
</service>
|
</service>
|
||||||
<service id="factory_service_simple" class="Bar">
|
<service id="factory_service_simple" class="Bar" public="true">
|
||||||
<factory service="factory_simple" method="getInstance"/>
|
<factory service="factory_simple" method="getInstance"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="lazy_context" class="LazyContext">
|
<service id="lazy_context" class="LazyContext" public="true">
|
||||||
<argument type="iterator">
|
<argument type="iterator">
|
||||||
<argument key="k1" type="service" id="foo.baz"/>
|
<argument key="k1" type="service" id="foo.baz"/>
|
||||||
<argument key="k2" type="service" id="service_container"/>
|
<argument key="k2" type="service" id="service_container"/>
|
||||||
</argument>
|
</argument>
|
||||||
<argument type="iterator"/>
|
<argument type="iterator"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="lazy_context_ignore_invalid_ref" class="LazyContext">
|
<service id="lazy_context_ignore_invalid_ref" class="LazyContext" public="true">
|
||||||
<argument type="iterator">
|
<argument type="iterator">
|
||||||
<argument type="service" id="foo.baz"/>
|
<argument type="service" id="foo.baz"/>
|
||||||
<argument type="service" id="invalid" on-invalid="ignore"/>
|
<argument type="service" id="invalid" on-invalid="ignore"/>
|
||||||
@ -135,7 +135,7 @@
|
|||||||
</service>
|
</service>
|
||||||
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
|
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
|
||||||
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
|
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
|
||||||
<service id="alias_for_foo" alias="foo"/>
|
<service id="alias_for_foo" alias="foo" public="true"/>
|
||||||
<service id="alias_for_alias" alias="foo"/>
|
<service id="alias_for_alias" alias="foo" public="true"/>
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
<services>
|
<services>
|
||||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||||
<service id="foo" class="Foo" abstract="true"/>
|
<service id="foo" class="Foo" public="true" abstract="true"/>
|
||||||
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
|
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
|
||||||
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
|
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
|
||||||
</services>
|
</services>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
<services>
|
<services>
|
||||||
|
<defaults public="true" />
|
||||||
<service class="FooClass"/>
|
<service class="FooClass"/>
|
||||||
<service id="FooClass">
|
<service id="FooClass">
|
||||||
<argument type="service">
|
<argument type="service">
|
||||||
|
@ -5,6 +5,7 @@ services:
|
|||||||
synthetic: true
|
synthetic: true
|
||||||
foo:
|
foo:
|
||||||
class: Foo
|
class: Foo
|
||||||
|
public: true
|
||||||
autowire: true
|
autowire: true
|
||||||
Psr\Container\ContainerInterface:
|
Psr\Container\ContainerInterface:
|
||||||
alias: service_container
|
alias: service_container
|
||||||
|
@ -9,6 +9,7 @@ parameters:
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
test:
|
test:
|
||||||
|
public: true
|
||||||
class: '%env(FOO)%'
|
class: '%env(FOO)%'
|
||||||
arguments:
|
arguments:
|
||||||
- '%env(Bar)%'
|
- '%env(Bar)%'
|
||||||
|
@ -20,18 +20,22 @@ services:
|
|||||||
|
|
||||||
factory: [Bar\FooClass, getInstance]
|
factory: [Bar\FooClass, getInstance]
|
||||||
configurator: sc_configure
|
configurator: sc_configure
|
||||||
|
public: true
|
||||||
foo.baz:
|
foo.baz:
|
||||||
class: '%baz_class%'
|
class: '%baz_class%'
|
||||||
factory: ['%baz_class%', getInstance]
|
factory: ['%baz_class%', getInstance]
|
||||||
configurator: ['%baz_class%', configureStatic1]
|
configurator: ['%baz_class%', configureStatic1]
|
||||||
|
public: true
|
||||||
bar:
|
bar:
|
||||||
class: Bar\FooClass
|
class: Bar\FooClass
|
||||||
arguments: [foo, '@foo.baz', '%foo_bar%']
|
arguments: [foo, '@foo.baz', '%foo_bar%']
|
||||||
configurator: ['@foo.baz', configure]
|
configurator: ['@foo.baz', configure]
|
||||||
|
public: true
|
||||||
foo_bar:
|
foo_bar:
|
||||||
class: '%foo_class%'
|
class: '%foo_class%'
|
||||||
shared: false
|
shared: false
|
||||||
arguments: ['@deprecated_service']
|
arguments: ['@deprecated_service']
|
||||||
|
public: true
|
||||||
method_call1:
|
method_call1:
|
||||||
class: Bar\FooClass
|
class: Bar\FooClass
|
||||||
file: '%path%foo.php'
|
file: '%path%foo.php'
|
||||||
@ -41,11 +45,13 @@ services:
|
|||||||
- [setBar, ['@?foo3']]
|
- [setBar, ['@?foo3']]
|
||||||
- [setBar, ['@?foobaz']]
|
- [setBar, ['@?foobaz']]
|
||||||
- [setBar, ['@=service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")']]
|
- [setBar, ['@=service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")']]
|
||||||
|
public: true
|
||||||
|
|
||||||
foo_with_inline:
|
foo_with_inline:
|
||||||
class: Foo
|
class: Foo
|
||||||
calls:
|
calls:
|
||||||
- [setBar, ['@inlined']]
|
- [setBar, ['@inlined']]
|
||||||
|
public: true
|
||||||
|
|
||||||
inlined:
|
inlined:
|
||||||
class: Bar
|
class: Bar
|
||||||
@ -58,10 +64,12 @@ services:
|
|||||||
class: Baz
|
class: Baz
|
||||||
calls:
|
calls:
|
||||||
- [setFoo, ['@foo_with_inline']]
|
- [setFoo, ['@foo_with_inline']]
|
||||||
|
public: true
|
||||||
|
|
||||||
request:
|
request:
|
||||||
class: Request
|
class: Request
|
||||||
synthetic: true
|
synthetic: true
|
||||||
|
public: true
|
||||||
configurator_service:
|
configurator_service:
|
||||||
class: ConfClass
|
class: ConfClass
|
||||||
public: false
|
public: false
|
||||||
@ -71,6 +79,7 @@ services:
|
|||||||
configured_service:
|
configured_service:
|
||||||
class: stdClass
|
class: stdClass
|
||||||
configurator: ['@configurator_service', configureStdClass]
|
configurator: ['@configurator_service', configureStdClass]
|
||||||
|
public: true
|
||||||
configurator_service_simple:
|
configurator_service_simple:
|
||||||
class: ConfClass
|
class: ConfClass
|
||||||
public: false
|
public: false
|
||||||
@ -78,18 +87,23 @@ services:
|
|||||||
configured_service_simple:
|
configured_service_simple:
|
||||||
class: stdClass
|
class: stdClass
|
||||||
configurator: ['@configurator_service_simple', configureStdClass]
|
configurator: ['@configurator_service_simple', configureStdClass]
|
||||||
|
public: true
|
||||||
decorated:
|
decorated:
|
||||||
class: stdClass
|
class: stdClass
|
||||||
|
public: true
|
||||||
decorator_service:
|
decorator_service:
|
||||||
class: stdClass
|
class: stdClass
|
||||||
decorates: decorated
|
decorates: decorated
|
||||||
|
public: true
|
||||||
decorator_service_with_name:
|
decorator_service_with_name:
|
||||||
class: stdClass
|
class: stdClass
|
||||||
decorates: decorated
|
decorates: decorated
|
||||||
decoration_inner_name: decorated.pif-pouf
|
decoration_inner_name: decorated.pif-pouf
|
||||||
|
public: true
|
||||||
deprecated_service:
|
deprecated_service:
|
||||||
class: stdClass
|
class: stdClass
|
||||||
deprecated: The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.
|
deprecated: The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.
|
||||||
|
public: true
|
||||||
new_factory:
|
new_factory:
|
||||||
class: FactoryClass
|
class: FactoryClass
|
||||||
public: false
|
public: false
|
||||||
@ -97,13 +111,16 @@ services:
|
|||||||
factory_service:
|
factory_service:
|
||||||
class: Bar
|
class: Bar
|
||||||
factory: ['@foo.baz', getInstance]
|
factory: ['@foo.baz', getInstance]
|
||||||
|
public: true
|
||||||
new_factory_service:
|
new_factory_service:
|
||||||
class: FooBarBaz
|
class: FooBarBaz
|
||||||
properties: { foo: bar }
|
properties: { foo: bar }
|
||||||
factory: ['@new_factory', getInstance]
|
factory: ['@new_factory', getInstance]
|
||||||
|
public: true
|
||||||
service_from_static_method:
|
service_from_static_method:
|
||||||
class: Bar\FooClass
|
class: Bar\FooClass
|
||||||
factory: [Bar\FooClass, getInstance]
|
factory: [Bar\FooClass, getInstance]
|
||||||
|
public: true
|
||||||
factory_simple:
|
factory_simple:
|
||||||
class: SimpleFactoryClass
|
class: SimpleFactoryClass
|
||||||
deprecated: The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.
|
deprecated: The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.
|
||||||
@ -112,14 +129,21 @@ services:
|
|||||||
factory_service_simple:
|
factory_service_simple:
|
||||||
class: Bar
|
class: Bar
|
||||||
factory: ['@factory_simple', getInstance]
|
factory: ['@factory_simple', getInstance]
|
||||||
|
public: true
|
||||||
lazy_context:
|
lazy_context:
|
||||||
class: LazyContext
|
class: LazyContext
|
||||||
arguments: [!iterator {'k1': '@foo.baz', 'k2': '@service_container'}, !iterator []]
|
arguments: [!iterator {'k1': '@foo.baz', 'k2': '@service_container'}, !iterator []]
|
||||||
|
public: true
|
||||||
lazy_context_ignore_invalid_ref:
|
lazy_context_ignore_invalid_ref:
|
||||||
class: LazyContext
|
class: LazyContext
|
||||||
arguments: [!iterator ['@foo.baz', '@?invalid'], !iterator []]
|
arguments: [!iterator ['@foo.baz', '@?invalid'], !iterator []]
|
||||||
alias_for_foo: '@foo'
|
public: true
|
||||||
alias_for_alias: '@foo'
|
alias_for_foo:
|
||||||
|
alias: 'foo'
|
||||||
|
public: true
|
||||||
|
alias_for_alias:
|
||||||
|
alias: 'foo'
|
||||||
|
public: true
|
||||||
Psr\Container\ContainerInterface:
|
Psr\Container\ContainerInterface:
|
||||||
alias: service_container
|
alias: service_container
|
||||||
public: false
|
public: false
|
||||||
|
@ -5,6 +5,7 @@ services:
|
|||||||
synthetic: true
|
synthetic: true
|
||||||
foo:
|
foo:
|
||||||
class: Class1
|
class: Class1
|
||||||
|
public: true
|
||||||
arguments: [!service { class: Class2, arguments: [!service { class: Class2 }] }]
|
arguments: [!service { class: Class2, arguments: [!service { class: Class2 }] }]
|
||||||
Psr\Container\ContainerInterface:
|
Psr\Container\ContainerInterface:
|
||||||
alias: service_container
|
alias: service_container
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
services:
|
services:
|
||||||
|
_defaults: {public: true}
|
||||||
|
|
||||||
foo: {class: stdClass, public: false}
|
foo: {class: stdClass, public: false}
|
||||||
|
|
||||||
@ -23,6 +24,4 @@ services:
|
|||||||
private_not_inlined: {class: stdClass, public: false}
|
private_not_inlined: {class: stdClass, public: false}
|
||||||
private_not_removed: {class: stdClass, public: false}
|
private_not_removed: {class: stdClass, public: false}
|
||||||
|
|
||||||
private_child: {parent: foo}
|
|
||||||
private_parent: {parent: private}
|
|
||||||
public_child: {parent: private, public: true}
|
public_child: {parent: private, public: true}
|
||||||
|
@ -234,7 +234,7 @@ class XmlFileLoaderTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
* @expectedDeprecation Top-level anonymous services are deprecated since Symfony 3.4, the "id" attribute will be required in version 4.0 in %sservices_without_id.xml at line 4.
|
* @expectedDeprecation Top-level anonymous services are deprecated since Symfony 3.4, the "id" attribute will be required in version 4.0 in %sservices_without_id.xml at line 5.
|
||||||
*/
|
*/
|
||||||
public function testLoadAnonymousServicesWithoutId()
|
public function testLoadAnonymousServicesWithoutId()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user