<?php
namespace App\Mvc;

abstract class View_Popup_GeneralAbstract extends ViewAbstract
{
	/**
	 * The rendering Smarty template file.
	 * @var String
	 */
	protected $renderingTemplate=SMARTY_LAYOUT_MAIN_POPUP;


	/**
	 * This var indicates if the popup should be automatically closed.
	 * @var Boolean
	 */
	protected bool $closePopup = false;


	/**
	 * Sets the closePopup flag.
	 * @param bool $closePopup
	 */
	public function setClosePopup(bool $closePopup) :void
	{
		$this->closePopup = $closePopup;
	}

	/**
	 * Returns the closePopup flag value.
	 * @return bool
	 */
	public function getClosePopup() :bool
	{
		return $this->closePopup;
	}

	/**
	 * Get template path
	 * @return string
	 */
	public function getTemplatePath()
	{
		return $this->renderingTemplate;
	}

	/**
	 * It also attempts to draw (using the MessageStack) the messages collected into $this->messagesCollector.
	 */
	public function render()
	{
		// sets the closePopup flag
		$this->setOutputVar('closePopup', $this->closePopup);

		return $this->renderWithCustomTemplate($this->getTemplatePath(), $this->messagesCollector);
	}
}
