Skip to content

Commit d319980

Browse files
committed
feature(CMS-697): Add the direct and indirect URL as a part of the payload for the Drupal API
1 parent 9f93976 commit d319980

File tree

1 file changed

+4
-0
lines changed
  • web/modules/custom/sfgov_api/src/Plugin/SfgApi/Media

1 file changed

+4
-0
lines changed

web/modules/custom/sfgov_api/src/Plugin/SfgApi/Media/File.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ class File extends SfgApiMediaBase {
2525
* {@inheritDoc}
2626
*/
2727
public function setCustomData($entity) {
28+
$referenced_file = $entity->get('field_media_file')->referencedEntities()[0];
29+
$drupal_direct_url = isset($referenced_file) ? $referenced_file->createFileUrl() : NULL;
2830
$custom_data = [
2931
'description' => $entity->get('field_description')->value ?: '',
3032
'published_date' => $entity->get('field_published_date')->value ?: NULL,
33+
'drupal_indirect_url' => $entity->toUrl()->toString(),
34+
'drupal_direct_url' => $drupal_direct_url,
3135
];
3236
return $custom_data;
3337
}

0 commit comments

Comments
 (0)