WEBD-325-45/week-03/project/libraries/src/View/Page/PageHtmlView.php

97 lines
1.7 KiB
PHP
Raw Normal View History

<?php
/**
2022-04-12 19:41:51 +00:00
* @package Octoleo CMS
*
2022-04-12 19:41:51 +00:00
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
2022-04-12 19:41:51 +00:00
namespace Octoleo\CMS\View\Page;
2022-04-12 19:41:51 +00:00
use Octoleo\CMS\Model\PageModel;
use Joomla\Renderer\RendererInterface;
use Joomla\View\HtmlView;
/**
2022-04-12 19:41:51 +00:00
* Page HTML view class for the application
*/
2022-04-12 19:41:51 +00:00
class PageHtmlView extends HtmlView
{
/**
2022-04-12 19:41:51 +00:00
* The active page
*
* @var string
*/
2022-04-12 19:41:51 +00:00
private $page = '';
/**
2022-04-12 19:41:51 +00:00
* The active page details
*
2022-04-12 19:41:51 +00:00
* @var string
*/
2022-04-12 19:41:51 +00:00
private $details;
/**
2022-04-12 19:41:51 +00:00
* The page model object.
*
2022-04-12 19:41:51 +00:00
* @var PageModel
*/
2022-04-12 19:41:51 +00:00
private $pageModel;
/**
* Instantiate the view.
*
2022-04-12 19:41:51 +00:00
* @param PageModel $pageModel The page model object.
* @param RendererInterface $renderer The renderer object.
*/
2022-04-12 19:41:51 +00:00
public function __construct(PageModel $pageModel, RendererInterface $renderer)
{
parent::__construct($renderer);
2022-04-12 19:41:51 +00:00
$this->pageModel = $pageModel;
}
/**
* Method to render the view
*
* @return string The rendered view
*/
public function render()
{
$this->setData(
[
2022-04-12 19:41:51 +00:00
'page' => $this->pageModel->getPage($this->page),
'details' => $this->pageModel->getDetails($this->details)
]
);
return parent::render();
}
/**
2022-04-12 19:41:51 +00:00
* Set the active page
*
* @param string $page The active page name
*
* @return void
*/
public function setPage(string $page): void
{
$this->page = $page;
}
/**
* Set the active page details
*
2022-04-12 19:41:51 +00:00
* @param string $page The active page name
*
* @return void
*/
2022-04-12 19:41:51 +00:00
public function setDetails(string $details): void
{
2022-04-12 19:41:51 +00:00
$this->details = $details;
}
}