<?php
namespace App\Controller\Website;
use App\Service\DocumentManagerServices;
use App\Service\InstagramService;
use Sulu\Bundle\WebsiteBundle\Controller\DefaultController;
use Sulu\Component\Content\Compat\StructureInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
class HomeController extends DefaultController {
public function __construct(RequestStack $request, DocumentManagerServices $documentManagerService, InstagramService $instagramService) {
$this->request = $request;
$this->documentManagerService = $documentManagerService;
$this->instagramService = $instagramService;
}
protected function getAttributes($attributes, StructureInterface $structure = null, $preview = true) {
$attributes = parent::getAttributes($attributes, $structure, $preview);
$locale = $this->request->getMainRequest()->getLocale();
$instagram_limit = new Response($this->getParameter('INSTAGRAM_LIMIT'));
$instagram_token = new Response($this->getParameter('INSTAGRAM_API_TOKEN'));
$medias = $this->instagramService->fetchInstagramPost($instagram_limit, $instagram_token);
$attributes['medias'] = $medias;
return $attributes;
}
}