Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

ProxyManager Bridge#7890

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Changes from1 commit
Commits
Show all changes
39 commits
Select commitHold shift + click to select a range
f829b7f
First implementation of lazy services via proxy manager
OcramiusMar 29, 2013
1874dbf
Adding basic logic to generate proxy instantiation into a php dumped …
OcramiusMar 30, 2013
37abd21
Compiling proxies into the generated DIC file
OcramiusMar 30, 2013
7c1c5fd
Upgrading dependency to ProxyManager 0.3.*
OcramiusMar 30, 2013
d0b4075
Suggesting ProxyManager in composer.json, removing useless calls
OcramiusMar 31, 2013
d994434
Adding failing test to demonstrate that proxy initialization breaks s…
OcramiusMar 31, 2013
2c6bf54
Fixing shared service instance
OcramiusMar 31, 2013
ee0d51f
Sharing services in the container should only happen when proxying fa…
OcramiusMar 31, 2013
f986dc7
Adding tests for proxy sharing within dumped containers
OcramiusMar 31, 2013
cc56920
Fixing shared proxies into the container
OcramiusMar 31, 2013
a6b031e
Bumping required version of ProxyManager
OcramiusMar 31, 2013
d8acc5e
Docblock for ContainerBuilder#shareService
OcramiusMar 31, 2013
e5f6bf2
Adding `ContainerBuilder#addClassResource`
OcramiusMar 31, 2013
fa46c93
Adding test to check that class resources are registered for lazy ser…
OcramiusApr 1, 2013
b90b359
Fixing tests, registering class resources for lazy services
OcramiusApr 1, 2013
eb3d703
Reverting import of global namespace classes
OcramiusApr 2, 2013
e364616
Lazier checks on the proxy structure (avoiding whitespace-based test …
OcramiusApr 25, 2013
ba3a232
Getters for proxied services are public for 5.3.3 compatibility
OcramiusApr 25, 2013
2dffad5
Enforcing soft dependency to ProxyManager
OcramiusApr 25, 2013
2881fcc
Reverting documentation changes, adding exception types description i…
OcramiusApr 25, 2013
1439e0b
Lazier checks on the proxy structure
OcramiusApr 27, 2013
95db92a
Adding ProxyManager bridge structure
OcramiusApr 30, 2013
5a4513c
Adding implementation of the proxy dumper and instantiator
OcramiusApr 30, 2013
fa2445c
Using the proxy dumper in the php dumper
OcramiusApr 30, 2013
eba1909
Re-configuring the container builder to get proxy generators injected…
OcramiusApr 30, 2013
d34bdf4
Passing the proxy dumper to the PhpDumper via ContainerBuilder
OcramiusApr 30, 2013
7bb0bdd
Adding tests for the runtime proxy instantiator
OcramiusApr 30, 2013
57c1d76
Adding tests for the ProxyDumper
OcramiusApr 30, 2013
57b270b
Moving lazy service instantiation features/tests to ProxyManager bridge
OcramiusApr 30, 2013
eaf3585
Removing useless dependencies
OcramiusApr 30, 2013
64b452c
CS fixes (EOF EOL)
OcramiusApr 30, 2013
41237ee
Removing zendframework/zend-code from dev dependencies
OcramiusMay 1, 2013
dcfc388
Adding vendor dir to ignored coverage directories
OcramiusMay 1, 2013
0e52e96
Applying CS fixes as of @Stof's review
OcramiusMay 1, 2013
48f0ac2
Moving proxy dumper instantiation from container builder to kernel
OcramiusMay 5, 2013
194b9b5
Removing `@api` annotation
OcramiusMay 5, 2013
73f79cc
Removing @api annotations, moving getters to private visibility
OcramiusMay 5, 2013
d582131
Removing last `@api` occurrences in Definition
OcramiusMay 5, 2013
f4d3e8a
EOL dots in docblock sentences
OcramiusMay 5, 2013
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
PrevPrevious commit
NextNext commit
Fixing shared proxies into the container
  • Loading branch information
@Ocramius
Ocramius committedMay 5, 2013
commitcc56920f0288394d6c5b69aa666679f638413cc4
42 changes: 31 additions & 11 deletionssrc/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,15 +164,16 @@ private function addServiceLocalTempVariables($cId, $definition)
*/
private function addProxyLoading($id, Definition $definition)
{
if (!($definition->isLazy() &&$definition->getClass())) {
if (!$this->isProxyCandidate($definition)) {
return '';
}

$class =$this->dumpValue($definition->getClass());
$instantiation ='return';

if (0 === strpos($class, "'") && !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
// provided class name is not valid
return '';
if (ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) {
$instantiation .= " \$this->services['$id'] =";
} elseif (ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
$instantiation .= " \$this->services['$id'] = \$this->scopedServices['$scope']['$id'] =";
}

$methodName = 'get' . Container::camelize($id) . 'Service';
Expand All@@ -182,7 +183,7 @@ private function addProxyLoading($id, Definition $definition)
if (\$lazyLoad) {
\$container = \$this;

return new $proxyClass(
$instantiation new $proxyClass(
function (& \$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) {
\$proxy->setProxyInitializer(null);

Expand DownExpand Up@@ -222,13 +223,13 @@ function (Definition $definition) {

/* @var $proxyDefinitions Definition[] */
foreach ($proxyDefinitions as $definition) {
$phpClass = new ClassGenerator(
$generatedClass = new ClassGenerator(
str_replace('\\', '', $definition->getClass()) . '_' . md5(spl_object_hash($definition))
);

$proxyGenerator->generate(new ReflectionClass($definition->getClass()), $phpClass);
$proxyGenerator->generate(new ReflectionClass($definition->getClass()), $generatedClass);

$code .= "\n" . $classGenerator->generate($phpClass);
$code .= "\n" . $classGenerator->generate($generatedClass);
}

return $code;
Expand DownExpand Up@@ -368,9 +369,10 @@ private function addServiceInstance($id, $definition)
$simple = $this->isSimpleInstance($id, $definition);

$instantiation = '';
if (ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) {

if (!$this->isProxyCandidate($definition) && ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) {
$instantiation = "\$this->services['$id'] = ".($simple ? '' : '$instance');
} elseif (ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
} elseif (!$this->isProxyCandidate($definition) &&ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
$instantiation = "\$this->services['$id'] = \$this->scopedServices['$scope']['$id'] = ".($simple ? '' : '$instance');
} elseif (!$simple) {
$instantiation = '$instance';
Expand DownExpand Up@@ -1274,6 +1276,24 @@ private function getServiceCall($id, Reference $reference = null)
}
}

/**
* Tells if the given definitions are to be used for proxying
*
* @param Definition $definition
*
* @return bool
*/
private function isProxyCandidate(Definition $definition)
{
if (!($definition->isLazy() && $definition->getClass())) {
return false;
}

$class = $this->dumpValue($definition->getClass());

return (boolean) preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class);
}

/**
* Returns the next name to use
*
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp