Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[WIP][HttpKernel] Expose bundle hierarchy/metadata as a service#19594
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ro0NL commentedAug 10, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@wesleylancel noted this could perhaps be enhanced using the |
ro0NL commentedAug 10, 2016
Besides that, to fix the caching this parameter needs to be converted some way, some how. We can go serialization way, or maybe introduce a |
| * | ||
| * @author Roland Franssen <franssen.roland@gmail.com> | ||
| */ | ||
| final class BundleVO |
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.
BundleMetadata?
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.
Yes. Will do.
GuilhemN commentedAug 11, 2016
Why do you need that ? |
ro0NL commentedAug 11, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Main problem is the So this approach is about exposing bundle info as a parameter, so it's available in a early phase. Ie when building the container, ie extensions. Besides that, i like the way this represents your bundle ecosystem, imho it's more useful thenjust |
GuilhemN commentedAug 11, 2016
@ro0NL as you said i think the real problem here is that the kernel is not available during compilation, maybe we should try to do that at first ? |
ro0NL commentedAug 11, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Good point. However, im not sure we should pass the kernel around, as is, in this phase. I can imagine reasons why it's currently added afterwards, ie you can really break the ecosystem as lots of stuff is publicly accessible, not frozen, etc. Hence i chose for a VO object, to avoid passing bundle instances around at all. But maybe someone can advice why to, or why not. I just hope we can agree this needs to be available. |
ro0NL commentedAug 11, 2016
I like the idea of separating the kernel from metadata/utilities, and break it down to just booting/handling/terminating etc. For metadata/utility the real kernel just uses the "kernel as a service". Eventually im not to sure about passing the real kernel as a service (like now after building), i think it's made available for the wrong reasons (ie exposing metadata/utilities). |
GuilhemN commentedAug 11, 2016
@ro0NL many things can break an app, i don't think that because someone can misuse a feature we should not include it. |
ro0NL commentedAug 11, 2016
Im pretty sure this is the reason it's registered after building. If not, this is as easy as moving a few lines around, so im really curious here... |
GuilhemN commentedAug 11, 2016
@ro0NL no that's not that easy because the |
ro0NL commentedAug 11, 2016
I havent fully investigated this yet, im still a bit unaware of inner workings here. Could you perhaps explain "the ContainerBuilder removes definitions when you use set" / point me to it. Eventually i would like the kernel metadata to be cached as a service definition. |
GuilhemN commentedAug 11, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
That's very complicated to access services during the compilation, mostly due tothis. |
ro0NL commentedAug 11, 2016
Got it. This is hard.. what about an object being a frozen definition and a real service at the same time... |
GuilhemN commentedAug 11, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@ro0NL it could be a solution but remember that we have to deal with bc :) |
ro0NL commentedAug 11, 2016
Of course, i'll have look at it this weekend to work on a better poc. |
ogizanagi commentedAug 11, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Not convinced by the use cases targeted by this feature, but what about something like: $container->set('booting_kernel',newBootingKernel($this)); where However:
|
ro0NL commentedAug 12, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The usecase is to have a ecosystem that allows for bugs like#6919 and#18563 to be fixed, and not have to workaround each time. Im aware of the container builder, and how it works. I tend to go with a Basically i want to write an extension that acts upon bundles and the kernel. |
| public function __toString() | ||
| { | ||
| return $this->className; | ||
| } |
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.
Is a__toString really necessary? If you want the class name, you can just call it from the getter
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.
No.. i forgot to remove it. So ignore for now.
linaori commentedAug 12, 2016
I'm not entirely sure what this does yet... But will this allow the addition of a "virtual" bundle? Basically hinting towards 2 things:
|
ro0NL commentedAug 12, 2016
Yes, it should allow for virtual bundles. I dont get your 2 points fully yet, but i try to show a better POC this afternoon. |
linaori commentedAug 12, 2016
I've taken some snapshots of how we've currently implemented it: class EntityPackage{publicfunction__construct($name,$path,$namespace ='',$alias ='');publicfunctiongetAlias();publicfunctiongetName();publicfunctiongetPath();publicfunctiongetNamespace();}// ...publicstaticfunctionload(&$bundles,$file = EntityInformation::CACHE_FILE){$packages = (newEntityInformation($file))->getEntityPackages();// Create and append HostnetEntityBundles for all entries.foreach ($packagesas$package) {$bundles[] =newHostnetEntityBundle($package); }$bundles[] =newHostnetDoctrineBundle();}// and in the end of registerBundles() in AppKernelHostnetEntityBundle::load($bundles);return$bundles; Basically comes down to having entity packages which feature no bundle concept/dependency while still registering all of them as bundle once in symfony and hooking up their repositories to the DIC by registering them as services. |
ro0NL commentedAug 12, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Looks creative :-) no offense. Imho this looks more event related (ideally listening to kernel boot events that is). My need is to modify the containerbuilder from a bundle extension, based on the ecosystem (kernel info, bundle info, etc.). For exmple the twigissue which needs to act upon the bundle hierarchy. Having this available as a service would be so convenient :-) edit:
In a way, it solves#18563 pretty easy. Maybe to get my bigger picture, i want to decouple the way we (ab)use the Seemaster...ro0NL:http-kernel/kernel-as-a-service to get an idea how i want to solve this. Eventually the kernel can be passed to a compiler pass, which registers/builds the kernel as a definition+service object (hence service aware definition). In early phase we have a useful kernel service object, later on, from cache we have the same service object. Via the kernel service you can get bundle vo's/metadata (anything but the real bundle interface). |
ogizanagi commentedAug 12, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@ro0NL: Why not simply allow to use (undeprecate) |
ro0NL commentedAug 12, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Im not sure.. i can imagine this is a design choice. There are 2 phases (building and runtime), where there's only 1 container per phase (respectively However due the 1st phase we cant use it as a container throughout as it cant guarantee safe services yet (not fully built) when getting. Why setting direct (fully built) services is not allowed, im not sure.. like i said i guess it's a design choice: The Anyway, to adhere to all this, i chose fortrue service objects representing the ecosystem (ie they have a corresponding definition), which allows it to work in both phases (it introcudes a design change though to do that, so im curious about it). Eventually this allows also for separation of concerns (the kernel (functional), and kernel-service (informational/util)). To clarify, edit:master...ro0NL:http-kernel/kernel-as-a-service is a better poc now, so i guess im gonna close this one in favor of a new PR. |
Uh oh!
There was an error while loading.Please reload this page.
This is a proof of concept to expose the bundle hierarchy and metadata in a early phase. For example when needed in a bundle extension. This makes the ecosystem a lot more flexible imho.