<?php

namespace OfficeBrain\Bundle\SubShopBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

/**
 * @author OfficeBrain 5058 <info@officebrain.com>
 *
 * Description : Sub shop Admin class.
 *
 * @Route("/{_locale}")
 **/
class SubShopController extends Controller
{
    private $translator;

    private $request;

    private $projectSetting;

    private $responseArray;

    private $recordsPerPage;

    private $session;

    private $subShopManager;

    public function __construct()
    {
        $this->translator = null;
        $this->request = null;
        $this->projectSetting = array();
        $this->responseArray = array();
        $this->recordsPerPage = null;
        $this->session = null;
        $this->subShopManager = null;
    }

    public function __destruct()
    {
        unset($this->translator);
        unset($this->request);
        unset($this->projectSetting);
        unset($this->responseArray);
        unset($this->recordsPerPage);
        unset($this->session);
        unset($this->subShopManager);
    }

    public function initAction()
    {
        $this->translator = $this->get('translator');
        $this->request = $this->getRequest();
        $this->projectSetting = $this->request->get('project_setting');
        $this->session = $this->get('session');
        $this->subShopManager = $this->get('office_brain_subshop_manager');
        $this->responseArray = array();
    }

    /**
     * @Route("/sub-shop-list",
     * name="office_brain_subshopbundle_subshopclient_subshoplist",
     * requirements={"records_per_page"="2|4|8|16|996", "page"="\d+"},
     * defaults={"records_per_page"=2, "page"=1})
     *
     * @Method("GET")
     * @Template("OfficeBrainSubShopBundle:SubShop:list.html.twig")
     */
    public function subShopListAction()
    {
        $this->initAction();

        $this->responseArray['subShopList'] = $this->subShopManager->getSubShopListByInstance();

        return $this->responseArray;
    }
}
