Blame view
public/vendor/illuminate/support/Facades/Event.php
2.53 KB
86143e36f Коммит вторник |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
<?php namespace Illuminate\Support\Facades; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Testing\Fakes\EventFake; /** * @method static \Closure createClassListener(string $listener, bool $wildcard = false) * @method static \Closure makeListener(\Closure|string $listener, bool $wildcard = false) * @method static \Illuminate\Events\Dispatcher setQueueResolver(callable $resolver) * @method static array getListeners(string $eventName) * @method static array|null dispatch(string|object $event, mixed $payload = [], bool $halt = false) * @method static array|null until(string|object $event, mixed $payload = []) * @method static bool hasListeners(string $eventName) * @method static void assertDispatched(string $event, callable|int $callback = null) * @method static void assertDispatchedTimes(string $event, int $times = 1) * @method static void assertNotDispatched(string $event, callable|int $callback = null) * @method static void flush(string $event) * @method static void forget(string $event) * @method static void forgetPushed() * @method static void listen(string|array $events, \Closure|string $listener) * @method static void push(string $event, array $payload = []) * @method static void subscribe(object|string $subscriber) * * @see \Illuminate\Events\Dispatcher */ class Event extends Facade { /** * Replace the bound instance with a fake. * * @param array|string $eventsToFake * @return \Illuminate\Support\Testing\Fakes\EventFake */ public static function fake($eventsToFake = []) { static::swap($fake = new EventFake(static::getFacadeRoot(), $eventsToFake)); Model::setEventDispatcher($fake); Cache::refreshEventDispatcher(); return $fake; } /** * Replace the bound instance with a fake during the given callable's execution. * * @param callable $callable * @param array $eventsToFake * @return callable */ public static function fakeFor(callable $callable, array $eventsToFake = []) { $originalDispatcher = static::getFacadeRoot(); static::fake($eventsToFake); return tap($callable(), function () use ($originalDispatcher) { static::swap($originalDispatcher); Model::setEventDispatcher($originalDispatcher); Cache::refreshEventDispatcher(); }); } /** * Get the registered name of the component. * * @return string */ protected static function getFacadeAccessor() { return 'events'; } } |