-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC][DependencyInjection][HttpKernel] Kernel as a service #19606
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d33a871
added ServiceAwareDefinition
ro0NL b75416a
added kernel/bundle service objects
ro0NL a10d563
the kernel as a service
ro0NL 6ddc8d5
fixed tests
ro0NL 4f52e29
allow for synthetic services while loading extensions - part 1
ro0NL 96b0e4b
oops
ro0NL 9b118aa
allow for synthetic services while loading extensions - part 2
ro0NL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
allow for synthetic services while loading extensions - part 2
- Loading branch information
commit 9b118aa617be63a10fca1d84367d71ad3b3813a1
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,16 +419,6 @@ public function has($id) | |
*/ | ||
public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) | ||
{ | ||
$definition = $this->hasDefinition($id) ? $this->getDefinition($id) : null; | ||
if (null !== $definition && $definition instanceof ServiceAwareDefinition) { | ||
return $definition->getService(); | ||
} | ||
// @TODO allow for available synthetic services? | ||
|
||
if (!$this->compiled) { | ||
@trigger_error(sprintf('Calling %s() before compiling the container is deprecated since version 3.2 and will throw an exception in 4.0.', __METHOD__), E_USER_DEPRECATED); | ||
} | ||
|
||
$id = strtolower($id); | ||
|
||
if ($service = parent::get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE)) { | ||
|
@@ -439,10 +429,27 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV | |
return $this->get($this->aliasDefinitions[$id]); | ||
} | ||
|
8000
||
if (null === $definition && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { | ||
try { | ||
$definition = $this->getDefinition($id); | ||
if ($definition instanceof ServiceAwareDefinition) { | ||
return $definition->getService(); | ||
} | ||
} catch (ServiceNotFoundException $e) { | ||
if ($this->compiled && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { | ||
throw $e; | ||
} | ||
$definition = null; | ||
} | ||
if (!$this->compiled) { | ||
@trigger_error(sprintf('Calling %s() before compiling the container is deprecated for non-synthetic services since version 3.2 and will throw an exception in 4.0.', __METHOD__), E_USER_DEPRECATED); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to be specific about non-synthetic services, besides that it will be triggered only once now whe 8000 n aliases kick in. |
||
} | ||
if (null === $definition) { | ||
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { | ||
throw new ServiceNotFoundException($id); | ||
} | ||
|
||
return; | ||
} | ||
$definition = $this->getDefinition($id); | ||
|
||
$this->loading[$id] = true; | ||
|
||
|
@@ -455,6 +462,29 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV | |
return $service; | ||
} | ||
|
||
/** | ||
* Get synthetic services. | ||
* | ||
* @return object[] | ||
*/ | ||
public function getSynthetics() | ||
{ | ||
$synthetics = array(); | ||
foreach ($this->definitions as $id => $definition) { | ||
if ($definition instanceof ServiceAwareDefinition) { | ||
$synthetics[$id] = $definition->getService(); | ||
} | ||
} | ||
foreach (parent::getServiceIds() as $id) { | ||
if ('service_container' === $id) { | ||
continue; | ||
} | ||
$synthetics[$id] = parent::get($id); | ||
} | ||
|
||
return $synthetics; | ||
} | ||
|
||
/** | ||
* Merges a ContainerBuilder with the current ContainerBuilder configuration. | ||
* | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For BC, however i tend to debug unknown id's before state. Just throwing here would be fine by me.