Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 0 additions & 10 deletions src/CoreBundle/Entity/Listener/SessionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ public function prePersist(Session $session, PrePersistEventArgs $args): void
// $this->checkLimit($repo, $url);
}

/**
* This code is executed when a session is loaded from the database.
*/
public function postLoad(Session $session, LifecycleEventArgs $args): void
{
if ($session->getImage()) {
$session->setImageUrl($this->assetRepository->getAssetUrl($session->getImage()));
}
}

/**
* This code is executed when a session is updated.
*/
Expand Down
13 changes: 11 additions & 2 deletions src/CoreBundle/Entity/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
#[ORM\JoinColumn(name: 'image_id', referencedColumnName: 'id', onDelete: 'SET NULL')]
protected ?Asset $image = null;

#[Groups(['user_subscriptions:sessions', 'session:read', 'session:item:read', 'session:basic'])]
#[Groups(['session:basic'])]
private ?string $imageUrl = null;

#[Groups(['user_subscriptions:sessions', 'session:read', 'session:item:read'])]
Expand Down Expand Up @@ -1197,7 +1197,16 @@ public function setImageUrl(?string $imageUrl): self

public function getImageUrl(): ?string
{
return $this->imageUrl;
$image = $this->getImage();

if ($image instanceof Asset) {
$category = $image->getCategory();
$filename = $image->getTitle();

return sprintf('/assets/%s/%s/%s', $category, $filename, $filename);
}

return null;
}

/**
Expand Down