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

[ProxyManagerBridge] remove deprecated features #22785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use ProxyManager\Generator\ClassGenerator;
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;

Expand Down Expand Up @@ -63,20 +62,18 @@ public function isProxyCandidate(Definition $definition)
/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, $id)
public function getProxyFactoryCode(Definition $definition, $id, $methodName = null)
{
$instantiation = 'return';

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

if (func_num_args() >= 3) {
$methodName = func_get_arg(2);
} else {
@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);
$methodName = 'get'.Container::camelize($id).'Service';
if (null === $methodName) {
throw new \InvalidArgumentException(sprintf('Missing name of method to call to construct the service "%s".', $id));
}

$proxyClass = $this->getProxyClassName($definition);

$generatedClass = $this->generateProxyClass($definition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,14 @@ public function testGetProxyFactoryCodeWithCustomMethod()
}

/**
* @group legacy
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Missing name of method to call to construct the service "foo".
*/
public function testGetProxyFactoryCode()
public function testGetProxyFactoryCodeWithoutCustomMethod()
{
$definition = new Definition(__CLASS__);

$definition->setLazy(true);

$code = $this->dumper->getProxyFactoryCode($definition, 'foo');

$this->assertStringMatchesFormat(
'%wif ($lazyLoad) {%wreturn $this->services[\'foo\'] =%s'
.'SymfonyBridgeProxyManagerTestsLazyProxyPhpDumperProxyDumperTest_%s(%wfunction '
.'(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) {'
.'%w$wrappedInstance = $this->getFooService(false);%w$proxy->setProxyInitializer(null);'
.'%wreturn true;%w}%w);%w}%w',
$code
);
$this->dumper->getProxyFactoryCode($definition, 'foo');
}

/**
Expand Down
2 changes: 2 additions & 0 deletions 2 src/Symfony/Component/DependencyInjection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ CHANGELOG
4.0.0
-----

* added a third `$methodName` argument to the `getProxyFactoryCode()` method
of the `DumperInterface`
* removed support for autowiring types
* removed `Container::isFrozen`
* removed support for dumping an ucompiled container in `PhpDumper`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public function isProxyCandidate(Definition $definition);
*
* @param Definition $definition
* @param string $id service identifier
* @param string $methodName the method name to get the service, will be added to the interface in 4.0
* @param string $methodName the method name to get the service
*
* @return string
*/
public function getProxyFactoryCode(Definition $definition, $id/**, $methodName = null */);
public function getProxyFactoryCode(Definition $definition, $id, $methodName);

/**
* Generates the code for the lazy proxy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testNullDumper()
$definition = new Definition('stdClass');

$this->assertFalse($dumper->isProxyCandidate($definition));
$this->assertSame('', $dumper->getProxyFactoryCode($definition, 'foo'));
$this->assertSame('', $dumper->getProxyFactoryCode($definition, 'foo', 'getFooService'));
$this->assertSame('', $dumper->getProxyCode($definition));
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.