Ejemplo n.º 1
0
 public function getRequest()
 {
     if ($this->request) {
         return $this->request;
     } else {
         if ($this->parent) {
             return $this->parent->getRequest();
         } else {
             return Pixifier::getInstance()->getPixie()->http_request();
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Dive into child context.
  *
  * @param $childName
  * @param bool $createIfNotExists
  * @return $this
  * @throws \Exception
  */
 public function goDown($childName, $createIfNotExists = true)
 {
     $context = $this->currentContext ?: $this->rootContext;
     $target = $context->getChildByName($childName);
     if ($target) {
         $this->currentContext = $target;
         $this->level++;
     } else {
         if ($createIfNotExists) {
             $target = new Context($childName);
             $this->currentContext->addChild($target);
             $target->setRequest($this->currentContext->getRequest());
             $this->currentContext = $target;
         } else {
             throw new \RuntimeException("No such context: \"{$childName}\"");
         }
     }
     return $this;
 }