<?php
 
namespace OfficeBrain\Bundle\AccessManagementBundle\Service;

class ProjectSetting
{
    public function __construct($request)
    {
        $this->request = $request;
        $this->prepareProjectSetting();
    }
        
    public function __destruct()
    {
        unset($this->request);
    }
    
    public function prepareProjectSetting()
    {
        $this->projectSetting = $this->request->get('project_setting');
        $this->instanceId = $this->projectSetting['instance_id'];
        $this->instanceType = $this->projectSetting['instance_type'];
        $this->userId = $this->projectSetting['user_id'];
        $this->userType = $this->projectSetting['user_type'];
        $this->cultureId = $this->projectSetting['culture_id'];
        $this->cultureCode = $this->projectSetting['culture_code'];
        $this->createdUid = $this->userId;
        $this->upatedUid =$this->userId;
    }

    public function getProjectSetting()
    {
        return $this->projectSetting;
    }

    public function getInatanceId()
    {
        return $this->instanceId;
    }

    public function getInatanceType()
    {
        return $this->instanceType;
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function getUseType()
    {
        return $this->userType;
    }

    public function getCultureId()
    {
        return $this->cultureId;
    }

    public function getCultureCode()
    {
        return $this->cultureCode;
    }

    public function getAccessRule($key)
    {
        if (array_key_exists($key, $this->projectSetting['access_rule'])) {
            return $this->projectSetting['access_rule'][$key];
        }
        return false;
    }

    public function getConfigurationRule($key)
    {
        if (array_key_exists($key, $this->projectSetting['configuration_rule'])) {
            return $this->projectSetting['configuration_rule'][$key];
        }
        return false;
    }
}
