Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

refactor all the service to register life cycle #2

wants to merge 2 commits into from

Conversation

beatwade
Copy link

how about write all the init service in register?

Copy link
Owner

@angyvolin angyvolin left a 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?

public function boot(Application $app)
{
$this->registerWorkflowConfiguration($app);
$app['workflow.registry'] = function ($app) {
Copy link
Owner

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.

return call_user_func($app[sprintf('%s.factory', $type)], $app[$definitionId], $app[$markingStoreId], $name);
};
//add symfony twig extension
$app->extend('twig', function ($twig, $app) {
Copy link
Owner

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'] = [];
Copy link
Owner

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:

  1. it's a sort of "fallback" in case no config was provided by user.
  2. 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

@angyvolin
Copy link
Owner

Closes #1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants