소스 검색

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

Christian Raue 14 년 전
부모
커밋
57e929e4eb
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  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();