partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

SystemPreference.php (1879B)


      1 <?php
      2 
      3 namespace PartKeepr\SystemPreferenceBundle\Entity;
      4 
      5 use Doctrine\ORM\Mapping as ORM;
      6 use PartKeepr\DoctrineReflectionBundle\Annotation\IgnoreIds;
      7 use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService;
      8 use Symfony\Component\Serializer\Annotation\Groups;
      9 
     10 /**
     11  * Represents a system preference entry.
     12  *
     13  * System preferences are a simple key => value mechanism, where the developer can
     14  * specify the key and value himself.
     15  *
     16  * Note that values are stored internally as serialized PHP values to keep their type.
     17  *
     18  * @ORM\Entity
     19  * @TargetService(uri="/api/system_preferences")
     20  * @IgnoreIds()
     21  **/
     22 class SystemPreference
     23 {
     24     /**
     25      * Defines the key of the system preference.
     26      *
     27      * @ORM\Column(type="string",length=255)
     28      * @ORM\Id()
     29      *
     30      * @Groups({"default"})
     31      *
     32      * @var string
     33      */
     34     private $preferenceKey;
     35 
     36     /**
     37      * Defines the value. Note that the value is internally stored as a serialized string.
     38      *
     39      * @ORM\Column(type="text")
     40      *
     41      * @Groups({"default"})
     42      *
     43      * @var mixed
     44      */
     45     private $preferenceValue;
     46 
     47     /**
     48      * Returns the key of this entry.
     49      *
     50      * @return string
     51      */
     52     public function getPreferenceKey()
     53     {
     54         return $this->preferenceKey;
     55     }
     56 
     57     /**
     58      * Sets the key for this user preference.
     59      *
     60      * @param string $key The key name
     61      */
     62     public function setPreferenceKey($key)
     63     {
     64         $this->preferenceKey = $key;
     65     }
     66 
     67     /**
     68      * Returns the value for this entry.
     69      *
     70      * @return mixed The value
     71      */
     72     public function getPreferenceValue()
     73     {
     74         return unserialize($this->preferenceValue);
     75     }
     76 
     77     /**
     78      * Sets the value for this entry.
     79      *
     80      * @param mixed $value
     81      */
     82     public function setPreferenceValue($value)
     83     {
     84         $this->preferenceValue = serialize($value);
     85     }
     86 }