File tree Expand file tree Collapse file tree 8 files changed +62
-20
lines changed Expand file tree Collapse file tree 8 files changed +62
-20
lines changed Original file line number Diff line number Diff line change @@ -40,13 +40,14 @@ class EventServiceProvider extends ServiceProvider
40
40
``` php
41
41
namespace App\Listeners;
42
42
43
+ use DragonCode\LaravelDeployOperations\Enums\MethodEnum;
43
44
use DragonCode\LaravelDeployOperations\Events\BaseEvent;
44
45
45
46
class SomeOperationsListener
46
47
{
47
48
public function handle(BaseEvent $event): void
48
49
{
49
- $method = $event->method; // `up` or `down` string value
50
+ $method = $event->method; // MethodEnum object value
50
51
$isBefore = $event->before; // boolean
51
52
}
52
53
}
Original file line number Diff line number Diff line change 15
15
- [ Database transactions] ( #database-transactions )
16
16
- [ Removed ` $async ` property] ( #removed-async-property )
17
17
- [ Removed ` operations:stub ` command] ( #removed-operationsstub-command )
18
+ - [ Changed property typing for events] ( #changed-property-typing-for-events )
18
19
19
20
## Low-Impact Changes
20
21
@@ -102,6 +103,30 @@ You should replace `DragonCode\LaravelActions\Action` namespace with `DragonCode
102
103
Don't forget to also change the namespace from ` DragonCode\LaravelActions\Events `
103
104
to ` DragonCode\LaravelDeployOperations\Events ` .
104
105
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
+
105
130
## Configuration file name changed
106
131
107
132
We 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 4
4
5
5
class Names
6
6
{
7
- public const Operations = 'operations ' ;
8
- public const Fresh = 'operations:fresh ' ;
9
- public const Install = 'operations:install ' ;
10
- public const Make = 'make:operation ' ;
11
- public const Refresh = 'operations:refresh ' ;
12
- public const Reset = 'operations:reset ' ;
13
- public const Rollback = 'operations:rollback ' ;
14
- public const Status = 'operations:status ' ;
15
- public const Upgrade = 'operations:upgrade ' ;
7
+ public const Operations = 'operations ' ;
8
+ public const Fresh = 'operations:fresh ' ;
9
+ public const Install = 'operations:install ' ;
10
+ public const Make = 'make:operation ' ;
11
+ public const Refresh = 'operations:refresh ' ;
12
+ public const Reset = 'operations:reset ' ;
13
+ public const Rollback = 'operations:rollback ' ;
14
+ public const Status = 'operations:status ' ;
15
+ public const Upgrade = 'operations:upgrade ' ;
16
16
}
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 4
4
5
5
namespace DragonCode \LaravelDeployOperations \Events ;
6
6
7
+ use DragonCode \LaravelDeployOperations \Enums \MethodEnum ;
8
+
7
9
abstract class BaseEvent
8
10
{
9
11
public function __construct (
10
- public string $ method ,
12
+ public MethodEnum $ method ,
11
13
public bool $ before
12
14
) {}
13
15
}
Original file line number Diff line number Diff line change 6
6
7
7
use DragonCode \LaravelDeployOperations \Constants \Names ;
8
8
use DragonCode \LaravelDeployOperations \Constants \Options ;
9
+ use DragonCode \LaravelDeployOperations \Enums \MethodEnum ;
9
10
use DragonCode \LaravelDeployOperations \Events \DeployOperationEnded ;
10
11
use DragonCode \LaravelDeployOperations \Events \DeployOperationFailed ;
11
12
use DragonCode \LaravelDeployOperations \Events \DeployOperationStarted ;
@@ -40,19 +41,19 @@ protected function runOperations(array $completed): void
40
41
{
41
42
try {
42
43
if ($ files = $ this ->getNewFiles ($ completed )) {
43
- $ this ->fireEvent (DeployOperationStarted::class, ' up ' );
44
+ $ this ->fireEvent (DeployOperationStarted::class, MethodEnum::Up );
44
45
45
46
$ this ->runEach ($ files , $ this ->getBatch ());
46
47
47
- $ this ->fireEvent (DeployOperationEnded::class, ' up ' );
48
+ $ this ->fireEvent (DeployOperationEnded::class, MethodEnum::Up );
48
49
49
50
return ;
50
51
}
51
52
52
- $ this ->fireEvent (NoPendingDeployOperations::class, ' up ' );
53
+ $ this ->fireEvent (NoPendingDeployOperations::class, MethodEnum::Up );
53
54
}
54
55
catch (Throwable $ e ) {
55
- $ this ->fireEvent (DeployOperationFailed::class, ' up ' );
56
+ $ this ->fireEvent (DeployOperationFailed::class, MethodEnum::Up );
56
57
57
58
throw $ e ;
58
59
}
Original file line number Diff line number Diff line change 6
6
7
7
use Closure ;
8
8
use DragonCode \LaravelDeployOperations \Concerns \Artisan ;
9
+ use DragonCode \LaravelDeployOperations \Enums \MethodEnum ;
9
10
use DragonCode \LaravelDeployOperations \Helpers \Config ;
10
11
use DragonCode \LaravelDeployOperations \Helpers \Git ;
11
12
use DragonCode \LaravelDeployOperations \Helpers \Sorter ;
@@ -78,7 +79,7 @@ protected function tableNotFound(): bool
78
79
return false ;
79
80
}
80
81
81
- protected function fireEvent (string $ event , string $ method ): void
82
+ protected function fireEvent (string $ event , MethodEnum $ method ): void
82
83
{
83
84
$ this ->events ->dispatch (new $ event ($ method , $ this ->options ->before ));
84
85
}
Original file line number Diff line number Diff line change 4
4
5
5
namespace DragonCode \LaravelDeployOperations \Processors ;
6
6
7
+ use DragonCode \LaravelDeployOperations \Enums \MethodEnum ;
7
8
use DragonCode \LaravelDeployOperations \Events \DeployOperationEnded ;
8
9
use DragonCode \LaravelDeployOperations \Events \DeployOperationStarted ;
9
10
use DragonCode \LaravelDeployOperations \Events \NoPendingDeployOperations ;
@@ -13,23 +14,23 @@ class Rollback extends Processor
13
14
public function handle (): void
14
15
{
15
16
if ($ this ->tableNotFound () || $ this ->nothingToRollback ()) {
16
- $ this ->fireEvent (NoPendingDeployOperations::class, ' down ' );
17
+ $ this ->fireEvent (NoPendingDeployOperations::class, MethodEnum::Down );
17
18
18
19
return ;
19
20
}
20
21
21
22
if ($ items = $ this ->getOperations ($ this ->options ->step )) {
22
- $ this ->fireEvent (DeployOperationStarted::class, ' down ' );
23
+ $ this ->fireEvent (DeployOperationStarted::class, MethodEnum::Down );
23
24
24
25
$ this ->showCaption ();
25
26
$ this ->run ($ items );
26
27
27
- $ this ->fireEvent (DeployOperationEnded::class, ' down ' );
28
+ $ this ->fireEvent (DeployOperationEnded::class, MethodEnum::Down );
28
29
29
30
return ;
30
31
}
31
32
32
- $ this ->fireEvent (NoPendingDeployOperations::class, ' down ' );
33
+ $ this ->fireEvent (NoPendingDeployOperations::class, MethodEnum::Down );
33
34
}
34
35
35
36
protected function showCaption (): void
You can’t perform that action at this time.
0 commit comments