<?php
namespace OfficeBrain\Bundle\PageBundle\Manager\Extended;

use OfficeBrain\Bundle\PageBundle\Manager\AbstractManager\MobileAppAbstract as MobileAppAbstract;
use Symfony\Component\DependencyInjection\ContainerInterface as Container;

/**
 *
 * @author OfficeBrain 4571 <info@officebrain.com>
 *
 * Description : Extended class
 *
 */
class MobileAppExtended extends MobileAppAbstract
{
    /**
     *
     * @author Employee Id: 4571
     * Description : Set variables
     *
     * @param 1:  $entityManager
     * @param 2:  $request     
     * @param 3:  $ImgBasePath
     * @param 4: $appSettingary
     *
     * @return null
     *
     * @throws null
     *
     **/
    public function __construct($container, $entityManager, $request)
    {
        parent::__construct($container, $entityManager, $request);        
    }
    
    /**
     *
     * @author Employee Id: 4571
     * Description : Unset variables
     *
     * @param : null
     *
     * @return null
     *
     * @throws null
     *
     **/
    public function __destruct()
    {
        parent::__destruct();
    }
	/**
     *
     * @author Employee Id: 410175
     * Description : Get All the Mobile App Setting variables
     *
     * @param : null
     *
     * @return null
     *
     * @throws null
     *
     **/
    public function getHomePageListing()
    {   
    	$countryId = $this->request->get('countryId',null);
    	$allSetting = $this->mobileAppRepository->getHomePageListing($this->homePageSectionId,$countryId);
    	$returnAry = array();
    	foreach ($allSetting as $key=>$value){
    		$thisAry = $value;
    		$thisAry['image'] = $this->imageBasePath.$value['image'];
    		$thisAry['mobileAppSetting'] = json_decode($value['mobileAppSetting'], true);
    		if(in_array($value['type'],$this->allowMultipleRecord)){    		
    			$returnAry[$this->typeArray[$value['type']]][] = $thisAry ;
    		}else{
    			$returnAry[$this->typeArray[$value['type']]] = $thisAry ;
    		}    		
    	} 
    	
    	foreach ($this->typeArray as $type ){
    		if(!array_key_exists($type,$returnAry)){
    			$returnAry[$type] = 'null';
    		}
    	}
    	return $returnAry;
    }
}
