-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from fmeccanici/feature/custom-state-changed-…
…event Feature/Allow to set custom StateChanged event
- Loading branch information
Showing
14 changed files
with
201 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/Dummy/CustomEventModelState/CustomEventModelState.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Spatie\ModelStates\Tests\Dummy\CustomEventModelState; | ||
|
||
use Spatie\ModelStates\State; | ||
use Spatie\ModelStates\StateConfig; | ||
|
||
abstract class CustomEventModelState extends State | ||
{ | ||
public static function config(): StateConfig | ||
{ | ||
return parent::config() | ||
->default(CustomEventModelStateA::class) | ||
->allowTransition(CustomEventModelStateA::class, CustomEventModelStateB::class) | ||
->stateChangedEvent(CustomStateChangedEvent::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Spatie\ModelStates\Tests\Dummy\CustomEventModelState; | ||
|
||
class CustomEventModelStateA extends CustomEventModelState | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Spatie\ModelStates\Tests\Dummy\CustomEventModelState; | ||
|
||
class CustomEventModelStateB extends CustomEventModelState | ||
{ | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
tests/Dummy/CustomEventModelState/CustomInvalidEventModelState.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Spatie\ModelStates\Tests\Dummy\CustomEventModelState; | ||
|
||
use Spatie\ModelStates\State; | ||
use Spatie\ModelStates\StateConfig; | ||
|
||
abstract class CustomInvalidEventModelState extends State | ||
{ | ||
public static function config(): StateConfig | ||
{ | ||
return parent::config() | ||
->default(CustomInvalidEventModelStateA::class) | ||
->allowTransition(CustomInvalidEventModelStateA::class, CustomInvalidEventModelStateB::class) | ||
->stateChangedEvent(CustomInvalidStateChangedEvent::class); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/Dummy/CustomEventModelState/CustomInvalidEventModelStateA.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Spatie\ModelStates\Tests\Dummy\CustomEventModelState; | ||
|
||
class CustomInvalidEventModelStateA extends CustomInvalidEventModelState | ||
{ | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
tests/Dummy/CustomEventModelState/CustomInvalidEventModelStateB.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Spatie\ModelStates\Tests\Dummy\CustomEventModelState; | ||
|
||
class CustomInvalidEventModelStateB extends CustomInvalidEventModelState | ||
{ | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
tests/Dummy/CustomEventModelState/CustomInvalidStateChangedEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Spatie\ModelStates\Tests\Dummy\CustomEventModelState; | ||
|
||
use Spatie\ModelStates\Events\StateChanged; | ||
use Spatie\ModelStates\State; | ||
use Spatie\ModelStates\Transition; | ||
|
||
class CustomInvalidStateChangedEvent | ||
{ | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
tests/Dummy/CustomEventModelState/CustomStateChangedEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Spatie\ModelStates\Tests\Dummy\CustomEventModelState; | ||
|
||
use Spatie\ModelStates\Events\StateChanged; | ||
use Spatie\ModelStates\State; | ||
use Spatie\ModelStates\Transition; | ||
|
||
class CustomStateChangedEvent extends StateChanged | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Spatie\ModelStates\Tests\Dummy; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Spatie\ModelStates\HasStates; | ||
use Spatie\ModelStates\Tests\Dummy\CustomEventModelState\CustomEventModelState; | ||
use Spatie\ModelStates\Tests\Dummy\ModelStates\ModelState; | ||
|
||
class TestModelCustomEvent extends TestModel | ||
{ | ||
protected $casts = [ | ||
'state' => CustomEventModelState::class, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Spatie\ModelStates\Tests\Dummy; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Spatie\ModelStates\HasStates; | ||
use Spatie\ModelStates\Tests\Dummy\CustomEventModelState\CustomEventModelState; | ||
use Spatie\ModelStates\Tests\Dummy\CustomEventModelState\CustomInvalidEventModelState; | ||
use Spatie\ModelStates\Tests\Dummy\ModelStates\ModelState; | ||
|
||
class TestModelCustomInvalidEvent extends TestModel | ||
{ | ||
protected $casts = [ | ||
'state' => CustomInvalidEventModelState::class, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters