Explorar o código

Add getLabel() to FieldDescriptionInterface; call it from ShowMapper

ShowMapper type hints $name on FieldDescriptionInterface, so the method
should be there.
Ethan Resnick %!s(int64=13) %!d(string=hai) anos
pai
achega
22ee95ecc0
Modificáronse 2 ficheiros con 8 adicións e 1 borrados
  1. 7 0
      Admin/FieldDescriptionInterface.php
  2. 1 1
      Show/ShowMapper.php

+ 7 - 0
Admin/FieldDescriptionInterface.php

@@ -239,4 +239,11 @@ interface FieldDescriptionInterface
      * @return int|string
      */
     function getMappingType();
+
+    /**
+     * return the label to use for the current field
+     *
+     * @return string
+     */
+    function getLabel();
 }

+ 1 - 1
Show/ShowMapper.php

@@ -75,7 +75,7 @@ class ShowMapper
             throw new \RuntimeException('invalid state');
         }
 
-        if (!$fieldDescription->getOption('label')) {
+        if (!$fieldDescription->getLabel()) {
             $fieldDescription->setOption('label', $this->admin->getLabelTranslatorStrategy()->getLabel($fieldDescription->getName(), 'show', 'label'));
         }