yii\widgets\FragmentCache::init PHP Method

init() public method

Initializes the FragmentCache object.
public init ( )
    public function init()
    {
        parent::init();
        $this->cache = $this->enabled ? Instance::ensure($this->cache, Cache::className()) : null;
        if ($this->cache instanceof Cache && $this->getCachedContent() === false) {
            $this->getView()->cacheStack[] = $this;
            ob_start();
            ob_implicit_flush(false);
        }
    }

Usage Example

 public function init()
 {
     parent::init();
     if ($this->viewElementsGathener === null) {
         throw new InvalidConfigException('ViewElementsGathener should be set');
     }
     if (is_string($this->viewElementsGathener)) {
         $this->viewElementsGathener = Yii::$app->get($this->viewElementsGathener);
     }
 }