<?php

namespace AmadeusAgentur\Nahrstedt\Sitepackage\ViewHelpers;

use AmadeusAgentur\Nahrstedt\Sitepackage\Domain\Model\Address;
use AmadeusAgentur\Nahrstedt\Sitepackage\Domain\Repository\AddressRepository;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Property\PropertyMapper;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;

class FavoriteAddressViewHelper extends AbstractViewHelper
{


    protected $escapeOutput = false;


    public function render()
    {
        $address = (int)$_COOKIE['favorite'];


        $objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
        $addressRepository = $objectManager->get(AddressRepository::class);

        //$address = $objectManager->get(DataMapper::class)->map(Address::class,->toArray());
        $address = $addressRepository->findByUid($address);

        return $address;
    }
}
