yii\widgets\FragmentCache::getCachedContent PHP Метод

getCachedContent() публичный Метод

Returns the cached content if available.
public getCachedContent ( ) : string | false
Результат string | false the cached content. False is returned if valid content is not found in the cache.
    public function getCachedContent()
    {
        if ($this->_content === null) {
            $this->_content = false;
            if ($this->cache instanceof Cache) {
                $key = $this->calculateKey();
                $data = $this->cache->get($key);
                if (is_array($data) && count($data) === 2) {
                    list($content, $placeholders) = $data;
                    if (is_array($placeholders) && count($placeholders) > 0) {
                        if (empty($this->getView()->cacheStack)) {
                            // outermost cache: replace placeholder with dynamic content
                            $content = $this->updateDynamicContent($content, $placeholders);
                        }
                        foreach ($placeholders as $name => $statements) {
                            $this->getView()->addDynamicPlaceholder($name, $statements);
                        }
                    }
                    $this->_content = $content;
                }
            }
        }
        return $this->_content;
    }

Usage Example

Пример #1
0
 public function getCachedContent()
 {
     if ($this->cachedData === null) {
         $cachedData = $this->viewElementsGathener->getCachedData($this->getId());
         if ($cachedData === false) {
             $this->cachedData = false;
             return false;
         }
         $this->viewElementsGathener->repeatGatheredData($this->view, $cachedData);
         $this->cachedData = parent::getCachedContent();
     }
     return $this->cachedData;
 }