public function getAttributeByPath($attribute_path) { return AttributePath::getAttributeByPath($this, $attribute_path); }
/** * @dataProvider attributeByPathProvider */ public function testGetAttributeByPath($attribute_path, $expected_name) { $type = new ArticleType(); $attribute = AttributePath::getAttributeByPath($type, $attribute_path); $this->assertEquals($expected_name, $attribute->getName()); }
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 ''; }