Skip to content

Commit f48b771

Browse files
author
roadiz-ci
committed
Merge tag v2.4.7 into develop
1 parent 38361a4 commit f48b771

File tree

4 files changed

+134
-5
lines changed

4 files changed

+134
-5
lines changed

config/services.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
parameters:
3-
roadiz_core.cms_version: '2.4.6'
3+
roadiz_core.cms_version: '2.4.7'
44
roadiz_core.cms_version_prefix: 'main'
55
env(APP_NAMESPACE): "roadiz"
66
env(APP_VERSION): "0.1.0"

src/EventSubscriber/CloudflareCacheEventSubscriber.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public static function getSubscribedEvents(): array
4040

4141
protected function supportConfig(): bool
4242
{
43-
return null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache() &&
44-
(
45-
null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache()->getBearer() ||
46-
null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache()->getEmail()
43+
return null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache()
44+
&& (
45+
null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache()->getBearer()
46+
|| null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache()->getEmail()
4747
);
4848
}
4949

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace RZ\Roadiz\CoreBundle\Explorer\Event;
6+
7+
use RZ\Roadiz\Core\AbstractEntities\PersistableInterface;
8+
use Symfony\Contracts\EventDispatcher\Event;
9+
10+
class ExplorerEntityListEvent extends Event
11+
{
12+
/**
13+
* @param class-string<PersistableInterface> $entityName
14+
*/
15+
public function __construct(
16+
private string $entityName,
17+
private array $criteria = [],
18+
private array $ordering = [],
19+
) {
20+
}
21+
22+
/**
23+
* @return class-string<PersistableInterface>
24+
*/
25+
public function getEntityName(): string
26+
{
27+
return $this->entityName;
28+
}
29+
30+
/**
31+
* @param class-string<PersistableInterface> $entityName
32+
*/
33+
public function setEntityName(string $entityName): ExplorerEntityListEvent
34+
{
35+
$this->entityName = $entityName;
36+
37+
return $this;
38+
}
39+
40+
public function getCriteria(): array
41+
{
42+
return $this->criteria;
43+
}
44+
45+
public function setCriteria(array $criteria): ExplorerEntityListEvent
46+
{
47+
$this->criteria = $criteria;
48+
49+
return $this;
50+
}
51+
52+
public function getOrdering(): array
53+
{
54+
return $this->ordering;
55+
}
56+
57+
public function setOrdering(array $ordering): ExplorerEntityListEvent
58+
{
59+
$this->ordering = $ordering;
60+
61+
return $this;
62+
}
63+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace RZ\Roadiz\CoreBundle\Explorer\EventSubscriber;
6+
7+
use RZ\Roadiz\CoreBundle\Entity\Node;
8+
use RZ\Roadiz\CoreBundle\Entity\NodeType;
9+
use RZ\Roadiz\CoreBundle\Explorer\Event\ExplorerEntityListEvent;
10+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
11+
12+
final class NodeExplorerEntityListEventSubscriber implements EventSubscriberInterface
13+
{
14+
public static function getSubscribedEvents(): array
15+
{
16+
return [
17+
ExplorerEntityListEvent::class => ['onNodeExplorerEntityList', 100],
18+
];
19+
}
20+
21+
public function onNodeExplorerEntityList(ExplorerEntityListEvent $event): void
22+
{
23+
$entity = $event->getEntityName();
24+
25+
if (Node::class !== $entity) {
26+
return;
27+
}
28+
29+
$criteria = $event->getCriteria();
30+
$ordering = $event->getOrdering();
31+
32+
if (
33+
!isset($criteria['nodeType'])
34+
|| 1 !== count($criteria['nodeType'])
35+
|| !$criteria['nodeType'][0] instanceof NodeType
36+
) {
37+
return;
38+
}
39+
40+
$event->setEntityName($criteria['nodeType'][0]->getSourceEntityFullQualifiedClassName());
41+
unset($criteria['nodeType']);
42+
$nodeFields = ['position', 'visible', 'locked', 'status', 'nodeName', 'createdAt', 'updatedAt'];
43+
44+
// Prefix all criteria array keys names with "node." and recompose criteria array
45+
$event->setCriteria(array_combine(
46+
array_map(function ($key) use ($nodeFields) {
47+
if (in_array($key, $nodeFields)) {
48+
return 'node.'.$key;
49+
}
50+
51+
return $key;
52+
}, array_keys($criteria)),
53+
array_values($criteria)
54+
));
55+
$event->setOrdering(array_combine(
56+
array_map(function ($key) use ($nodeFields) {
57+
if (in_array($key, $nodeFields)) {
58+
return 'node.'.$key;
59+
}
60+
61+
return $key;
62+
}, array_keys($ordering)),
63+
array_values($ordering)
64+
));
65+
}
66+
}

0 commit comments

Comments
 (0)