Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit 2459ad3

Browse files
committed
Fix issues laracasts#27
1 parent 18a27e7 commit 2459ad3

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/Laracasts/Commander/CommanderTrait.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@ public function execute($command, array $input = null, $decorators = [])
2222

2323
$bus = $this->getCommandBus();
2424

25-
// If any decorators are passed, we'll
26-
// filter through and register them
27-
// with the CommandBus, so that they
28-
// are executed first.
29-
foreach ($decorators as $decorator)
25+
// If any decorators are passed, we'll filter through and register them
26+
// with the CommandBus, so that they are executed first.
27+
if ($decorators)
3028
{
31-
$bus->decorate($decorator);
29+
foreach ($decorators as $decorator)
30+
{
31+
$bus->decorate($decorator);
32+
}
33+
} else {
34+
$bus->unDecorate();
3235
}
3336

37+
3438
return $bus->execute($command);
3539
}
3640

src/Laracasts/Commander/DefaultCommandBus.php

+10
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ public function decorate($className)
4343
$this->decorators[] = $className;
4444
}
4545

46+
/**
47+
* Clear decorations from the command bus
48+
*
49+
* @return null
50+
*/
51+
public function unDecorate()
52+
{
53+
$this->decorators = [];
54+
}
55+
4656
/**
4757
* Execute the command
4858
*

0 commit comments

Comments
 (0)