/**
  * @inheritdoc
  */
 public function setup(array $args = [])
 {
     $this->events->on('f.renderered', function () {
         $this->stack = new SplStack();
         $this->names = new SplStack();
         $this->factory->flush();
     });
     return;
 }
Beispiel #2
0
 /**
  * Used internally to keep engine status updated.
  * Using events is possible to keep in sync template flow with engine status without giving
  * to templates write access to Engine status.
  *
  * @access private
  */
 private function statusTransitions()
 {
     $this->status = self::STATUS_IN_LAYOUT;
     $this->events->on('f.template.layout', function () {
         if ($this->status & self::STATUS_IN_PARTIAL) {
             throw new LogicException('Is not possible to use $this->layout() in partials.');
         }
         $this->status = self::STATUS_IN_TEMPLATE;
     });
     $this->events->on('f.template.renderlayout', function () {
         $this->status = self::STATUS_IN_LAYOUT;
     });
     $this->events->on('f.template.prepartial', function () {
         $this->status |= self::STATUS_IN_PARTIAL;
     });
     $this->events->on('f.template.afterpartial', function () {
         $this->status ^= self::STATUS_IN_PARTIAL;
     });
     $this->events->on('f.template.renderered', function () {
         $this->stack()->pop();
         if ($this->stack()->count() === 0) {
             $this->status = self::STATUS_RENDERED | self::STATUS_IDLE;
             $this->events->fire('f.renderered', $this);
         }
     });
 }