Merge pull request #5735 from christianbeeznest/fixes-updates42

Internal: Fix ImageURL Handling for Session Entity
pull/5736/head
christianbeeznest 1 year ago committed by GitHub
commit 96ed0e1e69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      src/CoreBundle/Entity/Listener/SessionListener.php
  2. 13
      src/CoreBundle/Entity/Session.php

@ -49,16 +49,6 @@ class SessionListener
// $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.
*/

@ -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'])]
@ -1197,7 +1197,16 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
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;
}
/**

Loading…
Cancel
Save