Ejemplo n.º 1
0
 public function bind(Data $data) : self
 {
     $form = clone $this;
     $form->data = $data;
     $bindResult = $this->mapping->bind($data);
     if ($bindResult->isSuccess()) {
         $form->value = $bindResult->getValue();
     } else {
         $form->errors = $bindResult->getFormErrorSequence();
     }
     return $form;
 }
Ejemplo n.º 2
0
 public function bind(Data $data) : BindResult
 {
     if (!$data->filter(function (string $value, string $key) {
         if ($key !== $this->key && 0 !== strpos($key, $this->key . '[')) {
             return false;
         }
         if ('' === $value) {
             return false;
         }
         return true;
     })->isEmpty()) {
         $bindResult = $this->wrappedMapping->bind($data);
         if ($bindResult->isSuccess()) {
             return $this->applyConstraints($bindResult->getValue(), $this->key);
         }
         return $bindResult;
     }
     return $this->applyConstraints(null, $this->key);
 }