Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function getList(CollectionInterface $collection, $identifier)
 {
     $options = $collection->getOptions();
     $objectClass = $options->getObjectClass();
     $storedSettings = [];
     if (isset($this->storage[$options->getName()])) {
         $storedSettings = $this->storage[$options->getName()];
     }
     $settings = [];
     foreach ($storedSettings as $owner => $item) {
         if ($owner != $identifier) {
             continue;
         }
         foreach ($item as $name => $value) {
             /** @var SettingInterface $setting */
             $setting = new $objectClass();
             $setting->setCollection($options->getName());
             $setting->setIdentifier($identifier);
             $setting->setName($name);
             $setting->setValue($value);
             $settings[] = $setting;
         }
     }
     return $settings;
 }
 /**
  * Update one setting in collection by setting name
  *
  * @param string $name
  * @param mixed $data
  *
  * @return JsonModel|ApiProblemResponse
  */
 public function update($name, $data)
 {
     try {
         if (!$this->settings->isValid($name, $data)) {
             return new ApiProblemResponse(new ApiProblem(400, 'Invalid parameters provided.'));
         }
         $this->settings->setValue($name, $data);
         return new JsonModel([$name => $data]);
     } catch (SettingDoesNotExistException $exception) {
         return new ApiProblemResponse(new ApiProblem(404, $exception->getMessage()));
     }
 }
Esempio n. 3
0
 /**
  * @param CollectionInterface $collection
  * @param mixed               $identifier
  *
  * @return array
  */
 public function getList(CollectionInterface $collection, $identifier)
 {
     $options = $collection->getOptions();
     $repository = $this->entityManager->getRepository($options->getObjectClass());
     return $repository->findBy(['collection' => $options->getName(), 'identifier' => $identifier]);
 }