當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。