<?php

namespace OfficeBrain\Bundle\EmailBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 *
 * @author OfficeBrain 4795 <info@officebrain.com>
 *
 * Description: This class is auto generate by Doctrine ORM add your own custom function here.
 *
 */
/**
 * EmailTemplateHeaderLanguageRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class EmailTemplateHeaderLanguageRepository extends EntityRepository
{
    protected $projectSetting;
    protected $instanceId;
    protected $instanceType;
    protected $cultureId;
    protected $cultureCode;
    
    public function setProjectSetting($projetSetting)
    {
        $this->projectSetting = $projetSetting;
        $this->prepareProjectSettingData();
    }
    
    public function getProjectSetting()
    {
        return $this->projetSetting;
    }
    
    public function prepareProjectSettingData()
    {
        $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'];
    }
    
    /**
     * @author Employee Id: 4795
     *
     * Description : Find all headers header content by language
     */
    public function findHeaderContentByLanguage($header_id, $language_id)
    {
        return $this->createQueryBuilder('eh')
        ->select('eh.headerContent')
        ->where('eh.headerId = :header_id')
        ->andWhere('eh.languageId = :language_id')
        ->setParameter(':header_id', $header_id)
        ->setParameter(':language_id', $language_id)
        ->getQuery()
        ->getOneOrNullResult();
    }
}
