public function resolve() { list($route, $params) = parent::resolve(); if (!empty($params)) { foreach ($params as $name => $param) { if ($name === Application::OPTION_APPHOST) { unset($params[$name]); break; } } } return [$route, $params]; }
/** * Handles the specified request. * @param Request $request the request to be handled * @return Response the resulting response */ public function handleRequest($request) { list($route, $params) = $request->resolve(); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } else { $response = $this->getResponse(); $response->exitStatus = $result; return $response; } }
protected function _runCommand($single) { if (!$single->next_run || $single->next_run == null) { $this->log('Next run date for command not found. Skipping.'); return false; } $nextRunDate = new \DateTime($single->next_run); $currentDate = new \DateTime('NOW'); if ($currentDate > $nextRunDate) { $this->log('Next run date for command is before current date. Running.'); if (!$single->begin()) { $this->warning('Schedule begin method failed.'); } try { $argvDefault = ['yii']; $argvCommand = explode(' ', $single->command); $_SERVER['argv'] = array_merge($argvDefault, $argvCommand); $request = new Request(); list($route, $params) = $request->resolve(); $this->log('Calling runAction for command ' . $route . ' with args ' . print_r($params, true) . '.'); \Yii::$app->runAction($route, $params); } catch (ErrorException $e) { $this->warning("Running command encountered an error.\n" . $e->getMessage()); } if (!$single->end()) { $this->warning('Schedule end method failed.'); } return true; } else { $this->log('Next run date for command is after current date. Skipping.'); return false; } }
public function setParams($params) { parent::setParams($params); $this->_args = $params; }