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

Decorator error when command is triggering another command #22

Open
ronnievisser opened this issue Aug 4, 2014 · 3 comments · May be fixed by #27
Open

Decorator error when command is triggering another command #22

ronnievisser opened this issue Aug 4, 2014 · 3 comments · May be fixed by #27

Comments

@ronnievisser
Copy link

Hi,

I have the following logica in my app:
A command is creating a player which is firing a event which checks if the player already has an alias, if not it will create it using another command. The first command has a decorator. When the second command is firing it is also hitting the decorator given in the first command which should not happen.

Regards, Ronnie

@aarongustafson
Copy link

Yeah, I’m running into this too. For instance when registering a user, I want to issue 3 commands:

  1. Create the User
  2. Send them the Activation email
  3. Log them in

This fails to work:

$this->execute(
        RegisterUserCommand::class,
        null, # when null, it’s really Input::all()
        # Decorators
        [
            'Acme\Decorators\AssignIdAsUUID',
            'Acme\Decorators\SplitUserName',
            'Acme\Decorators\RemoveFullName',
            'Acme\Decorators\AssignUserLanguage',
            'Acme\Decorators\LookupUserGravatar',
        ]
);

$this->execute(SendActivationEmailCommand::class, Input::only('email'));

$this->execute(BypassLoginCommand::class, Input::only('email'));

The decorators continue to survive the execution in the CommandBus. They really should be reset with each call to $this->execute(). I tried passing an empty array and that did not work either.

I’m going to see if I can ferret out the issue directly, but I would love to hear from @JeffreyWay on this one.

@bruno-barros
Copy link

humm the CommandBus should remove the decorator after excecute it. Another point to me is the result of decorators don't change the command object. I've expected the decorators to be transformers to. Am I missing something here?

@aarongustafson
Copy link

I found a solution. There is a bit of code duplication between the ValidatorCommandBus and the DefaultCommandBus, but without stepping on @JeffreyWay’s toes there, I’ve got a solution. I will set up a Pull Request momentarily.

@aarongustafson aarongustafson linked a pull request Aug 13, 2014 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants