WEBD-325-45/week-03/project/libraries/src/Controller/LoginController.php

72 lines
1.8 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\Controller;
use Joomla\Application\AbstractApplication;
use Joomla\Controller\AbstractController;
use Joomla\Input\Input;
2022-04-12 19:41:51 +00:00
use Joomla\Renderer\RendererInterface;
use Laminas\Diactoros\Response\HtmlResponse;
/**
2022-04-12 19:41:51 +00:00
* Controller handling the site's homepage
*
2022-04-12 19:41:51 +00:00
* @method \Octoleo\CMS\Application\SiteApplication getApplication() Get the application object.
* @property-read \Octoleo\CMS\Application\SiteApplication $app Application object
*/
2022-04-12 19:41:51 +00:00
class LoginController extends AbstractController
{
/**
2022-04-12 19:41:51 +00:00
* The template renderer.
*
2022-04-12 19:41:51 +00:00
* @var RendererInterface
*/
2022-04-12 19:41:51 +00:00
private $renderer;
/**
* Constructor.
*
2022-04-12 19:41:51 +00:00
* @param RendererInterface $renderer The template renderer.
* @param Input $input The input object.
* @param AbstractApplication $app The application object.
*/
2022-04-12 19:41:51 +00:00
public function __construct(RendererInterface $renderer, Input $input = null, AbstractApplication $app = null)
{
parent::__construct($input, $app);
2022-04-12 19:41:51 +00:00
$this->renderer = $renderer;
}
/**
* Execute the controller.
*
* @return boolean
*/
public function execute(): bool
{
// Enable browser caching
$this->getApplication()->allowCache(true);
2022-04-12 19:41:51 +00:00
$task = $this->getInput()->getString('account', null);
2022-04-12 19:41:51 +00:00
if ('signup' === $task)
{
$this->getApplication()->setResponse(new HtmlResponse($this->renderer->render('signup.twig')));
}
else
{
$this->getApplication()->setResponse(new HtmlResponse($this->renderer->render('login.twig')));
}
return true;
}
}