Procházet zdrojové kódy

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 před 13 roky
rodič
revize
d0a310aad5
1 změnil soubory, kde provedl 4 přidání a 1 odebrání
  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()));
     }