/** * {@inheritdoc} */ public function __construct(DataDefinitionInterface $definition, $name = NULL, TypedDataInterface $parent = NULL) { parent::__construct($definition, $name, $parent); // Initialize computed properties by default, such that they get cloned // with the whole item. foreach ($this->definition->getPropertyDefinitions() as $name => $definition) { if ($definition->isComputed()) { $this->properties[$name] = \Drupal::typedDataManager()->getPropertyInstance($this, $name); } } }
/** * {@inheritdoc} */ public function setValue($values, $notify = TRUE) { // Treat the values as property value of the first property, if no array is // given. if (isset($values) && !is_array($values)) { $keys = array_keys($this->definition->getPropertyDefinitions()); $values = array($keys[0] => $values); } parent::setValue($values, $notify); }