Created
June 29, 2022 21:58
-
-
Save Greg-Boggs/e8d18176a70a3223033cdf8b716e2524 to your computer and use it in GitHub Desktop.
get a link field value in drupal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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