Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 69520c4

Browse filesBrowse files
committed
Add a new method to the compiled container
1 parent 82d3590 commit 69520c4
Copy full SHA for 69520c4

File tree

Expand file treeCollapse file tree

4 files changed

+34
-9
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+34
-9
lines changed

‎src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,15 @@ public function isProxyCandidate(Definition $definition)
6363
/**
6464
* {@inheritdoc}
6565
*/
66-
public function getProxyFactoryCode(Definition $definition, $id, $methodName = null)
66+
public function getProxyFactoryCode(Definition $definition, $id)
6767
{
6868
$instantiation = 'return';
6969

7070
if ($definition->isShared()) {
7171
$instantiation .= " \$this->services['$id'] =";
7272
}
7373

74-
if (null === $methodName) {
75-
@trigger_error(sprintf('You must use the third argument of %s to define the method to call to construct your service since version 3.1, not using it won\'t be supported in 4.0.', __METHOD__), E_USER_DEPRECATED);
76-
$methodName = 'get'.Container::camelize($id).'Service';
77-
}
74+
$methodName = 'get'.Container::camelize($id).'Service';
7875
$proxyClass = $this->getProxyClassName($definition);
7976

8077
$generatedClass = $this->generateProxyClass($definition);
@@ -88,7 +85,12 @@ public function getProxyFactoryCode(Definition $definition, $id, $methodName = n
8885
8986
$instantiation $constructorCall(
9087
function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) {
91-
\$wrappedInstance = \$this->$methodName(false);
88+
if (method_exists(\$this, 'getMethodFor')) {
89+
\$method = \$this->getMethodFor('$id');
90+
\$wrappedInstance = \$this->$methodName(false);
91+
} else {
92+
\$wrappedInstance = \$this->$methodName(false);
93+
}
9294
9395
\$proxy->setProxyInitializer(null);
9496

‎src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,30 @@ public function compile()
853853
throw new LogicException('You cannot compile a dumped frozen container.');
854854
}
855855
856+
EOF;
857+
}
858+
859+
/**
860+
* Adds the getter for the method map.
861+
*
862+
* @return string
863+
*/
864+
private function addMethodMapGetter()
865+
{
866+
return <<<EOF
867+
868+
/*{$this->docStar}
869+
* {@inheritdoc}
870+
*/
871+
public function getMethodFor(\$id)
872+
{
873+
if (isset(\$this->methodMap[\$id])) {
874+
return \$this->methodMap[\$id];
875+
}
876+
877+
throw new LogicException(sprintf('Service %s doesn\'t exist.', \$id));
878+
}
879+
856880
EOF;
857881
}
858882

‎src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ public function isProxyCandidate(Definition $definition);
3434
*
3535
* @param Definition $definition
3636
* @param string $id service identifier
37-
* @param string $methodName the method name to get the service, will be added to the interface in 4.0.
3837
*
3938
* @return string
4039
*/
41-
public function getProxyFactoryCode(Definition $definition, $id/**, $methodName = null */);
40+
public function getProxyFactoryCode(Definition $definition, $id);
4241

4342
/**
4443
* Generates the code for the lazy proxy.

‎src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function isProxyCandidate(Definition $definition)
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function getProxyFactoryCode(Definition $definition, $id, $methodName = null)
34+
public function getProxyFactoryCode(Definition $definition, $id)
3535
{
3636
return '';
3737
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.