Closed discordier closed 6 years ago
Looks good so far. What do you think about simplifying the definition of fallback services for Contao 3 by adding a second param to the share method
:
<?php
$container['example'] = $container->share(
function () {
return new Example();
},
'vendor.example'
);
Inside the share method it's checked if the symfony container is available. If the container is available and second param is passed, the service is delegated. Overthise the first param is used as fallback (Contao 3).
Well, the definition of the closures are parsed in Contao 4 as well. I wouldn't mind for that overhead.
We could provide a $container->factory
method as well for non shared services which acts the same way.
Problem is, the share
method is stateless and therefore we would then always be setting a service, the alias will get ignored or, worse the exception that the service has been overridden will get triggered.
So I see no way how your idea could work, if you see any, please explain as I'm always open for simplifying stuff.
I have update this for contao 4.
For travis i must install contao manager plugin or excluded the path?
@discordier Can you show this?
I added some more changes. Please review.
This PR is the work in progress for the new version
2.0
which will provide compatibility with Contao 3 & 4.