diff --git a/endpoints/endpoint_get_AAAAA/src/Controller/NodesController.php b/endpoints/endpoint_get_AAAAA/src/Controller/NodesController.php index 228d2e6..892a842 100644 --- a/endpoints/endpoint_get_AAAAA/src/Controller/NodesController.php +++ b/endpoints/endpoint_get_AAAAA/src/Controller/NodesController.php @@ -1,6 +1,6 @@ getTranslation($lang); $published = $node->get('status')->value; - /* get user name */ + /* USER - get user name */ $uid = $node->getOwnerId(); $user = \Drupal\user\Entity\User::load($uid); $name = $user->getDisplayName(); - /* absolute urls for body inline images */ - $base_url = Url::fromRoute('')->setAbsolute()->toString(); - $url_components = parse_url($base_url); - $domain = $url_components['scheme'].'://'.$url_components['host'].':'.$url_components['port']; - $body = str_replace( - '/sites/default/', - $domain.'/sites/default/', - $node->get('body')->value - ); + /* BODY Field - absolute urls for body inline images */ + // $base_url = Url::fromRoute('')->setAbsolute()->toString(); + // $url_components = parse_url($base_url); + // $domain = $url_components['scheme'].'://'.$url_components['host'].':'.$url_components['port']; + // $body = str_replace( + // '/sites/default/', + // $domain.'/sites/default/', + // $node->get('body')->value + // ); + + /* LINK Field */ + // $field_link = []; + // if ($node->hasField('field_link') && !$node->get('field_link')->isEmpty()) { + // $link_field = $node->get('field_link')->first(); + // $url = $link_field->getUrl(); + // $title = $link_field->getTitle(); + // if ($url) { + // $field_link['url'] = $url->toString(); + // } + // if ($title) { + // $field_link['title'] = $link_field->getTitle(); + // } else { + // $field_link['title'] = $url->toString();; + // } + // } + + /* GEOLOCATION Field */ + // $field_geolocation = []; + // if ($node->hasField('field_geolocation') && !$node->get('field_geolocation')->isEmpty()) { + // $geolocation_field = $node->get('field_geolocation')->first(); + // $latitude = $geolocation_field->lat; + // $longitude = $geolocation_field->lng; + // if ($latitude && $longitude) { + // $field_geolocation['lat'] = $latitude; + // $field_geolocation['lng'] = $longitude; + // } + // } if ($published == 1) { $nodes_response[] = [ 'id' => $node->id(), 'title' => $node->getTitle(), - 'body' => $body, 'lang' => $node->get('langcode')->value, 'created' => $node->get('created')->value, 'alias' => $node->get('path')->alias, 'author' => $name, + // 'field_geolocation' => $field_geolocation, + // 'field_link' => $field_link, + // 'body' => $body, // 'file' => $this->getFiles($node, 'field_file'), // 'image' => $this->getImages($node, 'field_image'), // 'category_id' => (