Skip to content

Commit

Permalink
feature(CMS-697): Add direct and indirect path for media_image and ad…
Browse files Browse the repository at this point in the history
…just keys for media_file to be the same.
  • Loading branch information
ds-derekchinn committed Dec 18, 2024
1 parent 3ab001f commit d04c000
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions web/modules/custom/sfgov_api/src/Plugin/SfgApi/Media/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function setCustomData($entity) {
$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,
'drupal_indirect_path' => $entity->toUrl()->toString(),
'drupal_direct_path' => $drupal_direct_url,
];
return $custom_data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ class Image extends SfgApiMediaBase {
* {@inheritDoc}
*/
public function setCustomData($entity) {

$custom_data = [];
$referenced_file = $entity->get('field_media_image')->referencedEntities()[0];
$drupal_direct_path = isset($referenced_file) ? $referenced_file->createFileUrl() : NULL;
$custom_data = [
'drupal_indirect_path' => $entity->toUrl()->toString(),
'drupal_direct_path' => $drupal_direct_path,
];
return $custom_data;
}

Expand Down

1 comment on commit d04c000

@aekong
Copy link
Collaborator

@aekong aekong commented on d04c000 Dec 18, 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-1734 for sfgov.

Please sign in to comment.