Esempio n. 1
0
 /**
  * Get the callback that will be used for the given FieldInterface object.
  *
  * @param FieldInterface $field
  * @throws \Dewdrop\Fields\Exception\HelperCallableNotAvailableForField
  * @return callable
  */
 public function getFieldAssignment(FieldInterface $field)
 {
     if (!$this->hasValidName()) {
         return false;
     }
     $id = $field->getId();
     if (!array_key_exists($id, $this->assignments)) {
         if (!$field->hasHelperCallback($this->name)) {
             $callback = $this->detectCallableForField($field);
         } else {
             $callback = $field->getHelperCallback($this->name);
         }
         if (!is_callable($callback)) {
             throw new HelperCallableNotAvailableForField("Field {$id} does not have a callable assigned and one could not be detected.");
         }
         $this->assignments[$id] = $this->wrapCallable($callback);
     }
     return $this->assignments[$id];
 }