Skip to content

Commit

Permalink
Merge tag v2.4.7 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Jan 16, 2025
1 parent 7c3ef91 commit d5ef0e6
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 53 deletions.
29 changes: 29 additions & 0 deletions src/AjaxControllers/AbstractAjaxExplorerController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Themes\Rozier\AjaxControllers;

use RZ\Roadiz\CoreBundle\Explorer\Event\ExplorerEntityListEvent;
use RZ\Roadiz\CoreBundle\Explorer\ExplorerItemFactoryInterface;
use RZ\Roadiz\CoreBundle\ListManager\EntityListManagerInterface;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

abstract class AbstractAjaxExplorerController extends AbstractAjaxController
{
public function __construct(
protected readonly ExplorerItemFactoryInterface $explorerItemFactory,
protected readonly EventDispatcherInterface $eventDispatcher,
SerializerInterface $serializer,
) {
parent::__construct($serializer);
}

public function createEntityListManager(string $entity, array $criteria = [], array $ordering = []): EntityListManagerInterface
{
$event = $this->eventDispatcher->dispatch(new ExplorerEntityListEvent($entity, $criteria, $ordering));

return parent::createEntityListManager($event->getEntityName(), $event->getCriteria(), $event->getOrdering());
}
}
17 changes: 3 additions & 14 deletions src/AjaxControllers/AjaxCustomFormsExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,14 @@
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Exception\NotSupported;
use RZ\Roadiz\CoreBundle\Entity\CustomForm;
use RZ\Roadiz\CoreBundle\Explorer\ExplorerItemFactoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Serializer\SerializerInterface;

final class AjaxCustomFormsExplorerController extends AbstractAjaxController
final class AjaxCustomFormsExplorerController extends AbstractAjaxExplorerController
{
public function __construct(
private readonly ExplorerItemFactoryInterface $explorerItemFactory,
SerializerInterface $serializer,
) {
parent::__construct($serializer);
}

/**
* @return Response JSON response
*/
public function indexAction(Request $request): Response
public function indexAction(Request $request): JsonResponse
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_CUSTOMFORMS');

Expand Down
11 changes: 1 addition & 10 deletions src/AjaxControllers/AjaxDocumentsExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,12 @@

use RZ\Roadiz\CoreBundle\Entity\Document;
use RZ\Roadiz\CoreBundle\Entity\Folder;
use RZ\Roadiz\CoreBundle\Explorer\ExplorerItemFactoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Serializer\SerializerInterface;

final class AjaxDocumentsExplorerController extends AbstractAjaxController
final class AjaxDocumentsExplorerController extends AbstractAjaxExplorerController
{
public function __construct(
private readonly ExplorerItemFactoryInterface $explorerItemFactory,
SerializerInterface $serializer,
) {
parent::__construct($serializer);
}

public function indexAction(Request $request): JsonResponse
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS');
Expand Down
11 changes: 1 addition & 10 deletions src/AjaxControllers/AjaxEntitiesExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,14 @@
use RZ\Roadiz\Core\AbstractEntities\PersistableInterface;
use RZ\Roadiz\CoreBundle\Configuration\JoinNodeTypeFieldConfiguration;
use RZ\Roadiz\CoreBundle\Entity\NodeTypeField;
use RZ\Roadiz\CoreBundle\Explorer\ExplorerItemFactoryInterface;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Yaml\Yaml;

final class AjaxEntitiesExplorerController extends AbstractAjaxController
final class AjaxEntitiesExplorerController extends AbstractAjaxExplorerController
{
public function __construct(
private readonly ExplorerItemFactoryInterface $explorerItemFactory,
SerializerInterface $serializer,
) {
parent::__construct($serializer);
}

protected function getFieldConfiguration(NodeTypeField $nodeTypeField): array
{
if (
Expand Down
3 changes: 3 additions & 0 deletions src/AjaxControllers/AjaxFoldersExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

/**
* Only used to display folders list in document explorer filtering aside.
*/
final class AjaxFoldersExplorerController extends AbstractAjaxController
{
public function indexAction(Request $request): JsonResponse
Expand Down
30 changes: 14 additions & 16 deletions src/AjaxControllers/AjaxNodesExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Exception\NotSupported;
use RZ\Roadiz\CoreBundle\Bag\NodeTypes;
use RZ\Roadiz\CoreBundle\Entity\Node;
use RZ\Roadiz\CoreBundle\Entity\NodesSources;
use RZ\Roadiz\CoreBundle\Entity\NodeType;
use RZ\Roadiz\CoreBundle\Entity\Tag;
use RZ\Roadiz\CoreBundle\EntityApi\NodeTypeApi;
use RZ\Roadiz\CoreBundle\Enum\NodeStatus;
use RZ\Roadiz\CoreBundle\Explorer\AbstractExplorerItem;
use RZ\Roadiz\CoreBundle\Explorer\ExplorerItemFactoryInterface;
Expand All @@ -19,20 +20,21 @@
use RZ\Roadiz\CoreBundle\Security\Authorization\Voter\NodeVoter;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

final class AjaxNodesExplorerController extends AbstractAjaxController
final class AjaxNodesExplorerController extends AbstractAjaxExplorerController
{
public function __construct(
private readonly ExplorerItemFactoryInterface $explorerItemFactory,
private readonly ClientRegistry $clientRegistry,
private readonly NodeSourceSearchHandlerInterface $nodeSourceSearchHandler,
private readonly NodeTypeApi $nodeTypeApi,
private readonly NodeTypes $nodeTypesBag,
ExplorerItemFactoryInterface $explorerItemFactory,
EventDispatcherInterface $eventDispatcher,
SerializerInterface $serializer,
) {
parent::__construct($serializer);
parent::__construct($explorerItemFactory, $eventDispatcher, $serializer);
}

protected function getItemPerPage(): int
Expand All @@ -45,10 +47,7 @@ protected function isSearchEngineAvailable(Request $request): bool
return '' !== $request->get('search') && null !== $this->clientRegistry->getClient();
}

/**
* @return Response JSON response
*/
public function indexAction(Request $request): Response
public function indexAction(Request $request): JsonResponse
{
// Only requires Search permission for nodes
$this->denyAccessUnlessGranted(NodeVoter::SEARCH);
Expand Down Expand Up @@ -87,13 +86,12 @@ protected function parseFilterFromRequest(Request $request): array
}

if ($request->query->has('nodeTypes') && count($request->get('nodeTypes')) > 0) {
$nodeTypeNames = array_map('trim', $request->get('nodeTypes'));

$nodeTypes = $this->nodeTypeApi->getBy([
'name' => $nodeTypeNames,
]);
/** @var NodeType[] $nodeTypes */
$nodeTypes = array_filter(array_map(function ($nodeTypeName) {
return $this->nodeTypesBag->get(trim($nodeTypeName));
}, $request->get('nodeTypes')));

if (null !== $nodeTypes && count($nodeTypes) > 0) {
if (count($nodeTypes) > 0) {
$arrayFilter['nodeType'] = $nodeTypes;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/Explorer/NodeTypeExplorerItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ protected function getColor(): ?string
return $this->nodeType->getColor();
}



public function toArray(): array
{
return [
Expand Down
1 change: 0 additions & 1 deletion src/Resources/app/api/FolderExplorerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function getFolders() {
}
})
.catch((error) => {
// TODO
// Log request error or display a message
throw new Error(error)
})
Expand Down

0 comments on commit d5ef0e6

Please sign in to comment.