<?php
namespace Medienreaktor\Persons\Controller;

/***
 *
 * This file is part of the "Persons" Extension for TYPO3 CMS.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 *  (c) 2018
 *
 ***/

/**
 * AddressController
 */
class AddressController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
    /**
     * addressRepository
     *
     * @var \Medienreaktor\Persons\Domain\Repository\AddressRepository
     */
    protected $addressRepository = null;
    public function __construct(\Medienreaktor\Persons\Domain\Repository\AddressRepository $addressRepository)
    {
        $this->addressRepository = $addressRepository;
    }

    /**
     * action list
     *
     * @return void
     */
    public function listAction(): \Psr\Http\Message\ResponseInterface
    {
        $addresses = $this->addressRepository->findAll();
        $this->view->assign('addresses', $addresses);
        return $this->htmlResponse();
    }

    /**
     * action show
     *
     * @param \Medienreaktor\Persons\Domain\Model\Address $address
     * @return void
     */
    public function showAction(\Medienreaktor\Persons\Domain\Model\Address $address): \Psr\Http\Message\ResponseInterface
    {
        $this->view->assign('address', $address);
        return $this->htmlResponse();
    }


    /**
     * action list
     *
     * @return void
     */
    public function teasersAction(): \Psr\Http\Message\ResponseInterface
    {
        $address = $this->addressRepository->findByUid((int)$this->settings['address']);
        $this->view->assign('address', $address);
        return $this->htmlResponse();
    }

}
