Selaa lähdekoodia

allow usage of a closure for the `code` option of fields

Christian Raue 14 vuotta sitten
vanhempi
commit
57e929e4eb
1 muutettua tiedostoa jossa 4 lisäystä ja 0 poistoa
  1. 4 0
      Admin/BaseFieldDescription.php

+ 4 - 0
Admin/BaseFieldDescription.php

@@ -318,6 +318,10 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface
      */
     public function getFieldValue($object, $fieldName)
     {
+        if (is_callable($this->getOption('code'))) {
+            return call_user_func($this->getOption('code'), $object);
+        }
+
         $camelizedFieldName = self::camelize($fieldName);
 
         $getters = array();