Skip to content

Instantly share code, notes, and snippets.

@Greg-Boggs
Created June 29, 2022 21:58
Show Gist options
  • Save Greg-Boggs/e8d18176a70a3223033cdf8b716e2524 to your computer and use it in GitHub Desktop.
Save Greg-Boggs/e8d18176a70a3223033cdf8b716e2524 to your computer and use it in GitHub Desktop.
get a link field value in drupal
<?php
$value = NULL;
if (
$entity->hasField($field)
&& $entity->get($field)->first()
&& !empty($entity->get($field)->first()->getValue())
) {
$value = array_values($entity->get($field)->first()->getValue())[0];
}
return $value->getUrl()->toString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment