瀏覽代碼

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

Christian Raue 14 年之前
父節點
當前提交
1ac5ff298e
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      Admin/BaseFieldDescription.php

+ 4 - 4
Admin/BaseFieldDescription.php

@@ -341,14 +341,14 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface
     public function getValue($object)
     public function getValue($object)
     {
     {
         $camelizedFieldName = self::camelize($this->getFieldName());
         $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')) {
         if ($this->getOption('code')) {
             $getters[] = $this->getOption('code');
             $getters[] = $this->getOption('code');
         }
         }
+        $getters[] = 'get'.$camelizedFieldName;
+        $getters[] = 'is'.$camelizedFieldName;
 
 
         foreach ($getters as $getter) {
         foreach ($getters as $getter) {
             if (method_exists($object, $getter)) {
             if (method_exists($object, $getter)) {