Skip to content

Commit

Permalink
Merge branch hotfix/v2.2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Mar 8, 2024
1 parent ec74b9b commit 5aed91f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src/AjaxControllers/AjaxSearchNodesSourcesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ protected function getNodeSourceData(NodesSources $source): array
/** @var Translation $translation */
$translation = $source->getTranslation();
$displayableNSDoc = $source->getDocumentsByFields()->filter(function (NodesSourcesDocuments $nsDoc) {
return $nsDoc->getDocument()->isImage() || $nsDoc->getDocument()->isSvg();
$doc = $nsDoc->getDocument();
return !$doc->isPrivate() && ($doc->isImage() || $doc->isSvg());
})->first();
if ($displayableNSDoc instanceof NodesSourcesDocuments) {
if (false !== $displayableNSDoc) {
$thumbnail = $displayableNSDoc->getDocument();
$this->documentUrlGenerator->setDocument($thumbnail);
$this->documentUrlGenerator->setOptions([
Expand Down
35 changes: 15 additions & 20 deletions src/Controllers/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Themes\Rozier\Controllers;

use RZ\Roadiz\CoreBundle\Bag\Settings;
use RZ\Roadiz\CoreBundle\Entity\Document;
use RZ\Roadiz\Documents\MediaFinders\RandomImageFinder;
use RZ\Roadiz\Documents\UrlGenerators\DocumentUrlGeneratorInterface;
Expand All @@ -14,31 +15,25 @@

class LoginController extends RozierApp
{
private DocumentUrlGeneratorInterface $documentUrlGenerator;
private RandomImageFinder $randomImageFinder;

/**
* @param DocumentUrlGeneratorInterface $documentUrlGenerator
* @param RandomImageFinder $randomImageFinder
*/
public function __construct(
DocumentUrlGeneratorInterface $documentUrlGenerator,
RandomImageFinder $randomImageFinder
private readonly DocumentUrlGeneratorInterface $documentUrlGenerator,
private readonly RandomImageFinder $randomImageFinder,
private readonly Settings $settingsBag
) {
$this->documentUrlGenerator = $documentUrlGenerator;
$this->randomImageFinder = $randomImageFinder;
}

/**
* @param Request $request
*
* @return Response
*/
public function imageAction(Request $request): Response
{
$response = new JsonResponse();
if (null !== $document = $this->getSettingsBag()->getDocument('login_image')) {
if ($document instanceof Document && $document->isProcessable()) {
$response->setPublic();
$response->setMaxAge(600);

if (null !== $document = $this->settingsBag->getDocument('login_image')) {
if (
$document instanceof Document &&
!$document->isPrivate() &&
$document->isProcessable()
) {
$this->documentUrlGenerator->setDocument($document);
$this->documentUrlGenerator->setOptions([
'width' => 1920,
Expand All @@ -49,7 +44,7 @@ public function imageAction(Request $request): Response
$response->setData([
'url' => $this->documentUrlGenerator->getUrl()
]);
return $this->makeResponseCachable($request, $response, 60, true);
return $response;
}
}

Expand All @@ -62,6 +57,6 @@ public function imageAction(Request $request): Response
$response->setData([
'url' => '/themes/Rozier/static/assets/img/default_login.jpg'
]);
return $this->makeResponseCachable($request, $response, 60, true);
return $response;
}
}
1 change: 1 addition & 0 deletions src/Serialization/DocumentThumbnailSerializeSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function onPostSerialize(ObjectEvent $event): void
if (
$visitor instanceof SerializationVisitorInterface &&
$document instanceof Document &&
!$document->isPrivate() &&
$context->hasAttribute('groups') &&
\is_array($context->getAttribute('groups')) &&
in_array('explorer_thumbnail', $context->getAttribute('groups'))
Expand Down

0 comments on commit 5aed91f

Please sign in to comment.