本文整理匯總了PHP中Illuminate\Contracts\Bus\Dispatcher::mapUsing方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dispatcher::mapUsing方法的具體用法?PHP Dispatcher::mapUsing怎麽用?PHP Dispatcher::mapUsing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Contracts\Bus\Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::mapUsing方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: boot
public function boot(Dispatcher $dispatcher)
{
$dispatcher->mapUsing(function ($command) {
$command = str_replace('Commands\\', 'Commands\\Handlers\\', get_class($command));
return trim($command, '\\') . 'Handler@handle';
});
$this->registerMiddleware($this->app['router']);
$this->registerModuleResourceNamespaces();
$this->setLocalesConfigurations();
}
示例2: handle
/**
* Handle the command.
*/
public function handle(Dispatcher $bus)
{
/**
* Customize command to handler mapping.
*/
$bus->mapUsing(function ($command) {
/**
* If the command is self handling then
* return the handle method as defined
* by the interface.
*/
if ($command instanceof SelfHandling) {
return get_class($command) . '@handle';
}
// Handlers are in the same directory.
return get_class($command) . 'Handler@handle';
});
}