src/Uniski/ConfigBundle/Entity/Configuration.php line 15

Open in your IDE?
  1. <?php
  2. namespace Uniski\ConfigBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  5. /**
  6.  * Configuration Entity
  7.  *
  8.  * @ORM\Entity
  9.  * @ORM\Table("configuration")
  10.  * @UniqueEntity(fields={"key"}, message="La clave debe ser Ășnica")
  11.  */
  12. class Configuration
  13. {
  14.     /**
  15.      * @var integer
  16.      *
  17.      * @ORM\Id
  18.      * @ORM\Column(name="id", type="integer")
  19.      * @ORM\GeneratedValue(strategy="IDENTITY")
  20.      */
  21.     protected $id;
  22.     /**
  23.      * @var string
  24.      *
  25.      * @ORM\Column(type="string")
  26.      */
  27.     protected $name;
  28.     /**
  29.      * @var string
  30.      *
  31.      * @ORM\Column(name="config_key", type="string")
  32.      * Key for the indentification for the API and admin
  33.      * configuration
  34.      */
  35.     protected $key;
  36.     /**
  37.      * @var array
  38.      *
  39.      * @ORM\Column(type="json")
  40.      */
  41.     protected $settings;
  42.     function __construct($name null$key null$settings null)
  43.     {
  44.         $this->name $name;
  45.         $this->key $key;
  46.         $this->settings $settings;
  47.     }
  48.     /**
  49.      * Get id
  50.      *
  51.      * @return integer
  52.      */
  53.     public function getId()
  54.     {
  55.         return $this->id;
  56.     }
  57.     /**
  58.      * Set name
  59.      *
  60.      * @param string $name
  61.      *
  62.      * @return Configuration
  63.      */
  64.     public function setName($name)
  65.     {
  66.         $this->name $name;
  67.         return $this;
  68.     }
  69.     /**
  70.      * Get name
  71.      *
  72.      * @return string
  73.      */
  74.     public function getName()
  75.     {
  76.         return $this->name;
  77.     }
  78.     /**
  79.      * Set settings
  80.      *
  81.      * @param array $settings
  82.      *
  83.      * @return Configuration
  84.      */
  85.     public function setSettings($settings)
  86.     {
  87.         $this->settings $settings;
  88.         return $this;
  89.     }
  90.     /**
  91.      * Get settings
  92.      *
  93.      * @return array
  94.      */
  95.     public function getSettings($key null)
  96.     {
  97.         if (!$this->settings) return null;
  98.         if ($key && !empty($this->settings[$key])) return $this->settings[$key];
  99.         
  100.         return $this->settings;
  101.     }
  102.     /**
  103.      * Set key
  104.      *
  105.      * @param string $key
  106.      *
  107.      * @return Configuration
  108.      */
  109.     public function setKey($key)
  110.     {
  111.         $this->key $key;
  112.         return $this;
  113.     }
  114.     /**
  115.      * Get key
  116.      *
  117.      * @return string
  118.      */
  119.     public function getKey()
  120.     {
  121.         return $this->key;
  122.     }
  123. }