yii\widgets\FragmentCache::run PHP Method

run() public method

Content displayed before this method call and after FragmentCache::init will be captured and saved in cache. This method does nothing if valid content is already found in cache.
public run ( )
    public function run()
    {
        if (($content = $this->getCachedContent()) !== false) {
            echo $content;
        } elseif ($this->cache instanceof Cache) {
            array_pop($this->getView()->cacheStack);
            $content = ob_get_clean();
            if ($content === false || $content === '') {
                return;
            }
            if (is_array($this->dependency)) {
                $this->dependency = Yii::createObject($this->dependency);
            }
            $data = [$content, $this->dynamicPlaceholders];
            $this->cache->set($this->calculateKey(), $data, $this->duration, $this->dependency);
            if (empty($this->getView()->cacheStack) && !empty($this->dynamicPlaceholders)) {
                $content = $this->updateDynamicContent($content, $this->dynamicPlaceholders);
            }
            echo $content;
        }
    }

Usage Example

 public function run()
 {
     if ($this->startedGathering === true) {
         $this->viewElementsGathener->endGathering();
     }
     parent::run();
 }