<?php
namespace OfficeBrain\Bundle\BannerBundle\Manager\AbstractManager;

use Symfony\Component\HttpFoundation\Request;

/**
 *
 * @author OfficeBrain 4571 <info@officebrain.com>
 *
 * Description : Abstract Class
 *
 */
abstract class BannerAbstract
{
    protected $entityManager;
    protected $request;
    protected $projectSetting;
    protected $instanceId;
    protected $instanceType;
    protected $cultureId;
    protected $cultureCode;
    protected $userId;
    protected $createdUid;
    protected $upatedUid;
    protected $translator;
    protected $knpPaginator;
    
    protected $languages;
    protected $countries;
    protected $bannerRepository;
    protected $bannerMasterRepository;
    protected $culture;
    protected $cultureAjax;
    protected $bannerImgPath;
    protected $languageCode;
    protected $countryCode;
    protected $responseArray;
    protected $subShopImagePath;
        
    /**
     *
     * @author Employee Id: 4571
     * Description : Initialize the required variable on class load
     *
     * @param : null
     *
     * @return null
     *
     * @throws null
     *
     **/
    public function __construct($entityManager, $request, $translator, $knpPaginator, $country, $language, $bannerImagePath, $subShopImagePath)
    {
        $this->entityManager = $entityManager;
        $this->request = $request;
        $this->projectSetting = $this->request->get('project_setting');
        
        if ($this->request->get('instance_id') > 0)
        {
        	$this->projectSetting['instance_id'] = $this->request->get('instance_id');
                $bannerInstance = $this->entityManager->getRepository('OfficeBrainAccessManagementBundle:InstanceMaster')->find($this->request->get('instance_id'));
                $this->projectSetting['instance_type'] = $bannerInstance->getInstanceType();
        }
        
        $this->instanceId = $this->projectSetting['instance_id'];
        $this->instanceType = $this->projectSetting['instance_type'];
        $this->userId = $this->projectSetting['user_id'];
        $this->cultureId = $this->projectSetting['culture_id'];
        $this->cultureCode = $this->projectSetting['culture_code'];
        $this->createdUid = $this->userId;
        $this->upatedUid =$this->userId;
        $this->translator = $translator;
        $this->knpPaginator = $knpPaginator;
                
        $this->bannerRepository  = $this->entityManager->getRepository('OfficeBrainBannerBundle:Banner');
        $this->bannerMasterRepository  = $this->entityManager->getRepository('OfficeBrainBannerBundle:BannerMaster');
        $this->bannerLanguageRepository  = $this->entityManager->getRepository('OfficeBrainBannerBundle:BannerLanguage');
        $this->bannerRepository->setProjectSetting($this->projectSetting);
        $this->bannerRepository->setPaginatorService($this->knpPaginator);
        $this->bannerMasterRepository->setProjectSetting($this->projectSetting);
        $this->bannerMasterRepository->setPaginatorService($this->knpPaginator);
               
        $this->countries =  $country;
        $this->languages = $language;
        $this->culture = $this->projectSetting['locale_language'];
        
        if (count(explode('_', $this->culture)) == 1) {
        	$this->culture = $this->projectSetting['culture_code'];
        }
        
        $this->cultureAjax = $this->request->get('culture');
        $this->getCultureValue();
        $this->bannerImgPath = $bannerImagePath;
        $this->responseArray = array();
        $this->subShopImagePath = $subShopImagePath;
        
    }
        
    /**
     *
     * @author Employee Id: 4571
     * Description : Unset the variables
     *
     * @param : null
     *
     * @return null
     *
     * @throws null
     *
     **/
    public function __destruct()
    {
        unset($this->entityManager);
        unset($this->request);
        unset($this->projectSetting);
        unset($this->instanceId);
        unset($this->instanceType);
        unset($this->userId);
        unset($this->cultureId);
        unset($this->cultureCode);
        unset($this->createdUid);
        unset($this->upatedUid);
        unset($this->translator);
        unset($this->knpPaginator);
        
        unset($this->countries);
        unset($this->languages);
        unset($this->bannerRepository);
        unset($this->bannerMasterRepository);
        unset($this->culture);
        unset($this->cultureAjax);
        unset($this->bannerImgPath);
        unset($this->languageCode);
        unset($this->countryCode);
        unset($this->responseArray);
        unset($this->subShopImagePath);
    }
    
    /**
     *
     * @author Employee Id: 4571
     * Description : seprate culture with language and country.
     *
     * @param : null
     *
     * @return null
     *
     * @throws null
     *
     **/
    public function getCultureValue()
    {
        $cultures = array();
        if (isset($this->culture) && $this->culture != "") {
            list($this->languageCode, $this->countryCode) = explode("_", $this->culture);
        }
    
        return $cultures;
    }
    
    public function getBanner($id)
    {
    }
    public function getBannerList($searchWord)
    {
    }
    public function getBannerListAjax()
    {
    }
    public function setBanner($banner)
    {
    }
    public function setBannerListPosition($banner, $pos, $id)
    {
    }
    public function updateBanner($banner)
    {
    }
    public function searchBannerType($searchWord)
    {
    }
    public function isValidUpload($form, $img, $banner)
    {
    }
    public function formatSizeUnits($bytes)
    {
    }
    public function fetchSearchActiveBanner($searchQuery, $categoryFilter)
    {
    }
    public function getLanguage($banner)
    {
    }
    public function getLanguageEdit($banner)
    {
    }
    public function getCountry()
    {
    }
    public function filterFormData($form)
    {
    }
    public function getCountryField($culture, $searchField, $returnField)
    {
    }
    public function fetchHomePageActiveBanner()
    {
    }
    public function getCountryIdByCode($cultureCode)
    {
    }
    public function deleteBanners($id, $deleteUid)
    {
    }
    public function getLanguageIdByCode($languageCode)
    {
    }
    public function makeCopyBannerGroup($banner1, $countryId, $isActive)
    {
    }
    public function copyBannerGroup()
    {
    }
    public function getBannerDetails()
    {
    }
    public function deleteBanner($id)
    {
    }
    public function deleteBannerAjax()
    {
    }
    public function handleImageUpload($img)
    {
    }
    public function findBannerTransition($display)
    {
    }
}
