예제 #1
0
 /**
  * @param $data
  *
  * @return array
  */
 public function toRepresentation($data)
 {
     $values = [];
     foreach ($data as $item) {
         $values[] = $this->child->toRepresentation($item);
     }
     return $values;
 }
예제 #2
0
 /**
  * @param Serializer $serializer
  */
 public function performStore(Serializer $serializer)
 {
     $serializer->save();
 }
예제 #3
0
파일: Field.php 프로젝트: kalaomer/kahire
 /**
  * @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];
 }
예제 #4
0
 /**
  * @param Serializer $serializer
  */
 public function performUpdate(Serializer $serializer)
 {
     $serializer->save();
 }