Skip to content

Commit

Permalink
feature(CMS-697): Add the direct and indirect URL as a part of the pa…
Browse files Browse the repository at this point in the history
…yload for the Drupal API
  • Loading branch information
ds-derekchinn committed Dec 13, 2024
1 parent 9f93976 commit d319980
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions web/modules/custom/sfgov_api/src/Plugin/SfgApi/Media/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ class File extends SfgApiMediaBase {
* {@inheritDoc}
*/
public function setCustomData($entity) {
$referenced_file = $entity->get('field_media_file')->referencedEntities()[0];
$drupal_direct_url = isset($referenced_file) ? $referenced_file->createFileUrl() : NULL;
$custom_data = [
'description' => $entity->get('field_description')->value ?: '',
'published_date' => $entity->get('field_published_date')->value ?: NULL,
'drupal_indirect_url' => $entity->toUrl()->toString(),
'drupal_direct_url' => $drupal_direct_url,
];
return $custom_data;
}
Expand Down

1 comment on commit d319980

@aekong
Copy link
Collaborator

@aekong aekong commented on d319980 Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visit Site

Created multidev environment pr-1732 for sfgov.

Please sign in to comment.