Ver código fonte

prefer method name given in the `code` option to retrieve a value

Christian Raue 14 anos atrás
pai
commit
1ac5ff298e
1 arquivos alterados com 4 adições e 4 exclusões
  1. 4 4
      Admin/BaseFieldDescription.php

+ 4 - 4
Admin/BaseFieldDescription.php

@@ -341,14 +341,14 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface
     public function getValue($object)
     {
         $camelizedFieldName = self::camelize($this->getFieldName());
-        $getters = array(
-            'get'.$camelizedFieldName,
-            'is'.$camelizedFieldName,
-        );
 
+        $getters = array();
+        // prefer method name given in the code option
         if ($this->getOption('code')) {
             $getters[] = $this->getOption('code');
         }
+        $getters[] = 'get'.$camelizedFieldName;
+        $getters[] = 'is'.$camelizedFieldName;
 
         foreach ($getters as $getter) {
             if (method_exists($object, $getter)) {