Вход Регистрация
Файл: system/vendor/illuminate/support/Facades/Event.php
Строк: 104
<?php

namespace IlluminateSupportFacades;

use 
IlluminateDatabaseEloquentModel;
use 
IlluminateSupportTestingFakesEventFake;

/**
 * @method static void listen(string|array $events, Closure|string $listener)
 * @method static bool hasListeners(string $eventName)
 * @method static void push(string $event, array $payload = [])
 * @method static void flush(string $event)
 * @method static void subscribe(object|string $subscriber)
 * @method static array|null until(string|object $event, mixed $payload = [])
 * @method static array|null dispatch(string|object $event, mixed $payload = [], bool $halt = false)
 * @method static array getListeners(string $eventName)
 * @method static Closure makeListener(Closure|string $listener, bool $wildcard = false)
 * @method static Closure createClassListener(string $listener, bool $wildcard = false)
 * @method static void forget(string $event)
 * @method static void forgetPushed()
 * @method static IlluminateEventsDispatcher setQueueResolver(callable $resolver)
 * @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)
 *
 * @see IlluminateEventsDispatcher
 */
class Event extends Facade
{
    
/**
     * Replace the bound instance with a fake.
     *
     * @param  array|string  $eventsToFake
     * @return IlluminateSupportTestingFakesEventFake
     */
    
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';
    }
}
Онлайн: 0
Реклама