master

laravel/framework

Last updated at: 29/12/2023 09:21

Dispatcher.php

TLDR

This file is the contract for the Dispatcher class in the Illuminate\Contracts\Bus namespace. It defines several methods that can be implemented by the Dispatcher class.

Methods

dispatch

Dispatches a command to its appropriate handler.

dispatchSync

Dispatches a command to its appropriate handler in the current process. Queueable jobs will be dispatched to the "sync" queue.

dispatchNow

Dispatches a command to its appropriate handler in the current process.

hasCommandHandler

Determines if the given command has a handler.

getCommandHandler

Retrieves the handler for a command.

pipeThrough

Sets the pipes commands should be piped through before dispatching.

map

Maps a command to a handler.

END

<?php

namespace Illuminate\Contracts\Bus;

interface Dispatcher
{
    /**
     * Dispatch a command to its appropriate handler.
     *
     * @param  mixed  $command
     * @return mixed
     */
    public function dispatch($command);

    /**
     * Dispatch a command to its appropriate handler in the current process.
     *
     * Queueable jobs will be dispatched to the "sync" queue.
     *
     * @param  mixed  $command
     * @param  mixed  $handler
     * @return mixed
     */
    public function dispatchSync($command, $handler = null);

    /**
     * Dispatch a command to its appropriate handler in the current process.
     *
     * @param  mixed  $command
     * @param  mixed  $handler
     * @return mixed
     */
    public function dispatchNow($command, $handler = null);

    /**
     * Determine if the given command has a handler.
     *
     * @param  mixed  $command
     * @return bool
     */
    public function hasCommandHandler($command);

    /**
     * Retrieve the handler for a command.
     *
     * @param  mixed  $command
     * @return bool|mixed
     */
    public function getCommandHandler($command);

    /**
     * Set the pipes commands should be piped through before dispatching.
     *
     * @param  array  $pipes
     * @return $this
     */
    public function pipeThrough(array $pipes);

    /**
     * Map a command to a handler.
     *
     * @param  array  $map
     * @return $this
     */
    public function map(array $map);
}