File tree Expand file tree Collapse file tree 7 files changed +53
-11
lines changed Expand file tree Collapse file tree 7 files changed +53
-11
lines changed Original file line number Diff line number Diff line change @@ -40,13 +40,14 @@ class EventServiceProvider extends ServiceProvider
4040``` php
4141namespace App\Listeners;
4242
43+ use DragonCode\LaravelDeployOperations\Enums\MethodEnum;
4344use DragonCode\LaravelDeployOperations\Events\BaseEvent;
4445
4546class SomeOperationsListener
4647{
4748 public function handle(BaseEvent $event): void
4849 {
49- $method = $event->method; // `up` or `down` string value
50+ $method = $event->method; // MethodEnum object value
5051 $isBefore = $event->before; // boolean
5152 }
5253}
Original file line number Diff line number Diff line change 1515- [ Database transactions] ( #database-transactions )
1616- [ Removed ` $async ` property] ( #removed-async-property )
1717- [ Removed ` operations:stub ` command] ( #removed-operationsstub-command )
18+ - [ Changed property typing for events] ( #changed-property-typing-for-events )
1819
1920## Low-Impact Changes
2021
@@ -102,6 +103,30 @@ You should replace `DragonCode\LaravelActions\Action` namespace with `DragonCode
102103Don't forget to also change the namespace from ` DragonCode\LaravelActions\Events `
103104to ` DragonCode\LaravelDeployOperations\Events ` .
104105
106+ ## Changed property typing for events
107+
108+ The type of the ` method ` property for events has been changed.
109+
110+ Before:
111+
112+ ``` php
113+ use DragonCode\LaravelActions\Events\ActionEnded;
114+ use DragonCode\LaravelDeployOperations\Enums\MethodEnum;
115+
116+ /** @var ActionEnded */
117+ $event->method; // is string
118+ ```
119+
120+ After:
121+
122+ ``` php
123+ use DragonCode\LaravelDeployOperations\Enums\MethodEnum;
124+ use DragonCode\LaravelDeployOperations\Events\DeployOperationEnded;
125+
126+ /** @var DeployOperationEnded */
127+ $event->method; // is MethodEnum
128+ ```
129+
105130## Configuration file name changed
106131
107132We recommend that you delete the old configuration file ` config/actions.php ` and publish a new one.
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace DragonCode \LaravelDeployOperations \Enums ;
6+
7+ enum MethodEnum: string
8+ {
9+ case Up = 'up ' ;
10+ case Down = 'down ' ;
11+ }
Original file line number Diff line number Diff line change 44
55namespace DragonCode \LaravelDeployOperations \Events ;
66
7+ use DragonCode \LaravelDeployOperations \Enums \MethodEnum ;
8+
79abstract class BaseEvent
810{
911 public function __construct (
10- public string $ method ,
12+ public MethodEnum $ method ,
1113 public bool $ before
1214 ) {}
1315}
Original file line number Diff line number Diff line change 66
77use DragonCode \LaravelDeployOperations \Constants \Names ;
88use DragonCode \LaravelDeployOperations \Constants \Options ;
9+ use DragonCode \LaravelDeployOperations \Enums \MethodEnum ;
910use DragonCode \LaravelDeployOperations \Events \DeployOperationEnded ;
1011use DragonCode \LaravelDeployOperations \Events \DeployOperationFailed ;
1112use DragonCode \LaravelDeployOperations \Events \DeployOperationStarted ;
@@ -40,19 +41,19 @@ protected function runOperations(array $completed): void
4041 {
4142 try {
4243 if ($ files = $ this ->getNewFiles ($ completed )) {
43- $ this ->fireEvent (DeployOperationStarted::class, ' up ' );
44+ $ this ->fireEvent (DeployOperationStarted::class, MethodEnum::Up );
4445
4546 $ this ->runEach ($ files , $ this ->getBatch ());
4647
47- $ this ->fireEvent (DeployOperationEnded::class, ' up ' );
48+ $ this ->fireEvent (DeployOperationEnded::class, MethodEnum::Up );
4849
4950 return ;
5051 }
5152
52- $ this ->fireEvent (NoPendingDeployOperations::class, ' up ' );
53+ $ this ->fireEvent (NoPendingDeployOperations::class, MethodEnum::Up );
5354 }
5455 catch (Throwable $ e ) {
55- $ this ->fireEvent (DeployOperationFailed::class, ' up ' );
56+ $ this ->fireEvent (DeployOperationFailed::class, MethodEnum::Up );
5657
5758 throw $ e ;
5859 }
Original file line number Diff line number Diff line change 66
77use Closure ;
88use DragonCode \LaravelDeployOperations \Concerns \Artisan ;
9+ use DragonCode \LaravelDeployOperations \Enums \MethodEnum ;
910use DragonCode \LaravelDeployOperations \Helpers \Config ;
1011use DragonCode \LaravelDeployOperations \Helpers \Git ;
1112use DragonCode \LaravelDeployOperations \Helpers \Sorter ;
@@ -78,7 +79,7 @@ protected function tableNotFound(): bool
7879 return false ;
7980 }
8081
81- protected function fireEvent (string $ event , string $ method ): void
82+ protected function fireEvent (string $ event , MethodEnum $ method ): void
8283 {
8384 $ this ->events ->dispatch (new $ event ($ method , $ this ->options ->before ));
8485 }
Original file line number Diff line number Diff line change 44
55namespace DragonCode \LaravelDeployOperations \Processors ;
66
7+ use DragonCode \LaravelDeployOperations \Enums \MethodEnum ;
78use DragonCode \LaravelDeployOperations \Events \DeployOperationEnded ;
89use DragonCode \LaravelDeployOperations \Events \DeployOperationStarted ;
910use DragonCode \LaravelDeployOperations \Events \NoPendingDeployOperations ;
@@ -13,23 +14,23 @@ class Rollback extends Processor
1314 public function handle (): void
1415 {
1516 if ($ this ->tableNotFound () || $ this ->nothingToRollback ()) {
16- $ this ->fireEvent (NoPendingDeployOperations::class, ' down ' );
17+ $ this ->fireEvent (NoPendingDeployOperations::class, MethodEnum::Down );
1718
1819 return ;
1920 }
2021
2122 if ($ items = $ this ->getOperations ($ this ->options ->step )) {
22- $ this ->fireEvent (DeployOperationStarted::class, ' down ' );
23+ $ this ->fireEvent (DeployOperationStarted::class, MethodEnum::Down );
2324
2425 $ this ->showCaption ();
2526 $ this ->run ($ items );
2627
27- $ this ->fireEvent (DeployOperationEnded::class, ' down ' );
28+ $ this ->fireEvent (DeployOperationEnded::class, MethodEnum::Down );
2829
2930 return ;
3031 }
3132
32- $ this ->fireEvent (NoPendingDeployOperations::class, ' down ' );
33+ $ this ->fireEvent (NoPendingDeployOperations::class, MethodEnum::Down );
3334 }
3435
3536 protected function showCaption (): void
You can’t perform that action at this time.
0 commit comments