thamtech /
yii2-scheduler
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @copyright Copyright(c) 2016 Webtools Ltd |
||
| 4 | * @copyright Copyright(c) 2018 Thamtech, LLC |
||
| 5 | * @link https://github.com/thamtech/yii2-scheduler |
||
| 6 | * @license https://opensource.org/licenses/MIT |
||
| 7 | **/ |
||
| 8 | |||
| 9 | namespace thamtech\scheduler\actions; |
||
| 10 | |||
| 11 | use Yii; |
||
| 12 | use yii\base\Action; |
||
| 13 | use thamtech\scheduler\models\SchedulerLog; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * View a log entry. |
||
| 17 | */ |
||
| 18 | class ViewLogAction extends Action |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var string the view file to be rendered. If not set, it will take the value of [[id]]. |
||
| 22 | * That means, if you name the action as "index" in "SchedulerController", then the view name |
||
| 23 | * would be "index", and the corresponding view file would be "views/scheduler/index.php". |
||
| 24 | */ |
||
| 25 | public $view; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Runs the action |
||
| 29 | * |
||
| 30 | * @return string result content |
||
| 31 | */ |
||
| 32 | public function run($id) |
||
| 33 | { |
||
| 34 | $model = SchedulerLog::findOne($id); |
||
| 35 | |||
| 36 | if (!$model) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 37 | throw new \yii\web\HttpException(404, 'The requested page does not exist.'); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $this->controller->render($this->view ?: $this->id, [ |
||
| 41 | 'model' => $model, |
||
| 42 | ]); |
||
| 43 | } |
||
| 44 | } |
||
| 45 |