Skip to content

Commit

Permalink
[DI] Remove deprecated scope concept
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Sep 4, 2015
1 parent eca45b7 commit 4a3e2f4
Show file tree
Hide file tree
Showing 70 changed files with 35 additions and 1,662 deletions.
Expand Up @@ -15,7 +15,6 @@
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;

Expand Down Expand Up @@ -68,10 +67,8 @@ public function getProxyFactoryCode(Definition $definition, $id)
{
$instantiation = 'return';

if ($definition->isShared() && ContainerInterface::SCOPE_CONTAINER === $definition->getScope(false)) {
if ($definition->isShared()) {
$instantiation .= " \$this->services['$id'] =";
} elseif ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope(false)) {
$instantiation .= " \$this->services['$id'] = \$this->scopedServices['$scope']['$id'] =";
}

$methodName = 'get'.Container::camelize($id).'Service';
Expand Down
Expand Up @@ -2,7 +2,6 @@

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
Expand All @@ -23,11 +22,7 @@ class LazyServiceProjectServiceContainer extends Container
*/
public function __construct()
{
$this->services =
$this->scopedServices =
$this->scopeStacks = array();
$this->scopes = array();
$this->scopeChildren = array();
$this->services = array();
}

/**
Expand All @@ -43,7 +38,6 @@ public function __construct()
public function getFooService($lazyLoad = true)
{
if ($lazyLoad) {

return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8(
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) {
$wrappedInstance = $this->getFooService(false);
Expand Down
Expand Up @@ -205,7 +205,6 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =
{
$data = array(
'class' => (string) $definition->getClass(),
'scope' => $definition->getScope(false),
'public' => $definition->isPublic(),
'synthetic' => $definition->isSynthetic(),
'lazy' => $definition->isLazy(),
Expand Down
Expand Up @@ -176,7 +176,6 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
protected function describeContainerDefinition(Definition $definition, array $options = array())
{
$output = '- Class: `'.$definition->getClass().'`'
."\n".'- Scope: `'.$definition->getScope(false).'`'
."\n".'- Public: '.($definition->isPublic() ? 'yes' : 'no')
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no')
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')
Expand Down
Expand Up @@ -256,7 +256,6 @@ protected function describeContainerDefinition(Definition $definition, array $op
$description[] = '<comment>Tags</comment> -';
}

$description[] = sprintf('<comment>Scope</comment> %s', $definition->getScope(false));
$description[] = sprintf('<comment>Public</comment> %s', $definition->isPublic() ? 'yes' : 'no');
$description[] = sprintf('<comment>Synthetic</comment> %s', $definition->isSynthetic() ? 'yes' : 'no');
$description[] = sprintf('<comment>Lazy</comment> %s', $definition->isLazy() ? 'yes' : 'no');
Expand Down
Expand Up @@ -346,7 +346,6 @@ private function getContainerDefinitionDocument(Definition $definition, $id = nu
}
}

$serviceXML->setAttribute('scope', $definition->getScope(false));
$serviceXML->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
$serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false');
$serviceXML->setAttribute('lazy', $definition->isLazy() ? 'true' : 'false');
Expand Down
5 changes: 0 additions & 5 deletions src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
Expand Up @@ -31,7 +31,6 @@
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\Scope;
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -65,10 +64,6 @@ public function build(ContainerBuilder $container)
{
parent::build($container);

// we need to add the request scope as early as possible so that
// the compilation can find scope widening issues
$container->addScope(new Scope('request'));

$container->addCompilerPass(new RoutingResolverPass());
$container->addCompilerPass(new ProfilerPass());
// must be registered before removing private services as some might be listeners/subscribers
Expand Down
Expand Up @@ -2,7 +2,6 @@
"definitions": {
"definition_1": {
"class": "Full\\Qualified\\Class1",
"scope": "container",
"public": true,
"synthetic": false,
"lazy": true,
Expand Down
Expand Up @@ -8,7 +8,6 @@ definition_1
~~~~~~~~~~~~
- Class: `Full\Qualified\Class1`
- Scope: `container`
- Public: yes
- Synthetic: no
- Lazy: yes
Expand Down
Expand Up @@ -2,7 +2,7 @@
<container>
<alias id="alias_1" service="service_1" public="true"/>
<alias id="alias_2" service="service_2" public="false"/>
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
<definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
</definition>
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/>
Expand Down
Expand Up @@ -2,7 +2,6 @@
"definitions": {
"definition_1": {
"class": "Full\\Qualified\\Class1",
"scope": "container",
"public": true,
"synthetic": false,
"lazy": true,
Expand All @@ -17,7 +16,6 @@
},
"definition_2": {
"class": "Full\\Qualified\\Class2",
"scope": "container",
"public": false,
"synthetic": true,
"lazy": false,
Expand Down
Expand Up @@ -8,7 +8,6 @@ definition_1
~~~~~~~~~~~~
- Class: `Full\Qualified\Class1`
- Scope: `container`
- Public: yes
- Synthetic: no
- Lazy: yes
Expand All @@ -21,7 +20,6 @@ definition_2
~~~~~~~~~~~~

- Class: `Full\Qualified\Class2`
- Scope: `container`
- Public: no
- Synthetic: yes
- Lazy: no
Expand Down
Expand Up @@ -2,10 +2,10 @@
<container>
<alias id="alias_1" service="service_1" public="true"/>
<alias id="alias_2" service="service_2" public="false"/>
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
<definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
</definition>
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
<definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<tags>
<tag name="tag1">
Expand Down
Expand Up @@ -2,7 +2,6 @@
"definitions": {
"definition_2": {
"class": "Full\\Qualified\\Class2",
"scope": "container",
"public": false,
"synthetic": true,
"lazy": false,
Expand Down
Expand Up @@ -8,7 +8,6 @@ definition_2
~~~~~~~~~~~~
- Class: `Full\Qualified\Class2`
- Scope: `container`
- Public: no
- Synthetic: yes
- Lazy: no
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<container>
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
<definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<tags>
<tag name="tag1">
Expand Down
Expand Up @@ -2,7 +2,6 @@
"tag1": [
{
"class": "Full\\Qualified\\Class2",
"scope": "container",
"public": false,
"synthetic": true,
"lazy": false,
Expand All @@ -16,7 +15,6 @@
"tag2": [
{
"class": "Full\\Qualified\\Class2",
"scope": "container",
"public": false,
"synthetic": true,
"lazy": false,
Expand Down
Expand Up @@ -8,7 +8,6 @@ definition_2
~~~~~~~~~~~~
- Class: `Full\Qualified\Class2`
- Scope: `container`
- Public: no
- Synthetic: yes
- Lazy: no
Expand All @@ -26,7 +25,6 @@ definition_2
~~~~~~~~~~~~

- Class: `Full\Qualified\Class2`
- Scope: `container`
- Public: no
- Synthetic: yes
- Lazy: no
Expand Down
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<container>
<tag name="tag1">
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
<definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
</definition>
</tag>
<tag name="tag2">
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
<definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
</definition>
</tag>
Expand Down
@@ -1,6 +1,5 @@
{
"class": "Full\\Qualified\\Class1",
"scope": "container",
"public": true,
"synthetic": false,
"lazy": true,
Expand Down
@@ -1,5 +1,4 @@
- Class: `Full\Qualified\Class1`
- Scope: `container`
- Public: yes
- Synthetic: no
- Lazy: yes
Expand Down
@@ -1,7 +1,6 @@
<comment>Service Id</comment> -
<comment>Class</comment> Full\Qualified\Class1
<comment>Tags</comment> -
<comment>Scope</comment> container
<comment>Public</comment> yes
<comment>Synthetic</comment> no
<comment>Lazy</comment> yes
Expand Down
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<definition class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
<definition class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
</definition>
@@ -1,6 +1,5 @@
{
"class": "Full\\Qualified\\Class2",
"scope": "container",
"public": false,
"synthetic": true,
"lazy": false,
Expand Down
@@ -1,5 +1,4 @@
- Class: `Full\Qualified\Class2`
- Scope: `container`
- Public: no
- Synthetic: yes
- Lazy: no
Expand Down
Expand Up @@ -4,7 +4,6 @@
- tag1 (<info>attr1</info>: val1, <info>attr2</info>: val2)
- tag1 (<info>attr3</info>: val3)
- tag2 ()
<comment>Scope</comment> container
<comment>Public</comment> no
<comment>Synthetic</comment> yes
<comment>Lazy</comment> no
Expand Down
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<definition class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
<definition class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<tags>
<tag name="tag1">
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========

3.0.0
-----

* removed all deprecated codes from 2.x versions

2.8.0
-----

Expand Down
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Component\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;

Expand All @@ -24,8 +23,6 @@
*
* - non synthetic, non abstract services always have a class set
* - synthetic services are always public
* - synthetic services are always of non-prototype scope
* - shared services are always of non-prototype scope
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
Expand All @@ -46,16 +43,6 @@ public function process(ContainerBuilder $container)
throw new RuntimeException(sprintf('A synthetic service ("%s") must be public.', $id));
}

// synthetic service has non-prototype scope
if ($definition->isSynthetic() && ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope(false)) {
throw new RuntimeException(sprintf('A synthetic service ("%s") cannot be of scope "prototype".', $id));
}

// shared service has non-prototype scope
if ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope(false)) {
throw new RuntimeException(sprintf('A shared service ("%s") cannot be of scope "prototype".', $id));
}

// non-synthetic, non-abstract service has class
if (!$definition->isAbstract() && !$definition->isSynthetic() && !$definition->getClass()) {
if ($definition->getFactory()) {
Expand Down

0 comments on commit 4a3e2f4

Please sign in to comment.