-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor all the service to register life cycle #2
base: master
Are you sure you want to change the base?
Conversation
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.
The main reason to use application boot for registering workflow configuration, is to allow another service providers adding their own workflow configs if any.
What if we simply move twig extension registration from boot() to register() method? Will this solve your issue?
src/WorkflowServiceProvider.php
Outdated
public function boot(Application $app) | ||
{ | ||
$this->registerWorkflowConfiguration($app); | ||
$app['workflow.registry'] = function ($app) { |
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.
This service definition rewrites previous one. Earlier can be removed.
src/WorkflowServiceProvider.php
Outdated
return call_user_func($app[sprintf('%s.factory', $type)], $app[$definitionId], $app[$markingStoreId], $name); | ||
}; | ||
//add symfony twig extension | ||
$app->extend('twig', function ($twig, $app) { |
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.
I think we should remain class_exists
check for those who don't use Twig.
@@ -50,75 +49,57 @@ function ($property = 'marking', PropertyAccessorInterface $propertyAccessor = n | |||
return new Registry(); | |||
}; | |||
|
|||
$app['workflow.config'] = []; |
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.
I'll prefer to remain this service parameter for two reasons:
- it's a sort of "fallback" in case no config was provided by user.
- one can add workflow configurations from any place after workflow service provider registration:
<?php
// some service provider
$app->extend('workflow.config', function (array $config) {
$config[] = ... // here comes workflow configuration
});
or simply
<?php
// yet another service provider
$app['workflow.config'][] = ... // here comes another workflow configuration
Closes #1 |
how about write all the init service in register?