Exemplo n.º 1
0
 /**
  * Removes pair by key.
  *
  * @param string $key
  */
 public function remove($key)
 {
     $pair = $this->repository->find($key);
     if ($pair !== null) {
         $this->repository->remove($pair->getId());
         $this->manager->flush();
         $this->manager->refresh();
     }
 }
Exemplo n.º 2
0
 /**
  * Returns setting model by name and profile or creates new if $mustExist is set to FALSE.
  *
  * @param string $name
  * @param string $profile
  * @param bool   $mustExist
  * @param string $type
  *
  * @throws \UnexpectedValueException
  *
  * @return Setting
  */
 public function get($name, $profile = 'default', $mustExist = true, $type = 'string')
 {
     $setting = $this->repo->find($profile . '_' . $name);
     if ($setting === null) {
         if ($mustExist == true) {
             throw new \UnexpectedValueException();
         }
         $setting = $this->createSetting($name, $profile, $type);
     }
     return $setting;
 }