Illuminate\Bus\Dispatcher::simpleMapping PHP Method

simpleMapping() public static method

Map the command to a handler within a given root namespace.
public static simpleMapping ( mixed $command, string $commandNamespace, string $handlerNamespace ) : string
$command mixed
$commandNamespace string
$handlerNamespace string
return string
    public static function simpleMapping($command, $commandNamespace, $handlerNamespace)
    {
        $command = str_replace($commandNamespace, '', get_class($command));
        return $handlerNamespace . '\\' . trim($command, '\\') . 'Handler@handle';
    }

Usage Example

Example #1
0
 /**
  * Bootstrap any application services.
  *
  * @param  \Illuminate\Bus\Dispatcher  $dispatcher
  * @return void
  */
 public function boot(Dispatcher $dispatcher)
 {
     $dispatcher->pipeThrough([CommandValidationPipe::class]);
     $dispatcher->mapUsing(function ($command) {
         return Dispatcher::simpleMapping($command, 'App\\Commands', 'App\\Handlers\\Commands');
     });
 }
All Usage Examples Of Illuminate\Bus\Dispatcher::simpleMapping