App.php
1 month ago
Artisan.php
1 month ago
Auth.php
1 month ago
Blade.php
1 month ago
Broadcast.php
1 month ago
Bus.php
1 month ago
Cache.php
1 month ago
Config.php
1 month ago
Cookie.php
1 month ago
Crypt.php
1 month ago
DB.php
1 month ago
Date.php
1 month ago
Event.php
1 month ago
Facade.php
1 month ago
File.php
1 month ago
Gate.php
1 month ago
Hash.php
1 month ago
Http.php
1 month ago
Lang.php
1 month ago
Log.php
1 month ago
Mail.php
1 month ago
Notification.php
1 month ago
ParallelTesting.php
1 month ago
Password.php
1 month ago
Queue.php
1 month ago
RateLimiter.php
1 month ago
Redirect.php
1 month ago
Redis.php
1 month ago
Request.php
1 month ago
Response.php
1 month ago
Route.php
1 month ago
Schema.php
1 month ago
Session.php
1 month ago
Storage.php
1 month ago
URL.php
1 month ago
Validator.php
1 month ago
View.php
1 month ago
Vite.php
1 month ago
Event.php
111 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWPSCOPED\Illuminate\Support\Facades; |
| 4 | |
| 5 | use IAWPSCOPED\Illuminate\Database\Eloquent\Model; |
| 6 | use IAWPSCOPED\Illuminate\Support\Testing\Fakes\EventFake; |
| 7 | /** |
| 8 | * @method static void listen(\Closure|string|array $events, \Closure|string|array|null $listener = null) |
| 9 | * @method static bool hasListeners(string $eventName) |
| 10 | * @method static bool hasWildcardListeners(string $eventName) |
| 11 | * @method static void push(string $event, object|array $payload = []) |
| 12 | * @method static void flush(string $event) |
| 13 | * @method static void subscribe(object|string $subscriber) |
| 14 | * @method static array|null until(string|object $event, mixed $payload = []) |
| 15 | * @method static array|null dispatch(string|object $event, mixed $payload = [], bool $halt = false) |
| 16 | * @method static array getListeners(string $eventName) |
| 17 | * @method static \Closure makeListener(\Closure|string|array $listener, bool $wildcard = false) |
| 18 | * @method static \Closure createClassListener(string $listener, bool $wildcard = false) |
| 19 | * @method static void forget(string $event) |
| 20 | * @method static void forgetPushed() |
| 21 | * @method static \Illuminate\Events\Dispatcher setQueueResolver(callable $resolver) |
| 22 | * @method static array getRawListeners() |
| 23 | * @method static void macro(string $name, object|callable $macro) |
| 24 | * @method static void mixin(object $mixin, bool $replace = true) |
| 25 | * @method static bool hasMacro(string $name) |
| 26 | * @method static void flushMacros() |
| 27 | * @method static \Illuminate\Support\Testing\Fakes\EventFake except(array|string $eventsToDispatch) |
| 28 | * @method static void assertListening(string $expectedEvent, string|array $expectedListener) |
| 29 | * @method static void assertDispatched(string|\Closure $event, callable|int|null $callback = null) |
| 30 | * @method static void assertDispatchedTimes(string $event, int $times = 1) |
| 31 | * @method static void assertNotDispatched(string|\Closure $event, callable|null $callback = null) |
| 32 | * @method static void assertNothingDispatched() |
| 33 | * @method static \Illuminate\Support\Collection dispatched(string $event, callable|null $callback = null) |
| 34 | * @method static bool hasDispatched(string $event) |
| 35 | * |
| 36 | * @see \Illuminate\Events\Dispatcher |
| 37 | * @see \Illuminate\Support\Testing\Fakes\EventFake |
| 38 | * @internal |
| 39 | */ |
| 40 | class Event extends Facade |
| 41 | { |
| 42 | /** |
| 43 | * Replace the bound instance with a fake. |
| 44 | * |
| 45 | * @param array|string $eventsToFake |
| 46 | * @return \Illuminate\Support\Testing\Fakes\EventFake |
| 47 | */ |
| 48 | public static function fake($eventsToFake = []) |
| 49 | { |
| 50 | static::swap($fake = new EventFake(static::getFacadeRoot(), $eventsToFake)); |
| 51 | Model::setEventDispatcher($fake); |
| 52 | Cache::refreshEventDispatcher(); |
| 53 | return $fake; |
| 54 | } |
| 55 | /** |
| 56 | * Replace the bound instance with a fake that fakes all events except the given events. |
| 57 | * |
| 58 | * @param string[]|string $eventsToAllow |
| 59 | * @return \Illuminate\Support\Testing\Fakes\EventFake |
| 60 | */ |
| 61 | public static function fakeExcept($eventsToAllow) |
| 62 | { |
| 63 | return static::fake([function ($eventName) use($eventsToAllow) { |
| 64 | return !\in_array($eventName, (array) $eventsToAllow); |
| 65 | }]); |
| 66 | } |
| 67 | /** |
| 68 | * Replace the bound instance with a fake during the given callable's execution. |
| 69 | * |
| 70 | * @param callable $callable |
| 71 | * @param array $eventsToFake |
| 72 | * @return mixed |
| 73 | */ |
| 74 | public static function fakeFor(callable $callable, array $eventsToFake = []) |
| 75 | { |
| 76 | $originalDispatcher = static::getFacadeRoot(); |
| 77 | static::fake($eventsToFake); |
| 78 | return \IAWPSCOPED\tap($callable(), function () use($originalDispatcher) { |
| 79 | static::swap($originalDispatcher); |
| 80 | Model::setEventDispatcher($originalDispatcher); |
| 81 | Cache::refreshEventDispatcher(); |
| 82 | }); |
| 83 | } |
| 84 | /** |
| 85 | * Replace the bound instance with a fake during the given callable's execution. |
| 86 | * |
| 87 | * @param callable $callable |
| 88 | * @param array $eventsToAllow |
| 89 | * @return mixed |
| 90 | */ |
| 91 | public static function fakeExceptFor(callable $callable, array $eventsToAllow = []) |
| 92 | { |
| 93 | $originalDispatcher = static::getFacadeRoot(); |
| 94 | static::fakeExcept($eventsToAllow); |
| 95 | return \IAWPSCOPED\tap($callable(), function () use($originalDispatcher) { |
| 96 | static::swap($originalDispatcher); |
| 97 | Model::setEventDispatcher($originalDispatcher); |
| 98 | Cache::refreshEventDispatcher(); |
| 99 | }); |
| 100 | } |
| 101 | /** |
| 102 | * Get the registered name of the component. |
| 103 | * |
| 104 | * @return string |
| 105 | */ |
| 106 | protected static function getFacadeAccessor() |
| 107 | { |
| 108 | return 'events'; |
| 109 | } |
| 110 | } |
| 111 |