예제 #1
0
 /**
  * @dataProvider attributePathProvider
  */
 public function testGetAttributePath($attribute, $expected_path)
 {
     $type = new ArticleType();
     $attribute_path = AttributePath::getAttributePath($attribute);
     $this->assertEquals($expected_path, $attribute_path);
 }
예제 #2
0
 public function getAttributeByPath($attribute_path)
 {
     return AttributePath::getAttributeByPath($this, $attribute_path);
 }
예제 #3
0
 /**
  * Returns the attribute's top-most entity type. That is the entity type
  * of the root attribute of this attribute.
  *
  * @return EntityTypeInterface
  */
 public function getRootType()
 {
     return AttributePath::getRootEntityType($this);
 }
 protected function getGlanceDescription(EntityInterface $resource, ViewTemplateInterface $view_template)
 {
     if ($this->hasOption('description')) {
         $description = $this->getOption('description');
         // empty value would reset eventual global options and allow to use the value_path option
         if ($this->hasOption('description_value_path') && empty($description)) {
             return AttributeValuePath::getAttributeValueByPath($resource, $this->getOption('description_value_path'));
         } else {
             return $description;
         }
     }
     // otherwise get first textarea attribute value
     $view_template_fields = $view_template->extractAllFields();
     foreach ($view_template_fields as $field) {
         $attribute_path = $field->getSetting('attribute_path');
         if ($attribute_path) {
             $attribute = AttributePath::getAttributeByPath($resource->getType(), $attribute_path);
             if (in_array(get_class($attribute), [TextareaAttribute::class])) {
                 return AttributeValuePath::getAttributeValueByPath($resource, $attribute_path);
             }
         }
     }
     return '';
 }