. */ namespace Alledia\Framework\Joomla; use Joomla\CMS\Form\Form; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\CMS\MVC\View\HtmlView; use Joomla\CMS\Object\CMSObject; defined('_JEXEC') or die(); abstract class AbstractView extends HtmlView { use TraitAllediaView; /** * @var BaseDatabaseModel */ protected $model = null; /** * Formally declare this since Joomla core does not * * @var Form */ protected $form = null; /** * @var CMSObject */ protected $state = null; /** * @inheritDoc * @throws \Exception */ public function __construct($config = []) { $this->setup(); parent::__construct($config); } /** * @inheritDoc */ public function setModel($model, $default = false) { $model = parent::setModel($model, $default); if ($model && $default) { $this->model = $model; $this->state = $this->model->getState(); } return $model; } /** * @inheritDoc */ public function display($tpl = null) { if ($this->initSuccess) { $this->displayHeader(); parent::display($tpl); $this->displayFooter(); } } /** * For use by subclasses * * @return void */ protected function displayHeader() { // Display custom text } /** * For use by subclasses * * @return void */ protected function displayFooter() { // Display custom text } /** * @param string $name * @param string $layout * * @return string * @throws \Exception */ public function loadDefaultTemplate(string $name, ?string $layout = 'default'): string { $currentLayout = $this->setLayout($layout); $output = $this->loadTemplate($name); $this->setLayout($currentLayout); return $output; } }