-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add service override events (#78)
* chore: Add service override events * chore: Dispatch service override events
- Loading branch information
Showing
6 changed files
with
167 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Sprout\Events; | ||
|
||
use Sprout\Contracts\ServiceOverride as ServiceOverrideClass; | ||
|
||
/** | ||
* Service Override Booted Event | ||
* | ||
* This event is dispatched after a service override has been booted. | ||
* | ||
* @template ServiceOverrideClass of \Sprout\Contracts\ServiceOverride | ||
* | ||
* @package Overrides | ||
* | ||
* @method static self dispatch(object $override) | ||
* @method static self dispatchIf(bool $boolean, object $override) | ||
* @method static self dispatchUnless(bool $boolean, object $override) | ||
*/ | ||
final class ServiceOverrideBooted extends ServiceOverrideEvent | ||
{ | ||
/** | ||
* @var object<\Sprout\Contracts\ServiceOverride> | ||
* @phpstan-var ServiceOverrideClass | ||
*/ | ||
public readonly object $override; | ||
|
||
/** | ||
* @param object<\Sprout\Contracts\ServiceOverride> $override | ||
* | ||
* @phpstan-param ServiceOverrideClass $override | ||
*/ | ||
public function __construct(object $override) | ||
{ | ||
$this->override = $override; | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Sprout\Events; | ||
|
||
use Illuminate\Foundation\Events\Dispatchable; | ||
|
||
/** | ||
* Service Override Event | ||
* | ||
* This is a base event class for the service override events. | ||
* | ||
* @package Overrides | ||
*/ | ||
abstract class ServiceOverrideEvent | ||
{ | ||
use Dispatchable; | ||
} |
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,36 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Sprout\Events; | ||
|
||
/** | ||
* Service Override Processed Event | ||
* | ||
* This event is dispatched after a service override has been processed. | ||
* | ||
* @template ServiceOverrideClass of \Sprout\Contracts\ServiceOverride | ||
* | ||
* @package Overrides | ||
* | ||
* @method static self dispatch(object $override) | ||
* @method static self dispatchIf(bool $boolean, object $override) | ||
* @method static self dispatchUnless(bool $boolean, object $override) | ||
*/ | ||
final class ServiceOverrideProcessed extends ServiceOverrideEvent | ||
{ | ||
/** | ||
* @var object<\Sprout\Contracts\ServiceOverride> | ||
* @phpstan-var ServiceOverrideClass | ||
*/ | ||
public readonly object $override; | ||
|
||
/** | ||
* @param object<\Sprout\Contracts\ServiceOverride> $override | ||
* | ||
* @phpstan-param ServiceOverrideClass $override | ||
*/ | ||
public function __construct(object $override) | ||
{ | ||
$this->override = $override; | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Sprout\Events; | ||
|
||
/** | ||
* Service Override Processing Event | ||
* | ||
* This event is dispatched before a service override is processed. | ||
* | ||
* @package Overrides | ||
* | ||
* @method static self dispatch(string $override) | ||
* @method static self dispatchIf(bool $boolean, string $override) | ||
* @method static self dispatchUnless(bool $boolean, string $override) | ||
*/ | ||
final class ServiceOverrideProcessing extends ServiceOverrideEvent | ||
{ | ||
/** | ||
* @var class-string<\Sprout\Contracts\ServiceOverride> | ||
*/ | ||
public readonly string $override; | ||
|
||
/** | ||
* @param class-string<\Sprout\Contracts\ServiceOverride> $override | ||
*/ | ||
public function __construct(string $override) | ||
{ | ||
$this->override = $override; | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Sprout\Events; | ||
|
||
/** | ||
* Service Override Registered Event | ||
* | ||
* This event is dispatched when a service override is registered with | ||
* Sprout. | ||
* | ||
* @package Overrides | ||
* | ||
* @method static self dispatch(string $override) | ||
* @method static self dispatchIf(bool $boolean, string $override) | ||
* @method static self dispatchUnless(bool $boolean, string $override) | ||
*/ | ||
final class ServiceOverrideRegistered extends ServiceOverrideEvent | ||
{ | ||
/** | ||
* @var class-string<\Sprout\Contracts\ServiceOverride> | ||
*/ | ||
public readonly string $override; | ||
|
||
/** | ||
* @param class-string<\Sprout\Contracts\ServiceOverride> $override | ||
*/ | ||
public function __construct(string $override) | ||
{ | ||
$this->override = $override; | ||
} | ||
} |