in /home/articlebio.com/public_html/vendor/yiisoft/yii2/di/Container.php at line 507
{ if (isset($this->_reflections[$class])) { return [$this->_reflections[$class], $this->_dependencies[$class]]; } $dependencies = []; try { $reflection = new ReflectionClass($class); } catch (\ReflectionException $e) { throw new NotInstantiableException( $class, 'Failed to instantiate component or class "' . $class . '".', 0, $e ); } $constructor = $reflection->getConstructor(); if ($constructor !== null) {
* @return object the newly created instance of the specified class * @throws NotInstantiableException If resolved to an abstract class or an interface (since 2.0.9) */ protected function build($class, $params, $config) { /* @var $reflection ReflectionClass */ list($reflection, $dependencies) = $this->getDependencies($class); $addDependencies = []; if (isset($config['__construct()'])) { $addDependencies = $config['__construct()']; unset($config['__construct()']); }
$class = $class->id; } 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));
return static::$container->get($class, $params, $type); } if (isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } throw new InvalidConfigException('Object configuration must be an array containing a "class" or "__class" element.'); } private static $_logger;
if (isset($this->_definitions[$id])) { $definition = $this->_definitions[$id]; if (is_object($definition) && !$definition instanceof Closure) { return $this->_components[$id] = $definition; } return $this->_components[$id] = Yii::createObject($definition); } elseif ($throwException) { throw new InvalidConfigException("Unknown component ID: $id"); } return null; }
* Since version 2.0.13, if a component isn't defined in the module, it will be looked up in the parent module. * The parent module may be the application. */ public function get($id, $throwException = true) { if (!isset($this->module)) { return parent::get($id, $throwException); } $component = parent::get($id, false); if ($component === null) { $component = $this->module->get($id, $throwException); }
private function supportsFractionalSeconds() { // use cache to prevent opening MySQL connection // https://github.com/yiisoft/yii2/issues/13749#issuecomment-481657224 $key = [__METHOD__, $this->db->dsn]; $cache = null; $schemaCache = (\Yii::$app && is_string($this->db->schemaCache)) ? \Yii::$app->get($this->db->schemaCache, false) : $this->db->schemaCache; // If the `$schemaCache` is an instance of `DbCache` we don't use it to avoid a loop if ($this->db->enableSchemaCache && $schemaCache instanceof CacheInterface && !($schemaCache instanceof DbCache)) { $cache = $schemaCache; } $version = $cache ? $cache->get($key) : null; if (!$version) {
$map = [ Schema::TYPE_DATETIME => 'datetime', Schema::TYPE_TIMESTAMP => 'timestamp', Schema::TYPE_TIME => 'time', ]; if ($this->supportsFractionalSeconds()) { $map = [ Schema::TYPE_DATETIME => 'datetime(0)', Schema::TYPE_TIMESTAMP => 'timestamp(0)', Schema::TYPE_TIME => 'time(0)', ]; }
* {@inheritdoc} */ public function init() { parent::init(); $this->typeMap = array_merge($this->typeMap, $this->defaultTimeTypeMap()); } /** * {@inheritdoc} */ protected function defaultExpressionBuilders()
*/ 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 Connection $connection the database connection. * @param array $config name-value pairs that will be used to initialize the object properties */ public function __construct($connection, $config = []) { $this->db = $connection; parent::__construct($config); } /** * {@inheritdoc} */ public function init()
$dependencies = $this->resolveDependencies($dependencies, $reflection); if (!$reflection->isInstantiable()) { throw new NotInstantiableException($reflection->name); } if (empty($config)) { return $reflection->newInstanceArgs($dependencies); } $config = $this->resolveDependencies($config); if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten)
$class = $class->id; } 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); } if (is_callable($type, true)) { return static::$container->invoke($type, $params); }
/** * Creates a query builder for the MySQL database. * @return QueryBuilder query builder instance */ public function createQueryBuilder() { return Yii::createObject(QueryBuilder::className(), [$this->db]); } /** * Resolves the table name and schema name (if any). * @param TableSchema $table the table metadata object * @param string $name the table name
/** * @return QueryBuilder the query builder for this connection. */ public function getQueryBuilder() { if ($this->_builder === null) { $this->_builder = $this->createQueryBuilder(); } return $this->_builder; } /**
/** * Returns the query builder for the current DB connection. * @return QueryBuilder the query builder for the current DB connection. */ public function getQueryBuilder() { return $this->getSchema()->getQueryBuilder(); } /** * Can be used to set [[QueryBuilder]] configuration via Connection configuration array. * * @param array $value the [[QueryBuilder]] properties to be configured.
$modelClass = $this->modelClass; if ($db === null) { $db = $modelClass::getDb(); } if ($this->sql === null) { list($sql, $params) = $db->getQueryBuilder()->build($this); } else { $sql = $this->sql; $params = $this->params; } $command = $db->createCommand($sql, $params);
public function one($db = null) { if ($this->emulateExecution) { return false; } return $this->createCommand($db)->queryOne(); } /** * Returns the query result as a scalar value. * The value returned will be the first column in the first row of the query results. * @param Connection|null $db the database connection used to generate the SQL statement.
* @return ActiveRecord|array|null a single row of query result. Depending on the setting of [[asArray]], * the query result may be either an array or an ActiveRecord object. `null` will be returned * if the query results in nothing. */ public function one($db = null) { $row = parent::one($db); if ($row !== false) { $models = $this->populate([$row]); return reset($models) ?: null; } return null;
public function actionView($slug) { $publishedOn = date("Y-m-d H:i:s"); $data['page'] = new Page; $data['tag'] = Tag::find() ->where(['slug' => $slug]) ->one(); if(!isset($data['tag'])): throw new NotFoundHttpException('The requested page does not exist'); endif; if($slug == 'world-cup-2018'){
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$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); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ 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__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php'; $config = require __DIR__ . '/../config/web.php'; (new yii\web\Application($config))->run();
$_GET = [ 'slug' => 'georgeclooney', ];