Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
* ),
* "style" = @ContextDefinition("string",
* label = @Translation("Image style")
* ),
* "additional_properties" = @ContextDefinition("list",
* label = @Translation("Additional properties")
* )
* }
* )
Expand Down Expand Up @@ -85,7 +88,7 @@ public function __construct(
*
* @return mixed
*/
public function resolve(FileInterface $entity = NULL, $style, RefinableCacheableDependencyInterface $metadata) {
public function resolve(FileInterface $entity = NULL, $style, array $additional_properties = [], RefinableCacheableDependencyInterface $metadata) {
// Return if we dont have an entity.
if (!$entity) {
return NULL;
Expand Down Expand Up @@ -129,11 +132,18 @@ public function resolve(FileInterface $entity = NULL, $style, RefinableCacheable
$metadata->addCacheableDependency($context->pop());
}

return [
$return = [
'id' => $entity->id(),
'url' => $url,
'width' => $dimensions['width'],
'height' => $dimensions['height'],
];

foreach($additional_properties as $property) {
$return[$property] = $entity->get($property)->value;
}

return $return;
}

return NULL;
Expand Down