public function getRequest() { if ($this->request) { return $this->request; } else { if ($this->parent) { return $this->parent->getRequest(); } else { return Pixifier::getInstance()->getPixie()->http_request(); } } }
/** * 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; }