public function LinkedFieldManager::getFieldValue in Linked Field 8
Get the URI from field value.
Parameters
\Drupal\Core\Field\FieldItemListInterface $field_items: The field item list.
Return value
string The value of the first field item.
Overrides LinkedFieldManagerInterface::getFieldValue
1 call to LinkedFieldManager::getFieldValue()
- LinkedFieldManager::getDestination in src/
LinkedFieldManager.php - Get the destination for a set field or custom text.
File
- src/
LinkedFieldManager.php, line 190
Class
- LinkedFieldManager
- Provides helper methods for client related functionalities.
Namespace
Drupal\linked_fieldCode
public function getFieldValue(FieldItemListInterface $field_items) {
$items = $field_items
->getValue();
$field_definition = $field_items
->getFieldDefinition();
$field_type = $field_definition
->getType();
// @TODO: We should add support for deltas.
$item = $items[0];
$uri = '';
if ($field_type == 'link') {
$uri = $item['uri'];
}
else {
$uri = isset($item['value']) ? $item['value'] : '';
}
return $uri;
}