function LinkItem::setValue
Same name and namespace in other branches
- 11.x core/modules/link/src/Plugin/Field/FieldType/LinkItem.php \Drupal\link\Plugin\Field\FieldType\LinkItem::setValue()
- 10 core/modules/link/src/Plugin/Field/FieldType/LinkItem.php \Drupal\link\Plugin\Field\FieldType\LinkItem::setValue()
- 9 core/modules/link/src/Plugin/Field/FieldType/LinkItem.php \Drupal\link\Plugin\Field\FieldType\LinkItem::setValue()
- 8.9.x core/modules/link/src/Plugin/Field/FieldType/LinkItem.php \Drupal\link\Plugin\Field\FieldType\LinkItem::setValue()
Overrides FieldItemBase::setValue
File
-
core/
modules/ link/ src/ Plugin/ Field/ FieldType/ LinkItem.php, line 221
Class
- LinkItem
- Plugin implementation of the 'link' field type.
Namespace
Drupal\link\Plugin\Field\FieldTypeCode
public function setValue($values, $notify = TRUE) {
// Treat the values as property value of the main property, if no array is
// given.
if (isset($values) && !is_array($values)) {
$values = [
static::mainPropertyName() => $values,
];
}
if (isset($values)) {
$values += [
'options' => [],
];
}
parent::setValue($values, $notify);
// Support setting the field item with only url property, but make sure
// values stay in sync if only url property is passed.
// NULL is a valid value, so we use array_key_exists().
if (is_array($values) && array_key_exists('resolvable_uri', $values) && !array_key_exists('uri', $values)) {
$this->onChange('resolvable_uri', FALSE);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.