<?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
 *
 ***/

/**
 * PersonController
 */
class PersonController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
    /**
     * personRepository
     *
     * @var \Medienreaktor\Persons\Domain\Repository\PersonRepository
     */
    protected $personRepository = null;

    /**
     * addressRepository
     *
     * @var \Medienreaktor\Persons\Domain\Repository\AddressRepository
     */
    protected $addressRepository = null;
    public function __construct(\Medienreaktor\Persons\Domain\Repository\PersonRepository $personRepository, \Medienreaktor\Persons\Domain\Repository\AddressRepository $addressRepository)
    {
        $this->personRepository = $personRepository;
        $this->addressRepository = $addressRepository;
    }

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

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


}
