Esempio n. 1
0
 /**
  * @param $data
  *
  * @return array
  */
 public function toRepresentation($data)
 {
     $values = [];
     foreach ($data as $item) {
         $values[] = $this->child->toRepresentation($item);
     }
     return $values;
 }
Esempio n. 2
0
 /**
  * @param Serializer $serializer
  */
 public function performStore(Serializer $serializer)
 {
     $serializer->save();
 }
Esempio n. 3
0
 /**
  * @param $data
  *
  * Return [isEmpty, data]
  *
  * @return array
  * @throws SkipField
  * @throws ValidationError
  */
 public function validateEmptyValues($data)
 {
     if ($this->readOnly) {
         return [true, $this->getDefault()];
     }
     if (EmptyType::isEmpty($data)) {
         if ($this->root instanceof Serializer and $this->root->partial()) {
             throw new SkipField();
         }
         if ($this->required) {
             $this->fail('required');
         }
         return [true, $this->getDefault()];
     }
     if ($data === null) {
         if (!$this->allowNull) {
             $this->fail('invalid');
         }
         return [true, null];
     }
     return [false, $data];
 }
Esempio n. 4
0
 /**
  * @param Serializer $serializer
  */
 public function performUpdate(Serializer $serializer)
 {
     $serializer->save();
 }