当前位置: 首页>>代码示例>>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;未经允许,请勿转载。