No main property name.

Created on 25 October 2023, over 1 year ago

Problem/Motivation

ComputedMetatagsFieldItem doesn't have a main property.

Steps to reproduce

Using this snippet throws an error:

    $node = \Drupal\node\Entity\Node::load(1);
    $items = $node->get('metatag');
    $main_property_name = $items->getFieldDefinition()->getFieldStorageDefinition()->getMainPropertyName();
    foreach ($items as $item) {
      $item->get($main_property_name);
    }

The error is:

InvalidArgumentException: Property value is unknown. in Drupal\Core\TypedData\TypedDataManager->getPropertyInstance() (line 196 of core/lib/Drupal/Core/TypedData/TypedDataManager.php).

Proposed resolution

Specify main property name.

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇵🇭Philippines dsdeiz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024