src/Model/Common/OwnerConfig.php line 87

  1. <?php
  2. namespace App\Model\Common;
  3. use ArrayAccess;
  4. class OwnerConfig implements ArrayAccess
  5. {
  6.     public const REPOSITORY_SINGLE 'single';
  7.     public const REPOSITORY_FORUM_THREADS 'forum_threads';
  8.     private $key;
  9.     /**
  10.      * @var array
  11.      */
  12.     private $config;
  13.     public function __construct($key, array $config)
  14.     {
  15.         $this->key $key;
  16.         $this->config $config;
  17.     }
  18.     public function getCaption()
  19.     {
  20.         return $this->config['caption'];
  21.     }
  22.     public function getClass()
  23.     {
  24.         return $this->config['class'];
  25.     }
  26.     public function getRepositorySingle()
  27.     {
  28.         return $this->getRepository(self::REPOSITORY_SINGLE);
  29.     }
  30.     public function getRepository($method)
  31.     {
  32.         return $this->config['repository'][$method];
  33.     }
  34.     public function getRouteName()
  35.     {
  36.         return $this->config['route']['name'];
  37.     }
  38.     public function getRouteParams()
  39.     {
  40.         return $this->config['route']['params'];
  41.     }
  42.     public function getId()
  43.     {
  44.         return $this->config['identity'];
  45.     }
  46.     public function getAdminListRepositoryMethod()
  47.     {
  48.         return $this->getRepository('admin_list');
  49.     }
  50.     public function getRender()
  51.     {
  52.         return $this->config['render'];
  53.     }
  54.     public function offsetSet($offset$value): void
  55.     {
  56.         if (is_null($offset)) {
  57.             $this->config[] = $value;
  58.         } else {
  59.             $this->config[$offset] = $value;
  60.         }
  61.     }
  62.     public function offsetExists($offset): bool
  63.     {
  64.         return isset($this->config[$offset]);
  65.     }
  66.     public function offsetUnset($offset): void
  67.     {
  68.         unset($this->config[$offset]);
  69.     }
  70.     public function offsetGet($offset)
  71.     {
  72.         return isset($this->config[$offset]) ? $this->config[$offset] : null;
  73.     }
  74. }