Procházet zdrojové kódy

optimization to call `$this->getOption('code')` only once

Christian Raue před 14 roky
rodič
revize
451616fa65
1 změnil soubory, kde provedl 6 přidání a 4 odebrání
  1. 6 4
      Admin/BaseFieldDescription.php

+ 6 - 4
Admin/BaseFieldDescription.php

@@ -318,16 +318,18 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface
      */
     public function getFieldValue($object, $fieldName)
     {
-        if (is_callable($this->getOption('code'))) {
-            return call_user_func($this->getOption('code'), $object);
+        $code = $this->getOption('code');
+
+        if (is_callable($code)) {
+            return call_user_func($code, $object);
         }
 
         $camelizedFieldName = self::camelize($fieldName);
 
         $getters = array();
         // prefer method name given in the code option
-        if ($this->getOption('code')) {
-            $getters[] = $this->getOption('code');
+        if ($code) {
+            $getters[] = $code;
         }
         $getters[] = 'get' . $camelizedFieldName;
         $getters[] = 'is' . $camelizedFieldName;