* @param string $key the key identifying the value to be cached * @param mixed $value the value to be cached. * @see [Memcache::set()](https://secure.php.net/manual/en/memcache.set.php) * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. * @return bool true if the value is successfully stored into cache, false otherwise */ protected function setValue($key, $value, $duration) { $expire = $this->normalizeDuration($duration); return $this->useMemcached ? $this->_cache->set($key, $value, $expire) : $this->_cache->set($key, $value, 0, $expire); } /** * Stores multiple key-value pairs in cache. * @param array $data array where key corresponds to cache key while value is the value stored * @param int $duration the number of seconds in which the cached values will expire. 0 means never expire. * @return array array of failed keys. */ protected function setValues($data, $duration)
* @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. * @return bool true if the value is successfully stored into cache, false otherwise */ protected function setValue($key, $value, $duration) { $expire = $this->normalizeDuration($duration); return $this->useMemcached ? $this->_cache->set($key, $value, $expire) : $this->_cache->set($key, $value, 0, $expire); } /** * Stores multiple key-value pairs in cache. * @param array $data array where key corresponds to cache key while value is the value stored * @param int $duration the number of seconds in which the cached values will expire. 0 means never expire.
$value = serialize([$value, $dependency]); } elseif ($this->serializer !== false) { $value = call_user_func($this->serializer[0], [$value, $dependency]); } $key = $this->buildKey($key); return $this->setValue($key, $value, $duration); } /** * Stores multiple items in cache. Each item contains a value identified by a key. * If the cache already contains such a key, the existing value and * expiration time will be replaced with the new ones, respectively.
} else { if (sizeOf($aModifiedRelations) > 0) { foreach ($aModifiedRelations as $name) if (isset($this->_related[$name])) { // \Yii::trace($this->getCacheId() . '.saveRelationToCache(' . $name . ')'); $oCachedRecord->setRelation($name, $this->_related[$name]); } \Yii::$app->cache->set($key, $oCachedRecord); } } } /** * Name des Attributs, in dem variable Attribute json-serialisiert gespeichert sind.
* @param string $name Name der geladenen Relation */ protected function afterLoadRelation($name) { $this->_modifiedRelations[] = $name; $this->saveToCache(); $this->saveRelationsToCache(); } /** * Liefert den Inhalt eines variablen Attributs. * @param string $name * @return mixed
unset($this->_relatedPks[$name]); return $this->_related[$name]; } else { $bRelationLoaded = isset($this->_related[$name]); $value = parent::__get($name); if (!$bRelationLoaded && isset($this->_related[$name])) { $this->afterLoadRelation($name); } return $value; } } /**
if (sizeOf($this->aColumns) == 0) { $oSectionType = SectionType::findByPk($this->TypeID); if ($oSectionType === null) { throw new \Exception("Section[" . $this->ID . "].initColumns() Unknown SectionType=" . $this->TypeID); } foreach ($oSectionType->sectioncolumntypes as $oSectionColumnType) { $oColumnType = ColumnType::findByPk($oSectionColumnType->ColumnTypeID); if ($oColumnType !== null) { $this->aColumns[] = new \Additor\models\Column($this, sizeOf($this->aColumns), $oColumnType); } } } else {
} public function afterFind() { parent::afterFind(); $this->initColumns(); } /** * Returns the name of the column that stores the lock version for implementing optimistic locking. * * Optimistic locking allows multiple users to access the same record for edits and avoids potential conflicts.
if ($this->inverseOf !== null) { $this->addInverseRelations($models); } if (!$this->asArray) { foreach ($models as $model) { $model->afterFind(); } } return parent::populate($models); }
$cClass = $modelClass::getClassNameFromRow($row); $cCacheID = $cClass::getCacheIdFromPk($cClass::getPrimaryKeyFromRow($row)); $oModel = $cClass::findByCacheId($cCacheID); if ($oModel) { $aModels[$i] = $oModel; } else { $aModels[$i] = parent::populate([$row])[0]; \Yii::trace('ActiveQuery.populate() ' . $cCacheID . ' load from Db.'); } } return $aModels; } }
public function all($db = null) { if ($this->emulateExecution) { return []; } $rows = $this->createCommand($db)->queryAll(); return $this->populate($rows); } /** * Converts the raw query results into the format as specified by this query. * This method is internally used to convert the data fetched from database * into the format as required by this query.
* @param Connection $db the DB connection used to create the DB command. * If null, the DB connection returned by [[modelClass]] will be used. * @return array|ActiveRecord[] the query results. If the query results in nothing, an empty array will be returned. */ public function all($db = null) { return parent::all($db); } /** * {@inheritdoc} */ public function prepare($builder)
* bzw. diesen zu füllen. Ist über den Aufruf von lang() eine Sprache festgelegt worden, * wird für einen MultiLangActiveRecord der entsprechende LangActiveRecord geliefert. * @param \yi\db\Connection $db Optional Angabe der Datenbank * @return array|\yii\db\ActiveRecord[] */ public function all ($db = null){ $aRecords = parent::all($db); if (sizeOf($aRecords) > 0) { if (!$this->asArray) { foreach ($aRecords AS $i => $oRecord) { $cCacheID = $oRecord->getCacheId(); if (\Yii::$app->ARcache->exists($cCacheID)) { $aRecords[$i] = \Yii::$app->ARcache->get($cCacheID);
$realName = lcfirst(substr($method->getName(), 3)); if ($realName !== $name) { throw new InvalidArgumentException('Relation names are case sensitive. ' . get_class($model) . " has a relation named \"$realName\" instead of \"$name\"."); } } return $this->multiple ? $this->all() : $this->one(); } /** * If applicable, populate the query's primary model into the related records' inverse relationship. * @param array $result the array of related records as generated by [[populate()]] * @since 2.0.9
if (isset($this->_related[$name]) || array_key_exists($name, $this->_related)) { return $this->_related[$name]; } $value = parent::__get($name); if ($value instanceof ActiveQueryInterface) { $this->setRelationDependencies($name, $value); return $this->_related[$name] = $value->findFor($name, $this); } return $value; } /**
$class = $activeQuery->modelClass; $this->_related[$name] = $class::findByPk($this->_relatedPks[$name]); unset($this->_relatedPks[$name]); return $this->_related[$name]; } else { $bRelationLoaded = isset($this->_related[$name]); $value = parent::__get($name); if (!$bRelationLoaded && isset($this->_related[$name])) { $this->afterLoadRelation($name); } return $value; } }
*/ protected function initLangDict($bForce = false) { // Relation "lang" laden, alles weitere geschieht in afterLoadRelation() if ($bForce || sizeof($this->_langDict) == 0) { foreach ($this->allLanguages as $oLang) { $this->_langDict[$oLang->LangCode] = $oLang; } } }
{ if ($cLangCode == "" || $cLangCode == self::LANG_CURRENT_CONTENT) { $cLangCode = \Yii::$app->request->getLangCode(); } if (!isset($this->_langDict[$cLangCode])) { $this->initLangDict(); // Sprache nicht gefunden? if (!isset($this->_langDict[$cLangCode])) { // Neuen LangActiveRecord erzeugen $cClass = static::langClassName(); $oLang = new $cClass;
if ($ARs[$i] instanceof \Additor\components\db\MultiLangActiveRecord) { $cClass = get_class($ARs[$i]); if ($cClass::$_usesUserBackendLanguage) $cCode = \Yii::$app->user->getBackendLangCode(); else $cCode = $cLangCode; $ARs[$i] = $ARs[$i]->getLang($cCode); } } if (!$bIsArray) { $ARs = $ARs[0]; } }
$this->_aMultiLangAttributeNames[] = $name; } } if ((is_object($value) && $value instanceof \Additor\components\db\MultiLangActiveRecord) || (is_array($value) && isset($value[0]) && $value[0] instanceof \Additor\components\db\ActiveRecord) ) { $value = $this->convertLang($value, $this->LangCode); } } return $value; }
return $aControllers; } public function beforeRender() { foreach ($this->sections as $oSection) { $oSection->beforeRender(); } } public function createMissingAutoGeneratedEntries($aReadAccessUsergroupIDs = [\Additor\models\Usergroup::ID_ANONYMOUS]) {
} public function actionView() { \Yii::$app->user->setLastVisitedPage($this->oPage); $this->oPage->beforeRender(); if (sizeOf($_REQUEST) > 0) { $bIsAjax = \Yii::$app->request->getIsAjax() && isset($_REQUEST['ajax']); $aElemControllers = $this->oPage->getControllers(); foreach ($aElemControllers as $oElemController) { if ($oElemController->applyRequestData()) {
$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) {
$pathInfo = $request->getPathInfo(); $request->parseVirtualFolders($pathInfo); // Prüfen, ob die gleiche URL bereits angefragt wurde und 404 oder 301 als Ergebnis hatte. // Bei 404 wird in der \yii\web\Application::$catchAll gesetzt und in parent::handleRequest() behandelt. $request->checkFailedRequest($pathInfo); return parent::handleRequest($request); } public function disableLogging(){ foreach (\Yii::$app->log->targets as $cKey => $oLogTarget) { $oLogTarget->enabled = false; };
{ 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();
$application = new \Additor\components\console\Application($env); } else { $env = \Additor\Modules::createEnvironment("web"); $application = new \Additor\components\web\Application($env); } $exitCode = $application->run(); exit($exitCode);
<?php require "protected/yii.php";
$_GET = [ 'PageID' => 1339, ]; $_SESSION = [ '__flash' => [], 'EditMode' => false, 'ImpersonatedUserID' => 0, 'ImpersonatedGroupID' => 0, 'LastVisitedPageIDs' => [ 1339, ], 'LastModifiedPageIDs' => [], 'LastSelectedPageIDs' => [], 'LastSelectedUserOrGroupsCodes' => [], 'CreateEntryTypes' => [], 'EditEntryTypes' => [], 'ExtraUsergroupIDs' => [], 'IsIntranet' => false, 'DEBUG' => [], 'WATCH' => [], ];