<?php

namespace Application\Bundle\Controller;

use eZ\Bundle\EzPublishCoreBundle\Controller,
    Symfony\Component\HttpFoundation\Request,
    Symfony\Component\HttpFoundation\Response,
    eZ\Publish\API\Repository\Values\Content\Query,
    eZ\Publish\API\Repository\Values\Content\Query\Criterion,
    DateTime;

class ContentViewController extends Controller
{
    /**
     * ID\Location: 2
     */
    public function mapAction( $locationId, $viewType, $layout = false, array $params = array() )
    {
        $params = array(
            'cities' => $this->fetchCities()
        );
        $response = new Response;
        $date = new DateTime();
        $date->modify('+600 seconds');
        $response->setExpires($date);
        return $this->render(
            'ApplicationBundle::pagelayout.html.twig',
            $params,
            $response
        );
    }
    
    protected function fetchCities()
    {
        return $this->get('messaggio.database')->loadTextFieldValues('company', 'city');
    }
}