當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Module::runAction方法代碼示例

本文整理匯總了PHP中yii\base\Module::runAction方法的典型用法代碼示例。如果您正苦於以下問題:PHP Module::runAction方法的具體用法?PHP Module::runAction怎麽用?PHP Module::runAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\base\Module的用法示例。


在下文中一共展示了Module::runAction方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Run the job.
  * 
  * @param Job $job
  */
 public function run(Job $job)
 {
     \Yii::info('Running job', 'yii2queue');
     try {
         if ($job->isCallable()) {
             $retval = $job->runCallable();
         } else {
             $retval = $this->module->runAction($job->route, $job->data);
         }
     } catch (\Exception $e) {
         if ($job->isCallable()) {
             if (isset($job->header['signature']) && isset($job->header['signature']['route'])) {
                 $id = $job->id . " " . \yii\helpers\Json::encode($job->header['signature']['route']);
             } else {
                 $id = $job->id . ' callable';
             }
         } else {
             $id = $job->route;
         }
         \Yii::error("Fatal Error: Error running route '{$id}'. Message: {$e->getMessage()}", 'yii2queue');
         throw new \yii\base\Exception("Error running route '{$id}'. Message: {$e->getMessage()}. File: {$e->getFile()}[{$e->getLine()}]. Stack Trace: {$e->getTraceAsString()}", 500);
     }
     if ($retval !== false) {
         \Yii::info('Deleting job', 'yii2queue');
         $this->delete($job);
     }
 }
開發者ID:tajhulfaijin,項目名稱:yii2-queue,代碼行數:32,代碼來源:Queue.php

示例2: run

 /**
  * Run the job.
  * 
  * @param Job $job
  */
 public function run(Job $job)
 {
     \Yii::info('Running job', 'yii2queue');
     try {
         if ($job->isCallable()) {
             $retval = $job->runCallable();
         } else {
             $retval = $this->module->runAction($job->route, $job->data);
         }
     } catch (\Exception $e) {
         $route = $this->serialize($job);
         \Yii::error("Fatal Error: Error running route {$route}. Message: {$e->getMessage()}", 'yii2queue');
         throw new \yii\base\Exception("Error running route {$route}. Message: {$e->getMessage()}. File: {$e->getFile()}[{$e->getLine()}]. Stack Trace: {$e->getTraceAsString()}", 500);
     }
     if ($retval !== false) {
         \Yii::info('Deleting job', 'yii2queue');
         $this->delete($job);
     }
 }
開發者ID:vtsurka,項目名稱:yii2-queue,代碼行數:24,代碼來源:Queue.php

示例3: run

 /**
  * Runs a request specified in terms of a route.
  * The route can be either an ID of an action within this controller or a complete route consisting
  * of module IDs, controller ID and action ID. If the route starts with a slash '/', the parsing of
  * the route will start from the application; otherwise, it will start from the parent module of this controller.
  * @param string $route the route to be handled, e.g., 'view', 'comment/view', '/admin/comment/view'.
  * @param array $params the parameters to be passed to the action.
  * @return mixed the result of the action.
  * @see runAction()
  */
 public function run($route, $params = [])
 {
     $pos = strpos($route, '/');
     if ($pos === false) {
         return $this->runAction($route, $params);
     } elseif ($pos > 0) {
         return $this->module->runAction($route, $params);
     }
     return Yii::$app->runAction(ltrim($route, '/'), $params);
 }
開發者ID:bobxia,項目名稱:yii2,代碼行數:20,代碼來源:Controller.php

示例4: run

 /**
  * Run the job.
  *
  * @param Job $job The job to be executed.
  *
  * @return void
  * @throws \yii\base\Exception Exception.
  */
 public function run(Job $job)
 {
     $this->trigger(self::EVENT_BEFORE_RUN, $beforeEvent = new Event(['job' => $job]));
     if (!$beforeEvent->isValid) {
         return;
     }
     \Yii::info('Running job', 'yii2queue');
     try {
         if ($job->isCallable()) {
             $retval = $job->runCallable();
         } else {
             $retval = $this->module->runAction($job->route, $job->data);
         }
     } catch (\Exception $e) {
         if ($job->isCallable()) {
             if (isset($job->header['signature']) && isset($job->header['signature']['route'])) {
                 $id = $job->id . ' ' . \yii\helpers\Json::encode($job->header['signature']['route']);
             } else {
                 $id = $job->id . ' callable';
             }
         } else {
             $id = $job->route;
         }
         \Yii::error("Fatal Error: Error running route '{$id}'. Message: {$e->getMessage()}", 'yii2queue');
         if ($this->releaseOnFailure) {
             $this->release($job);
         }
         throw new \yii\base\Exception("Error running route '{$id}'. " . "Message: {$e->getMessage()}. " . "File: {$e->getFile()}[{$e->getLine()}]. Stack Trace: {$e->getTraceAsString()}", 500);
     }
     $this->trigger(self::EVENT_AFTER_RUN, new Event(['job' => $job, 'returnValue' => $retval]));
     if ($retval !== false) {
         \Yii::info('Deleting job', 'yii2queue');
         $this->delete($job);
     } else {
         if ($this->releaseOnFailure) {
             $this->release($job);
         }
     }
 }
開發者ID:voodoo-mobile,項目名稱:yii2-queue,代碼行數:47,代碼來源:Queue.php


注:本文中的yii\base\Module::runAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。