/** * Get the fully qualified location of the view. * * Just returns $view if $view is in the database, otherwise throws an * exception. * * @param string $view * @return string */ public function find($view) { // Check to see if the page exists in the database $vpage = Vpage::make($view); if (!empty($vpage)) { return $view . Vpage::EXTENSION_SEPARATOR . $vpage->pagetype; } throw new InvalidArgumentException("View [{$view}] not found in vpage table."); }
/** * Gets the source code of a template, given its name. * * @param string $name The name of the template to load * * @return string The template source code * * @throws Twig_Error_Loader When $name is not found */ public function getSource($name) { // Fetch the view from the database. $viewModel = Vpage::make($name); // If it is found return its content. if (!empty($viewModel)) { return $viewModel->content; } throw new Twig_Error_Loader('unable to locate page ' . $name); }
/** * Return the last modified timestamp of a view. * * @param string $name * @return integer */ public function lastModified($name) { // Fetch the view from the database. $viewModel = Vpage::make($name); // If it is found return its last modified time as a timestamp. if (!empty($viewModel)) { $dt = new \DateTime($viewModel->updated_at); return $dt->format('U'); } throw new InvalidArgumentException('unable to locate page ' . $name); }