当前位置: 首页>>代码示例>>PHP>>正文


PHP ShellDispatcher::dispatch方法代码示例

本文整理汇总了PHP中ShellDispatcher::dispatch方法的典型用法代码示例。如果您正苦于以下问题:PHP ShellDispatcher::dispatch方法的具体用法?PHP ShellDispatcher::dispatch怎么用?PHP ShellDispatcher::dispatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ShellDispatcher的用法示例。


在下文中一共展示了ShellDispatcher::dispatch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ShellDispatcher

 function process_message($msg)
 {
     $msg_body = json_decode($msg->body, true);
     if (isset($msg_body['params']) && is_array($msg_body['params'])) {
         $msg_body['params'] = json_encode($msg_body['params']);
     }
     $msg_body = array_values($msg_body);
     $dispatcher = new ShellDispatcher($msg_body, false);
     try {
         $dispatcher->dispatch();
     } catch (Exception $e) {
         RabbitMQ::publish(json_decode($msg->body, true), ['exchange' => 'requeueable', 'queue' => 'requeueable_messages']);
         $newMessage[] = $msg->body;
         $newMessage[] = '==>';
         $newMessage[] = $e->getMessage();
         $newMessage[] = $e->getFile();
         $newMessage[] = $e->getLine();
         $newMessage[] = $e->getTraceAsString();
         $newMessage[] = $e->getCode();
         $newMessage[] = $e->getPrevious();
         RabbitMQ::publish($newMessage, ['exchange' => 'unprocessed', 'queue' => 'unprocessed_messages']);
         EmailSender::sendEmail('elisio.leonardo@gmail.com', $msg->body, $newMessage);
     }
     $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
     // Send a message with the string "quit" to cancel the consumer.
     if ($msg->body === 'quit') {
         $msg->delivery_info['channel']->basic_cancel($msg->delivery_info['consumer_tag']);
     }
 }
开发者ID:backstageel,项目名称:cakephp-rabbitmq,代码行数:29,代码来源:RabbitMQShell.php

示例2: run

/**
 * Run the dispatcher
 *
 * @param array $argv The argv from PHP
 * @return void
 */
	public static function run($argv) {
		$dispatcher = new ShellDispatcher($argv);
		$dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
	}
开发者ID:sherix88,项目名称:sigedu,代码行数:10,代码来源:ShellDispatcher.php

示例3: dispatchShell

 /**
  * Dispatch a command to another Shell. Similar to Object::requestAction()
  * but intended for running shells from other shells.
  *
  * ### Usage:
  *
  * With a string command:
  *
  *	`return $this->dispatchShell('schema create DbAcl');`
  *
  * Avoid using this form if you have string arguments, with spaces in them.
  * The dispatched will be invoked incorrectly. Only use this form for simple
  * command dispatching.
  *
  * With an array command:
  *
  * `return $this->dispatchShell('schema', 'create', 'i18n', '--dry');`
  *
  * @return mixed The return of the other shell.
  * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::dispatchShell
  */
 public function dispatchShell()
 {
     $args = func_get_args();
     if (is_string($args[0]) && count($args) === 1) {
         $args = explode(' ', $args[0]);
     }
     $Dispatcher = new ShellDispatcher($args, false);
     return $Dispatcher->dispatch();
 }
开发者ID:4Queen,项目名称:php-buildpack,代码行数:30,代码来源:Shell.php

示例4: run

 /**
  * Run the dispatcher
  *
  * @param array $argv The argv from PHP
  *
  * @return void
  */
 public static function run($argv)
 {
     $dispatcher = new ShellDispatcher($argv);
     return $dispatcher->_stop($dispatcher->dispatch() === FALSE ? 1 : 0);
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:12,代码来源:ShellDispatcher.php


注:本文中的ShellDispatcher::dispatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。