/** * Send the api result to the client * * @param array $result */ public function sendResponse($result) { if (!$this->framework->getRequest() instanceof WebRequest) { return; } return $this->restHelper->sendResponse($this->framework->getRequest(), $this->framework->getResponse(), $result); }
/** * Searches a renderer for the given template file and renders the * file. * * @access protected * @param string $templateFile * @param array $additionalData * @return string */ protected function searchRendererAndRenderTemplate($templateFile, $additionalData = array()) { // Get the file information for the template file $fileInfo = pathinfo($templateFile); $extension = $fileInfo['extension']; // If we haven't a renderer for this extension we return an // empty string to prevent everything from failing. if (!isset($this->renderer[$extension])) { return ''; } // Take the renderer... $renderer = $this->renderer[$extension]; // ...and render the template file. return $renderer->renderTemplateFile($templateFile, $this->framework, $this->framework->getRequest(), $this->framework->getResponse(), $additionalData); }
/** * Returns the instance for the given class if the class path * starts with Zepi\Turbo. * * @param \ReflectionClass $parameterClass * @return object */ protected function getFrameworkInstance(ReflectionClass $parameterClass) { if ($parameterClass->name == 'Zepi\\Turbo\\Framework') { return $this->framework; } if ($parameterClass->name == 'Zepi\\Turbo\\Request\\RequestAbstract') { return $this->framework->getRequest(); } if ($parameterClass->name == 'Zepi\\Turbo\\Response\\Response') { return $this->framework->getResponse(); } if ($parameterClass->getNamespaceName() === 'Zepi\\Turbo\\Manager') { return $this->getFrameworkManager($parameterClass->name); } }
/** * Iterates trough an array and searches the needed menu entry. * If found, return the menu entry, otherwise return false. * * @access protected * @param array $menuEntries * @return false|\Zepi\Web\General\Entity\MenuEntry */ protected function searchCorrectMenuEntryInArray($menuEntries) { foreach ($menuEntries as $key => $menuEntry) { if (trim($menuEntry->getTarget(), '/') === trim($this->framework->getRequest()->getRoute(), '/')) { return $menuEntry; } if ($menuEntry->hasChildren()) { $menuEntry = $this->searchCorrectMenuEntryInArray($menuEntry->getChildren()); if ($menuEntry !== false) { return $menuEntry; } } } return false; }
/** * Executes the given event handlers. Every event handler will * be initialized and executed. * * @access protected * @param string $type * @param string $name * @param mixed $value * @return mixed */ protected function executeItems($type, $name, $value = null) { if (!isset($this->handlers[$type][$name])) { return $value; } $request = $this->framework->getRequest(); foreach ($this->filterHandlers($type, $name, $request) as $handlerName) { $handler = $this->framework->getInstance($handlerName); $response = $this->framework->getResponse(); $response->setData('_executedType', $type); $response->setData('_executedName', $name); // Execute the handler $handlerResult = $handler->execute($this->framework, $this->framework->getRequest(), $response, $value); // Save the handler result to the variable if this is an filter handler if ($type === self::FILTER) { $value = $handlerResult; } } // Return the value if this is an filter handler if ($type === self::FILTER) { return $value; } }
/** * Returns the full url to the asset manager to load the * given file. * * @access public * @param string $file * @return string */ public function getUrlToTheAssetLoader($file) { return $this->framework->getRequest()->getFullRoute('/assets/' . $file); }