ソースを参照

Enable public fields without getters to be displayed

Enable public fields without getters to be displayed in the list.
Previously, when there was not getter method, the field would not have a value in the list, even if it was public. Forms would still work because they use the Symfony2 Form mechanisms that look for getters first and then for public fields.
Michel Weimerskirch 12 年 前
コミット
d0a310aad5
1 ファイル変更4 行追加1 行削除
  1. 4 1
      Admin/BaseFieldDescription.php

+ 4 - 1
Admin/BaseFieldDescription.php

@@ -322,13 +322,16 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface
         $getters[] = 'get' . $camelizedFieldName;
         $getters[] = 'is' . $camelizedFieldName;
 
-
         foreach ($getters as $getter) {
             if (method_exists($object, $getter)) {
                 return call_user_func(array($object, $getter));
             }
         }
 
+        if (isset($object->{$fieldName})) {
+            return $object->{$fieldName};
+        }
+
         throw new NoValueException(sprintf('Unable to retrieve the value of `%s`', $this->getName()));
     }