[DI] Fix private-by-default BC layer
This commit is contained in:
parent
ad4bc6b647
commit
ff2ab5831a
@ -31,7 +31,7 @@ class ContainerBuilderTest extends TestCase
|
||||
|
||||
$builder->setProxyInstantiator(new RuntimeInstantiator());
|
||||
|
||||
$builder->register('foo1', 'ProxyManagerBridgeFooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php');
|
||||
$builder->register('foo1', 'ProxyManagerBridgeFooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php')->setPublic(true);
|
||||
$builder->getDefinition('foo1')->setLazy(true);
|
||||
|
||||
$builder->compile();
|
||||
|
@ -953,6 +953,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->loadFromFile($container, 'default_config');
|
||||
$container
|
||||
->register('foo', \stdClass::class)
|
||||
->setPublic(true)
|
||||
->setProperty('dispatcher', new Reference('event_dispatcher'));
|
||||
$container->compile();
|
||||
$this->assertInstanceOf(EventDispatcherInterface::class, $container->get('foo')->dispatcher);
|
||||
|
@ -52,11 +52,11 @@ class WebProfilerExtensionTest extends TestCase
|
||||
$this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock();
|
||||
|
||||
$this->container = new ContainerBuilder();
|
||||
$this->container->register('event_dispatcher', EventDispatcher::class);
|
||||
$this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface'));
|
||||
$this->container->register('twig', 'Twig\Environment');
|
||||
$this->container->register('twig_loader', 'Twig\Loader\ArrayLoader')->addArgument(array());
|
||||
$this->container->register('twig', 'Twig\Environment')->addArgument(new Reference('twig_loader'));
|
||||
$this->container->register('event_dispatcher', EventDispatcher::class)->setPublic(true);
|
||||
$this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface'))->setPublic(true);
|
||||
$this->container->register('twig', 'Twig\Environment')->setPublic(true);
|
||||
$this->container->register('twig_loader', 'Twig\Loader\ArrayLoader')->addArgument(array())->setPublic(true);
|
||||
$this->container->register('twig', 'Twig\Environment')->addArgument(new Reference('twig_loader'))->setPublic(true);
|
||||
$this->container->setParameter('kernel.bundles', array());
|
||||
$this->container->setParameter('kernel.cache_dir', __DIR__);
|
||||
$this->container->setParameter('kernel.debug', false);
|
||||
@ -65,6 +65,7 @@ class WebProfilerExtensionTest extends TestCase
|
||||
$this->container->setParameter('debug.file_link_format', null);
|
||||
$this->container->setParameter('profiler.class', array('Symfony\\Component\\HttpKernel\\Profiler\\Profiler'));
|
||||
$this->container->register('profiler', $this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\Profiler'))
|
||||
->setPublic(true)
|
||||
->addArgument(new Definition($this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface')));
|
||||
$this->container->setParameter('data_collector.templates', array());
|
||||
$this->container->set('kernel', $this->kernel);
|
||||
@ -123,6 +124,9 @@ class WebProfilerExtensionTest extends TestCase
|
||||
|
||||
private function getCompiledContainer()
|
||||
{
|
||||
if ($this->container->has('web_profiler.debug_toolbar')) {
|
||||
$this->container->getDefinition('web_profiler.debug_toolbar')->setPublic(true);
|
||||
}
|
||||
$this->container->compile();
|
||||
$this->container->set('kernel', $this->kernel);
|
||||
|
||||
|
@ -30,6 +30,7 @@ class ChildDefinition extends Definition
|
||||
public function __construct($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
$this->setPrivate(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,8 +68,8 @@ class RemoveUnusedDefinitionsPass implements RepeatablePassInterface
|
||||
|
||||
if (1 === count($referencingAliases) && false === $isReferenced) {
|
||||
$container->setDefinition((string) reset($referencingAliases), $definition);
|
||||
$definition->setPrivate(reset($referencingAliases)->isPrivate());
|
||||
$definition->setPublic(!$definition->isPrivate());
|
||||
$definition->setPrivate(reset($referencingAliases)->isPrivate());
|
||||
$container->removeDefinition($id);
|
||||
$container->log($this, sprintf('Removed service "%s"; reason: replaces alias %s.', $id, reset($referencingAliases)));
|
||||
} elseif (0 === count($referencingAliases) && false === $isReferenced) {
|
||||
|
@ -126,7 +126,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
parent::__construct($parameterBag);
|
||||
|
||||
$this->trackResources = interface_exists('Symfony\Component\Config\Resource\ResourceInterface');
|
||||
$this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(true));
|
||||
$this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(true)->setPublic(true));
|
||||
$this->setAlias(PsrContainerInterface::class, new Alias('service_container', false));
|
||||
$this->setAlias(ContainerInterface::class, new Alias('service_container', false));
|
||||
}
|
||||
@ -562,6 +562,22 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
* @see Reference
|
||||
*/
|
||||
public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
|
||||
{
|
||||
if ($this->isCompiled()) {
|
||||
$id = $this->normalizeId($id);
|
||||
|
||||
if (isset($this->definitions[$id]) && $this->definitions[$id]->isPrivate()) {
|
||||
@trigger_error(sprintf('Fetching the "%s" private service is deprecated and will fail in Symfony 4.0. Make the service public instead.', $id), E_USER_DEPRECATED);
|
||||
}
|
||||
if (isset($this->aliasDefinitions[$id]) && $this->aliasDefinitions[$id]->isPrivate()) {
|
||||
@trigger_error(sprintf('Fetching the "%s" private alias is deprecated and will fail in Symfony 4.0. Make the alias public instead.', $id), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->doGet($id, $invalidBehavior);
|
||||
}
|
||||
|
||||
private function doGet($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
|
||||
{
|
||||
$id = $this->normalizeId($id);
|
||||
|
||||
@ -573,7 +589,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
}
|
||||
|
||||
if (!isset($this->definitions[$id]) && isset($this->aliasDefinitions[$id])) {
|
||||
return $this->get((string) $this->aliasDefinitions[$id], $invalidBehavior);
|
||||
return $this->doGet((string) $this->aliasDefinitions[$id], $invalidBehavior);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -1122,7 +1138,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
$callable[0] = $parameterBag->resolveValue($callable[0]);
|
||||
|
||||
if ($callable[0] instanceof Reference) {
|
||||
$callable[0] = $this->get((string) $callable[0], $callable[0]->getInvalidBehavior());
|
||||
$callable[0] = $this->doGet((string) $callable[0], $callable[0]->getInvalidBehavior());
|
||||
} elseif ($callable[0] instanceof Definition) {
|
||||
$callable[0] = $this->createService($callable[0], null);
|
||||
}
|
||||
@ -1166,7 +1182,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
}
|
||||
}
|
||||
foreach (self::getInitializedConditionals($v) as $s) {
|
||||
if (!$this->get($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) {
|
||||
if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
@ -1182,7 +1198,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
}
|
||||
}
|
||||
foreach (self::getInitializedConditionals($v) as $s) {
|
||||
if (!$this->get($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) {
|
||||
if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
@ -1193,7 +1209,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
return $count;
|
||||
});
|
||||
} elseif ($value instanceof Reference) {
|
||||
$value = $this->get((string) $value, $value->getInvalidBehavior());
|
||||
$value = $this->doGet((string) $value, $value->getInvalidBehavior());
|
||||
} elseif ($value instanceof Definition) {
|
||||
$value = $this->createService($value, null);
|
||||
} elseif ($value instanceof Expression) {
|
||||
@ -1518,7 +1534,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
}
|
||||
}
|
||||
foreach (self::getInitializedConditionals($call[1]) as $s) {
|
||||
if (!$this->get($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) {
|
||||
if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -255,11 +255,7 @@ class XmlFileLoader extends FileLoader
|
||||
$definition->setChanges(array());
|
||||
}
|
||||
|
||||
if ($publicAttr = $service->getAttribute('public')) {
|
||||
$definition->setPublic(XmlUtils::phpize($publicAttr));
|
||||
}
|
||||
|
||||
foreach (array('class', 'shared', 'synthetic', 'lazy', 'abstract') as $key) {
|
||||
foreach (array('class', 'public', 'shared', 'synthetic', 'lazy', 'abstract') as $key) {
|
||||
if ($value = $service->getAttribute($key)) {
|
||||
$method = 'set'.$key;
|
||||
$definition->$method(XmlUtils::phpize($value));
|
||||
|
@ -630,6 +630,7 @@ class ContainerBuilderTest extends TestCase
|
||||
$container->setParameter('env(HTTP_DUMMY_VAR)', '123');
|
||||
$container->register('teatime', 'stdClass')
|
||||
->setProperty('foo', '%env(DUMMY_ENV_VAR)%')
|
||||
->setPublic(true)
|
||||
;
|
||||
$container->compile(true);
|
||||
|
||||
@ -687,9 +688,11 @@ class ContainerBuilderTest extends TestCase
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('env(FAKE)', '123');
|
||||
|
||||
$container->register('foo', 'stdClass')->setProperties(array(
|
||||
'fake' => '%env(int:FAKE)%',
|
||||
));
|
||||
$container->register('foo', 'stdClass')
|
||||
->setPublic(true)
|
||||
->setProperties(array(
|
||||
'fake' => '%env(int:FAKE)%',
|
||||
));
|
||||
|
||||
$container->compile(true);
|
||||
|
||||
@ -701,7 +704,9 @@ class ContainerBuilderTest extends TestCase
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('env(FAKE)', null);
|
||||
|
||||
$container->register('foo', 'stdClass')->setProperties(array(
|
||||
$container->register('foo', 'stdClass')
|
||||
->setPublic(true)
|
||||
->setProperties(array(
|
||||
'fake' => '%env(int:FAKE)%',
|
||||
));
|
||||
|
||||
@ -860,7 +865,7 @@ class ContainerBuilderTest extends TestCase
|
||||
|
||||
$this->assertEmpty($container->getResources(), 'No resources get registered without resource tracking');
|
||||
|
||||
$container->register('foo', 'BarClass');
|
||||
$container->register('foo', 'BarClass')->setPublic(true);
|
||||
$container->getDefinition('foo')->setLazy(true);
|
||||
|
||||
$container->compile();
|
||||
@ -959,7 +964,7 @@ class ContainerBuilderTest extends TestCase
|
||||
|
||||
$container->addDefinitions(array(
|
||||
'bar' => $fooDefinition,
|
||||
'bar_user' => $fooUserDefinition,
|
||||
'bar_user' => $fooUserDefinition->setPublic(true),
|
||||
));
|
||||
|
||||
$container->compile();
|
||||
@ -973,7 +978,7 @@ class ContainerBuilderTest extends TestCase
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setResourceTracking(false);
|
||||
$container->setDefinition('a', new Definition('stdClass'));
|
||||
$container->register('a', 'stdClass')->setPublic(true);
|
||||
$container->compile();
|
||||
$container->set('a', new \stdClass());
|
||||
}
|
||||
@ -990,7 +995,7 @@ class ContainerBuilderTest extends TestCase
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$def = new Definition('stdClass');
|
||||
$def->setSynthetic(true);
|
||||
$def->setSynthetic(true)->setPublic(true);
|
||||
$container->setDefinition('a', $def);
|
||||
$container->compile();
|
||||
$container->set('a', $a = new \stdClass());
|
||||
@ -1031,10 +1036,10 @@ class ContainerBuilderTest extends TestCase
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$abstract = new Definition('AbstractClass');
|
||||
$abstract->setAbstract(true);
|
||||
$abstract->setAbstract(true)->setPublic(true);
|
||||
|
||||
$container->setDefinition('abstract_service', $abstract);
|
||||
$container->setAlias('abstract_alias', 'abstract_service');
|
||||
$container->setAlias('abstract_alias', 'abstract_service')->setPublic(true);
|
||||
|
||||
$container->compile();
|
||||
|
||||
@ -1048,6 +1053,7 @@ class ContainerBuilderTest extends TestCase
|
||||
$container->set('a', new \BazClass());
|
||||
$definition = new Definition('BazClass');
|
||||
$definition->setLazy(true);
|
||||
$definition->setPublic(true);
|
||||
$container->setDefinition('a', $definition);
|
||||
});
|
||||
|
||||
@ -1075,6 +1081,7 @@ class ContainerBuilderTest extends TestCase
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo', 'stdClass');
|
||||
$container->register('bar', 'MethodCallClass')
|
||||
->setPublic(true)
|
||||
->setProperty('simple', 'bar')
|
||||
->setProperty('complex', new Reference('foo'))
|
||||
->addMethodCall('callMe');
|
||||
@ -1088,9 +1095,10 @@ class ContainerBuilderTest extends TestCase
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register(A::class);
|
||||
$container->register(A::class)->setPublic(true);
|
||||
$bDefinition = $container->register('b', __NAMESPACE__.'\B');
|
||||
$bDefinition->setAutowired(true);
|
||||
$bDefinition->setPublic(true);
|
||||
|
||||
$container->compile();
|
||||
|
||||
@ -1149,12 +1157,13 @@ class ContainerBuilderTest extends TestCase
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo_service', ServiceLocator::class)
|
||||
->setPublic(true)
|
||||
->addArgument(array(
|
||||
'bar' => new ServiceClosureArgument(new Reference('bar_service')),
|
||||
'baz' => new ServiceClosureArgument(new TypedReference('baz_service', 'stdClass')),
|
||||
))
|
||||
;
|
||||
$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->compile();
|
||||
|
||||
@ -1234,6 +1243,7 @@ class ContainerBuilderTest extends TestCase
|
||||
{
|
||||
$container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar')));
|
||||
$container->register('foo', 'stdClass')
|
||||
->setPublic(true)
|
||||
->setProperty('foo', '%FOO%');
|
||||
|
||||
$container->compile();
|
||||
|
@ -74,7 +74,7 @@ class XmlDumperTest extends TestCase
|
||||
$this->assertEquals('<?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">
|
||||
<services>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
|
||||
<service id="foo" class="FooClass" public="true">
|
||||
<argument type="service">
|
||||
<service class="BarClass">
|
||||
@ -98,7 +98,7 @@ class XmlDumperTest extends TestCase
|
||||
$this->assertEquals("<?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\">
|
||||
<services>
|
||||
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" synthetic=\"true\"/>
|
||||
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" public=\"true\" synthetic=\"true\"/>
|
||||
<service id=\"foo\" class=\"FooClass\Foo\" public=\"true\">
|
||||
<tag name=\"foo"bar\bar\" foo=\"foo"barřž€\"/>
|
||||
<argument>foo<>&bar</argument>
|
||||
@ -127,7 +127,7 @@ class XmlDumperTest extends TestCase
|
||||
array("<?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\">
|
||||
<services>
|
||||
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" synthetic=\"true\"/>
|
||||
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" public=\"true\" synthetic=\"true\"/>
|
||||
<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=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
||||
@ -137,7 +137,7 @@ class XmlDumperTest extends TestCase
|
||||
array("<?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\">
|
||||
<services>
|
||||
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" synthetic=\"true\"/>
|
||||
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" public=\"true\" synthetic=\"true\"/>
|
||||
<service id=\"foo\" class=\"FooClass\Foo\" public=\"true\" decorates=\"bar\"/>
|
||||
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
||||
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
|
||||
|
@ -29,9 +29,6 @@ class Container extends AbstractContainer
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -27,9 +27,6 @@ class ProjectServiceContainer extends Container
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -32,9 +32,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->methodMap = array(
|
||||
'test' => 'getTestService',
|
||||
);
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -36,9 +36,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->methodMap = array(
|
||||
'test' => 'getTestService',
|
||||
);
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -30,9 +30,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->methodMap = array(
|
||||
'bar' => 'getBarService',
|
||||
);
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -31,9 +31,6 @@ class ProjectServiceContainer extends Container
|
||||
'service_from_anonymous_factory' => 'getServiceFromAnonymousFactoryService',
|
||||
'service_with_method_call_and_factory' => 'getServiceWithMethodCallAndFactoryService',
|
||||
);
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -30,9 +30,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->methodMap = array(
|
||||
'foo' => 'getFooService',
|
||||
);
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -36,9 +36,6 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container
|
||||
$this->methodMap = array(
|
||||
'test' => 'getTestService',
|
||||
);
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -35,9 +35,6 @@ class ProjectServiceContainer extends Container
|
||||
'Bar\\Foo' => 'getFooService',
|
||||
'Foo\\Foo' => 'getFoo2Service',
|
||||
);
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -29,9 +29,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->parameters = $this->getDefaultParameters();
|
||||
|
||||
$this->services = array();
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -295,7 +295,6 @@ class Container%s extends Container
|
||||
);
|
||||
$this->privates = array(
|
||||
'factory_simple' => true,
|
||||
'service_container' => true,
|
||||
);
|
||||
$this->aliases = array(
|
||||
'alias_for_alias' => 'foo',
|
||||
|
@ -52,7 +52,6 @@ class ProjectServiceContainer extends Container
|
||||
);
|
||||
$this->privates = array(
|
||||
'factory_simple' => true,
|
||||
'service_container' => true,
|
||||
);
|
||||
$this->aliases = array(
|
||||
'alias_for_alias' => 'foo',
|
||||
|
@ -36,9 +36,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->methodMap = array(
|
||||
'bar' => 'getBarService',
|
||||
);
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -29,9 +29,6 @@ class Symfony_DI_PhpDumper_Test_Base64Parameters extends Container
|
||||
$this->parameters = $this->getDefaultParameters();
|
||||
|
||||
$this->services = array();
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ class Symfony_DI_PhpDumper_Test_Legacy_Privates extends Container
|
||||
'private_not_inlined' => true,
|
||||
'private_not_removed' => true,
|
||||
'private_parent' => true,
|
||||
'service_container' => true,
|
||||
);
|
||||
$this->aliases = array(
|
||||
'alias_to_private' => 'private',
|
||||
|
@ -40,7 +40,6 @@ class ProjectServiceContainer extends Container
|
||||
);
|
||||
$this->privates = array(
|
||||
'baz_service' => true,
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
|
@ -34,7 +34,6 @@ class ProjectServiceContainer extends Container
|
||||
);
|
||||
$this->privates = array(
|
||||
'baz_service' => true,
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
|
@ -33,7 +33,6 @@ class ProjectServiceContainer extends Container
|
||||
);
|
||||
$this->privates = array(
|
||||
'private_foo' => true,
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
|
@ -36,9 +36,6 @@ class Symfony_DI_PhpDumper_Test_Rot13Parameters extends Container
|
||||
'Symfony\\Component\\DependencyInjection\\Tests\\Dumper\\Rot13EnvVarProcessor' => 'getRot13EnvVarProcessorService',
|
||||
'container.env_var_processors_locator' => 'getContainer_EnvVarProcessorsLocatorService',
|
||||
);
|
||||
$this->privates = array(
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ class ProjectServiceContainer extends Container
|
||||
);
|
||||
$this->privates = array(
|
||||
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => true,
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
|
@ -35,7 +35,6 @@ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container
|
||||
);
|
||||
$this->privates = array(
|
||||
'foo3' => true,
|
||||
'service_container' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
<services>
|
||||
<service class="Symfony\Component\DependencyInjection\ContainerInterface" id="service_container" synthetic="true"/>
|
||||
<service class="Symfony\Component\DependencyInjection\ContainerInterface" id="service_container" public="true" synthetic="true"/>
|
||||
<service alias="service_container" id="Psr\Container\ContainerInterface" public="false"/>
|
||||
<service alias="service_container" id="Symfony\Component\DependencyInjection\ContainerInterface" public="false"/>
|
||||
</services>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
<services>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
|
||||
<service id="foo" class="Foo" public="true">
|
||||
<factory method="createFoo">
|
||||
<service class="FooFactory">
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
<services>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
|
||||
<service id="foo" class="Foo" public="true" autowire="true"/>
|
||||
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
|
||||
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
|
||||
|
@ -20,7 +20,7 @@
|
||||
</parameter>
|
||||
</parameters>
|
||||
<services>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
|
||||
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
|
||||
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
|
||||
</services>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parameter key="foo">bar</parameter>
|
||||
</parameters>
|
||||
<services>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
|
||||
<service id="foo" class="Bar\FooClass" public="true">
|
||||
<tag name="foo" foo="foo"/>
|
||||
<tag name="foo" bar="bar" baz="baz"/>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
<services>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
|
||||
<service id="foo" class="Foo" public="true" abstract="true"/>
|
||||
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
|
||||
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
<services>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
|
||||
<service id="foo" autoconfigure="true" abstract="true">
|
||||
<argument type="service" id="bar" on-invalid="ignore_uninitialized"/>
|
||||
</service>
|
||||
|
@ -1,6 +1,7 @@
|
||||
services:
|
||||
service_container:
|
||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||
public: true
|
||||
synthetic: true
|
||||
Psr\Container\ContainerInterface:
|
||||
alias: service_container
|
||||
|
@ -2,6 +2,7 @@
|
||||
services:
|
||||
service_container:
|
||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||
public: true
|
||||
synthetic: true
|
||||
foo:
|
||||
class: Foo
|
||||
|
@ -8,6 +8,7 @@ parameters:
|
||||
services:
|
||||
service_container:
|
||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||
public: true
|
||||
synthetic: true
|
||||
Psr\Container\ContainerInterface:
|
||||
alias: service_container
|
||||
|
@ -6,6 +6,7 @@ parameters:
|
||||
services:
|
||||
service_container:
|
||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||
public: true
|
||||
synthetic: true
|
||||
foo:
|
||||
class: Bar\FooClass
|
||||
|
@ -2,6 +2,7 @@
|
||||
services:
|
||||
service_container:
|
||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||
public: true
|
||||
synthetic: true
|
||||
foo:
|
||||
class: Class1
|
||||
|
@ -51,8 +51,8 @@ class FormPassTest extends TestCase
|
||||
$container = $this->createContainerBuilder();
|
||||
|
||||
$container->setDefinition('form.extension', $this->createExtensionDefinition());
|
||||
$container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type');
|
||||
$container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type');
|
||||
$container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type')->setPublic(true);
|
||||
$container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type')->setPublic(true);
|
||||
|
||||
$container->compile();
|
||||
|
||||
@ -73,8 +73,8 @@ class FormPassTest extends TestCase
|
||||
|
||||
$container->setDefinition('form.extension', $this->createExtensionDefinition());
|
||||
$container->setDefinition(DebugCommand::class, $this->createDebugCommandDefinition());
|
||||
$container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type');
|
||||
$container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type');
|
||||
$container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type')->setPublic(true);
|
||||
$container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type')->setPublic(true);
|
||||
|
||||
$container->compile();
|
||||
|
||||
@ -163,6 +163,7 @@ class FormPassTest extends TestCase
|
||||
|
||||
$container->setDefinition('form.extension', $this->createExtensionDefinition());
|
||||
$container->register('my.type_extension', 'stdClass')
|
||||
->setPublic(true)
|
||||
->addTag('form.type_extension');
|
||||
|
||||
$container->compile();
|
||||
@ -178,8 +179,8 @@ class FormPassTest extends TestCase
|
||||
$definition2->addTag('form.type_guesser');
|
||||
|
||||
$container->setDefinition('form.extension', $this->createExtensionDefinition());
|
||||
$container->setDefinition('my.guesser1', $definition1);
|
||||
$container->setDefinition('my.guesser2', $definition2);
|
||||
$container->setDefinition('my.guesser1', $definition1)->setPublic(true);
|
||||
$container->setDefinition('my.guesser2', $definition2)->setPublic(true);
|
||||
|
||||
$container->compile();
|
||||
|
||||
@ -249,6 +250,7 @@ class FormPassTest extends TestCase
|
||||
private function createExtensionDefinition()
|
||||
{
|
||||
$definition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
|
||||
$definition->setPublic(true);
|
||||
$definition->setArguments(array(
|
||||
array(),
|
||||
array(),
|
||||
@ -261,6 +263,7 @@ class FormPassTest extends TestCase
|
||||
private function createDebugCommandDefinition()
|
||||
{
|
||||
$definition = new Definition('Symfony\Component\Form\Command\DebugCommand');
|
||||
$definition->setPublic(true);
|
||||
$definition->setArguments(array(
|
||||
$formRegistry = $this->getMockBuilder(FormRegistryInterface::class)->getMock(),
|
||||
array(),
|
||||
|
@ -18,11 +18,14 @@ class ResettableServicePassTest extends TestCase
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('one', ResettableService::class)
|
||||
->setPublic(true)
|
||||
->addTag('kernel.reset', array('method' => 'reset'));
|
||||
$container->register('two', ClearableService::class)
|
||||
->setPublic(true)
|
||||
->addTag('kernel.reset', array('method' => 'clear'));
|
||||
|
||||
$container->register(ServiceResetListener::class)
|
||||
->setPublic(true)
|
||||
->setArguments(array(null, array()));
|
||||
$container->addCompilerPass(new ResettableServicePass('kernel.reset'));
|
||||
|
||||
|
@ -56,10 +56,11 @@ class ServiceResetListenerTest extends TestCase
|
||||
private function buildContainer()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('one', ResettableService::class);
|
||||
$container->register('two', ClearableService::class);
|
||||
$container->register('one', ResettableService::class)->setPublic(true);
|
||||
$container->register('two', ClearableService::class)->setPublic(true);
|
||||
|
||||
$container->register('reset_subscriber', ServiceResetListener::class)
|
||||
->setPublic(true)
|
||||
->addArgument(new IteratorArgument(array(
|
||||
'one' => new Reference('one', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE),
|
||||
'two' => new Reference('two', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE),
|
||||
|
@ -824,7 +824,7 @@ EOF;
|
||||
$this->assertFileExists($containerFile);
|
||||
unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta');
|
||||
|
||||
$kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass'); });
|
||||
$kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); });
|
||||
$kernel->boot();
|
||||
|
||||
$this->assertTrue(get_class($kernel->getContainer()) !== $containerClass);
|
||||
|
Reference in New Issue
Block a user