/** * Controller is the base class of web controllers. * * @author Qiang Xue <qiang.xue@gmail.com> * @since 2.0 */ class Controller extends \yii\base\Controller { public function init() { Yii::$app->language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); } /** * @var boolean whether to enable CSRF validation for the actions in this controller. * CSRF validation is enabled only when both this property and [[Request::enableCsrfValidation]] are true. */ public $enableCsrfValidation = true; /**
* @author Qiang Xue <qiang.xue@gmail.com> * @since 2.0 */ class Controller extends \yii\base\Controller { public function init() { Yii::$app->language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); } /** * @var boolean whether to enable CSRF validation for the actions in this controller. * CSRF validation is enabled only when both this property and [[Request::enableCsrfValidation]] are true.
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
* @param array $config name-value pairs that will be used to initialize the object properties. */ public function __construct($id, $module, $config = []) { $this->id = $id; $this->module = $module; parent::__construct($config); } /** * Declares external actions for the controller. * This method is meant to be overwritten to declare external actions for the controller. * It should return an array, with array keys being action IDs, and array values the corresponding
foreach ($params as $index => $param) { $dependencies[$index] = $param; } $dependencies = $this->resolveDependencies($dependencies, $reflection); if (empty($config)) { return $reflection->newInstanceArgs($dependencies); } if (!empty($dependencies) && is_a($class, 'yii\base\Object', true)) { // set $config as the last parameter (existing one will be overwritten) $dependencies[count($dependencies) - 1] = $config; return $reflection->newInstanceArgs($dependencies);
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
* @throws InvalidConfigException if the configuration is invalid. * @see \yii\di\Container */ public static function createObject($type, array $params = []) { if (is_string($type)) { return static::$container->get($type, $params); } elseif (is_array($type) && isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } elseif (is_callable($type, true)) { return call_user_func($type, $params);
$className = ltrim($this->controllerNamespace . '\\' . str_replace('/', '\\', $prefix) . $className, '\\'); if (strpos($className, '-') !== false || !class_exists($className)) { return null; } if (is_subclass_of($className, 'yii\base\Controller')) { return Yii::createObject($className, [$id, $this]); } elseif (YII_DEBUG) { throw new InvalidConfigException("Controller class must extend from \\yii\\base\\Controller."); } else { return null; } }
if (($pos = strrpos($route, '/')) !== false) { $id .= '/' . substr($route, 0, $pos); $route = substr($route, $pos + 1); } $controller = $this->createControllerByID($id); if ($controller === null && $route !== '') { $controller = $this->createControllerByID($id . '/' . $route); $route = ''; } return $controller === null ? false : [$controller, $route];
if (isset($this->controllerMap[$id])) { $controller = Yii::createObject($this->controllerMap[$id], [$id, $this]); return [$controller, $route]; } $module = $this->getModule($id); if ($module !== null) { return $module->createController($route); } if (($pos = strrpos($route, '/')) !== false) { $id .= '/' . substr($route, 0, $pos); $route = substr($route, $pos + 1); }
* @param array $params the parameters to be passed to the action * @return mixed the result of the action. * @throws InvalidRouteException if the requested route cannot be resolved into an action successfully */ public function runAction($route, $params = []) { $parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params);
$route = $this->catchAll[0]; $params = array_splice($this->catchAll, 1); } try { Yii::trace("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } else { $response = $this->getResponse(); if ($result !== null) { $response->data = $result;
try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
require(__DIR__ . '/../../common/config/main-local.php'), require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main-local.php') ); $application = new yii\web\Application($config); $application->run();
$_GET = [ 'areaSlug' => 'santa-cruz-hochland', 'lodgeSlug' => 'pikaia-lodge', ]; $_SERVER = [ 'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'PHP_FCGI_MAX_REQUESTS' => '32000', 'USER' => 'plawjygs', 'GROUP' => 'plawjygs', 'HOME' => '/home/plawjygs', 'ORIG_SCRIPT_NAME' => '/fastcgist/php5.6', 'ORIG_PATH_TRANSLATED' => '/home/plawjygs/www.planeta-verde.de/v2.0/frontend/web/index.php', 'ORIG_PATH_INFO' => '/frontend/web/index.php', 'ORIG_SCRIPT_FILENAME' => '/usr/local/fastcgi-starter/php5.6', 'HTTP_CONNECTION' => 'close', 'SCRIPT_NAME' => '/frontend/web/index.php', 'REQUEST_URI' => '/reiseziele/santa-cruz-hochland/lodge/pikaia-lodge', 'QUERY_STRING' => '', 'REQUEST_METHOD' => 'GET', 'SERVER_PROTOCOL' => 'HTTP/2.0', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'REDIRECT_URL' => '/frontend/web/index.php', 'REMOTE_PORT' => '45268', 'SCRIPT_FILENAME' => '/home/plawjygs/www.planeta-verde.de/v2.0/frontend/web/index.php', 'SERVER_ADMIN' => '[no address given]', 'CONTEXT_DOCUMENT_ROOT' => '/usr/local/fastcgi-starter/', 'CONTEXT_PREFIX' => '/fastcgist/', 'REQUEST_SCHEME' => 'https', 'DOCUMENT_ROOT' => '/home/plawjygs/www.planeta-verde.de/v2.0/', 'REMOTE_ADDR' => '18.234.154.197', 'REMOTE_HOST' => 'ec2-18-234-154-197.compute-1.amazonaws.com', 'SERVER_PORT' => '443', 'SERVER_ADDR' => '77.75.251.119', 'SERVER_NAME' => 'www.planeta-verde.de', 'SERVER_SOFTWARE' => 'Apache', 'SERVER_SIGNATURE' => '', 'HTTP_HOST' => 'www.planeta-verde.de', 'HTTP_USER_AGENT' => 'claudebot', 'HTTP_ACCEPT' => '*/*', 'H2_STREAM_TAG' => '3915490-21743-5', 'H2_STREAM_ID' => '5', 'H2_PUSHED_ON' => '', 'H2_PUSHED' => '', 'H2_PUSH' => 'off', 'H2PUSH' => 'off', 'HTTP2' => 'on', 'SSL_TLS_SNI' => 'www.planeta-verde.de', 'HTTPS' => 'on', 'REDIRECT_STATUS' => '200', 'REDIRECT_HANDLER' => 'php-fastcgi5.6', 'REDIRECT_H2_STREAM_TAG' => '3915490-21743-5', 'REDIRECT_H2_STREAM_ID' => '5', 'REDIRECT_H2_PUSHED_ON' => '', 'REDIRECT_H2_PUSHED' => '', 'REDIRECT_H2_PUSH' => 'off', 'REDIRECT_H2PUSH' => 'off', 'REDIRECT_HTTP2' => 'on', 'REDIRECT_SSL_TLS_SNI' => 'www.planeta-verde.de', 'REDIRECT_HTTPS' => 'on', 'REDIRECT_REDIRECT_STATUS' => '200', 'REDIRECT_REDIRECT_H2_STREAM_TAG' => '3915490-21743-5', 'REDIRECT_REDIRECT_H2_STREAM_ID' => '5', 'REDIRECT_REDIRECT_H2_PUSHED_ON' => '', 'REDIRECT_REDIRECT_H2_PUSHED' => '', 'REDIRECT_REDIRECT_H2_PUSH' => 'off', 'REDIRECT_REDIRECT_H2PUSH' => 'off', 'REDIRECT_REDIRECT_HTTP2' => 'on', 'REDIRECT_REDIRECT_SSL_TLS_SNI' => 'www.planeta-verde.de', 'REDIRECT_REDIRECT_HTTPS' => 'on', 'REDIRECT_REDIRECT_REDIRECT_STATUS' => '200', 'REDIRECT_REDIRECT_REDIRECT_H2_STREAM_TAG' => '3915490-21743-5', 'REDIRECT_REDIRECT_REDIRECT_H2_STREAM_ID' => '5', 'REDIRECT_REDIRECT_REDIRECT_H2_PUSHED_ON' => '', 'REDIRECT_REDIRECT_REDIRECT_H2_PUSHED' => '', 'REDIRECT_REDIRECT_REDIRECT_H2_PUSH' => 'off', 'REDIRECT_REDIRECT_REDIRECT_H2PUSH' => 'off', 'REDIRECT_REDIRECT_REDIRECT_HTTP2' => 'on', 'REDIRECT_REDIRECT_REDIRECT_SSL_TLS_SNI' => 'www.planeta-verde.de', 'REDIRECT_REDIRECT_REDIRECT_HTTPS' => 'on', 'FCGI_ROLE' => 'RESPONDER', 'PHP_SELF' => '/frontend/web/index.php', 'REQUEST_TIME_FLOAT' => 1711711502.1387551, 'REQUEST_TIME' => 1711711502, ];