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

Decorators of the parent command will be executed on the child command #57

Open
arminsam opened this issue Jan 30, 2015 · 1 comment
Open

Comments

@arminsam
Copy link

I have CommandA with ONE decorator class.

I have CommandB with NO decorator classes.

In CommandA handler, I execute CommandB.

By right, when I execute CommandA, these steps should happen:

1- Decorator of CommandA should be executed
2- CommandA handler should be called
3- CommandB handler should be called

However, I found that the decorator class of CommandA will execute twice:

1- Decorator of CommandA is executed
2- CommandA handler is called
3- Decorator of CommandA is executed again
4- CommandB handler is called

I managed to fix the issue by adding this check to CommanderTrait->execute() function:

if (empty($decorators))
{
    $bus->emptyDecorators();
}

where emptyDecorators() is defined in CommandBus implementation as:

/**
* Remove all 
*/
public function emptyDecorators ()
{
    $this->decorators = [];
}

Thanks.

@nesl247
Copy link

nesl247 commented Jan 30, 2015

This was fixed already, BUT, it was not fixed in the version for Laravel 4. This definitely needs to be handled.

If you want to manually do it for now, in the ServiceProvider, changed bindShared to bind.

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

No branches or pull requests

2 participants