Forráskód Böngészése

Adding 'help' as reserved key for FieldDescription

Stefano Sala 13 éve
szülő
commit
db25866003

+ 8 - 1
Admin/BaseFieldDescription.php

@@ -190,6 +190,7 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface
      * Define the options value, if the options array contains the reserved keywords
      *   - type
      *   - template
+     *   - help
      *
      * Then the value are copied across to the related property value
      *
@@ -210,6 +211,12 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface
             unset($options['template']);
         }
 
+        // set help if provided
+        if (isset($options['help'])) {
+            $this->setHelp($options['help']);
+            unset($options['help']);
+        }
+
         $this->options = $options;
     }
 
@@ -475,4 +482,4 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface
     {
         return $this->getOption('label');
     }
-}
+}

+ 2 - 1
Tests/Admin/BaseFieldDescriptionTest.php

@@ -49,10 +49,11 @@ class BaseFieldDescriptionTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('trucmuche', $description->getLabel());
 
         $this->assertNull($description->getTemplate());
-        $description->setOptions(array('type' => 'integer', 'template' => 'foo.twig.html'));
+        $description->setOptions(array('type' => 'integer', 'template' => 'foo.twig.html', 'help' => 'fooHelp'));
 
         $this->assertEquals('integer', $description->getType());
         $this->assertEquals('foo.twig.html', $description->getTemplate());
+        $this->assertEquals('fooHelp', $description->getHelp());
 
         $this->assertCount(0, $description->getOptions());