diff --git a/lib/Models/src/Core/AbstractEntities/NodeInterface.php b/lib/Models/src/Core/AbstractEntities/NodeInterface.php
new file mode 100644
index 00000000..a3014635
--- /dev/null
+++ b/lib/Models/src/Core/AbstractEntities/NodeInterface.php
@@ -0,0 +1,15 @@
+getDefinition('workflow.registry');
- $strategyDefinition = new Definition(InstanceOfSupportStrategy::class, [Node::class]);
+ $strategyDefinition = new Definition(InstanceOfSupportStrategy::class, [NodeInterface::class]);
$strategyDefinition->setPublic(false);
- $dtoStrategyDefinition = new Definition(InstanceOfSupportStrategy::class, [NodeTreeDto::class]);
- $dtoStrategyDefinition->setPublic(false);
$registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $strategyDefinition]);
- $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $dtoStrategyDefinition]);
}
}
diff --git a/lib/RoadizCoreBundle/src/Entity/Node.php b/lib/RoadizCoreBundle/src/Entity/Node.php
index 18b73384..369d1a63 100644
--- a/lib/RoadizCoreBundle/src/Entity/Node.php
+++ b/lib/RoadizCoreBundle/src/Entity/Node.php
@@ -19,6 +19,7 @@
use RZ\Roadiz\Contracts\NodeType\NodeTypeInterface;
use RZ\Roadiz\Core\AbstractEntities\LeafInterface;
use RZ\Roadiz\Core\AbstractEntities\LeafTrait;
+use RZ\Roadiz\Core\AbstractEntities\NodeInterface;
use RZ\Roadiz\Core\AbstractEntities\TranslationInterface;
use RZ\Roadiz\CoreBundle\Api\Filter as RoadizFilter;
use RZ\Roadiz\CoreBundle\Model\AttributableInterface;
@@ -66,7 +67,7 @@
),
ApiFilter(PropertyFilter::class)
]
-class Node extends AbstractDateTimedPositioned implements LeafInterface, AttributableInterface, Loggable
+class Node extends AbstractDateTimedPositioned implements LeafInterface, AttributableInterface, Loggable, NodeInterface
{
use LeafTrait;
use AttributableTrait;
diff --git a/lib/RoadizCoreBundle/src/Model/NodeTreeDto.php b/lib/RoadizCoreBundle/src/Model/NodeTreeDto.php
index 0c5b688f..e34fbbef 100644
--- a/lib/RoadizCoreBundle/src/Model/NodeTreeDto.php
+++ b/lib/RoadizCoreBundle/src/Model/NodeTreeDto.php
@@ -4,13 +4,13 @@
namespace RZ\Roadiz\CoreBundle\Model;
-use RZ\Roadiz\Core\AbstractEntities\PersistableInterface;
+use RZ\Roadiz\Core\AbstractEntities\NodeInterface;
use RZ\Roadiz\CoreBundle\Entity\Node;
/**
* Doctrine Data transfer object to represent a Node in a tree.
*/
-final class NodeTreeDto implements PersistableInterface
+final class NodeTreeDto implements NodeInterface
{
public NodeTypeTreeDto $nodeType;
public NodesSourcesTreeDto $nodeSource;
diff --git a/lib/RoadizCoreBundle/src/Repository/NodeRepository.php b/lib/RoadizCoreBundle/src/Repository/NodeRepository.php
index e8c0cf7b..618e5495 100644
--- a/lib/RoadizCoreBundle/src/Repository/NodeRepository.php
+++ b/lib/RoadizCoreBundle/src/Repository/NodeRepository.php
@@ -13,6 +13,7 @@
use Doctrine\ORM\Tools\Pagination\Paginator;
use Doctrine\Persistence\ManagerRegistry;
use RZ\Roadiz\Contracts\NodeType\NodeTypeFieldInterface;
+use RZ\Roadiz\Core\AbstractEntities\NodeInterface;
use RZ\Roadiz\Core\AbstractEntities\PersistableInterface;
use RZ\Roadiz\Core\AbstractEntities\TranslationInterface;
use RZ\Roadiz\CoreBundle\Doctrine\Event\QueryBuilder\QueryBuilderApplyEvent;
@@ -1038,10 +1039,10 @@ public function findByReverseNodeAndFieldAndTranslation(
}
/**
- * @param Node $node
+ * @param NodeInterface $node
* @return array
*/
- public function findAllOffspringIdByNode(Node $node): array
+ public function findAllOffspringIdByNode(NodeInterface $node): array
{
$theOffsprings = [];
$in = \array_filter([(int) $node->getId()]);
diff --git a/lib/RoadizCoreBundle/src/Security/Authorization/Voter/NodeVoter.php b/lib/RoadizCoreBundle/src/Security/Authorization/Voter/NodeVoter.php
index 7ddffd07..ca17f851 100644
--- a/lib/RoadizCoreBundle/src/Security/Authorization/Voter/NodeVoter.php
+++ b/lib/RoadizCoreBundle/src/Security/Authorization/Voter/NodeVoter.php
@@ -6,6 +6,7 @@
use Doctrine\Persistence\ManagerRegistry;
use Psr\Cache\CacheItemPoolInterface;
+use RZ\Roadiz\Core\AbstractEntities\NodeInterface;
use RZ\Roadiz\CoreBundle\Entity\Node;
use RZ\Roadiz\CoreBundle\Entity\NodesSources;
use RZ\Roadiz\CoreBundle\Security\Authorization\Chroot\NodeChrootResolver;
@@ -74,7 +75,7 @@ protected function supports(string $attribute, mixed $subject): bool
return false;
}
- if ($subject instanceof Node || $subject instanceof NodesSources) {
+ if ($subject instanceof NodeInterface || $subject instanceof NodesSources) {
return true;
}
@@ -114,7 +115,7 @@ protected function voteOnAttribute(string $attribute, mixed $subject, TokenInter
};
}
- private function isNodeInsideUserChroot(Node $node, Node $chroot, bool $includeChroot = false): bool
+ private function isNodeInsideUserChroot(NodeInterface $node, NodeInterface $chroot, bool $includeChroot = false): bool
{
if (!$includeChroot && $chroot->getId() === $node->getId()) {
return false;
@@ -137,7 +138,7 @@ private function isNodeInsideUserChroot(Node $node, Node $chroot, bool $includeC
return \in_array($node->getId(), $offspringIds, true);
}
- private function isGrantedWithUserChroot(Node $node, UserInterface $user, array|string $roles, bool $includeChroot): bool
+ private function isGrantedWithUserChroot(NodeInterface $node, UserInterface $user, array|string $roles, bool $includeChroot): bool
{
$chroot = $this->chrootResolver->getChroot($user);
if (null === $chroot) {
@@ -173,7 +174,7 @@ private function canEmptyTrash(UserInterface $user): bool
}
- private function canCreate(Node $node, UserInterface $user): bool
+ private function canCreate(NodeInterface $node, UserInterface $user): bool
{
/*
* Creation is allowed only if node is inside user chroot,
@@ -182,7 +183,7 @@ private function canCreate(Node $node, UserInterface $user): bool
return $this->isGrantedWithUserChroot($node, $user, 'ROLE_ACCESS_NODES', true);
}
- private function canRead(Node $node, UserInterface $user): bool
+ private function canRead(NodeInterface $node, UserInterface $user): bool
{
/*
* Read is allowed only if node is inside user chroot,
@@ -191,12 +192,12 @@ private function canRead(Node $node, UserInterface $user): bool
return $this->isGrantedWithUserChroot($node, $user, 'ROLE_ACCESS_NODES', true);
}
- private function canReadLogs(Node $node, UserInterface $user): bool
+ private function canReadLogs(NodeInterface $node, UserInterface $user): bool
{
return $this->isGrantedWithUserChroot($node, $user, ['ROLE_ACCESS_NODES', 'ROLE_ACCESS_LOGS'], false);
}
- private function canEditContent(Node $node, UserInterface $user): bool
+ private function canEditContent(NodeInterface $node, UserInterface $user): bool
{
/*
* Edition is allowed only if node is inside user chroot,
@@ -205,17 +206,17 @@ private function canEditContent(Node $node, UserInterface $user): bool
return $this->isGrantedWithUserChroot($node, $user, 'ROLE_ACCESS_NODES', false);
}
- private function canEditTags(Node $node, UserInterface $user): bool
+ private function canEditTags(NodeInterface $node, UserInterface $user): bool
{
return $this->isGrantedWithUserChroot($node, $user, ['ROLE_ACCESS_NODES', 'ROLE_ACCESS_TAGS'], false);
}
- private function canEditRealms(Node $node, UserInterface $user): bool
+ private function canEditRealms(NodeInterface $node, UserInterface $user): bool
{
return $this->isGrantedWithUserChroot($node, $user, ['ROLE_ACCESS_NODES', 'ROLE_ACCESS_REALM_NODES'], false);
}
- private function canDuplicate(Node $node, UserInterface $user): bool
+ private function canDuplicate(NodeInterface $node, UserInterface $user): bool
{
/*
* Duplication is allowed only if node is inside user chroot,
@@ -224,22 +225,22 @@ private function canDuplicate(Node $node, UserInterface $user): bool
return $this->isGrantedWithUserChroot($node, $user, 'ROLE_ACCESS_NODES', false);
}
- private function canEditSetting(Node $node, UserInterface $user): bool
+ private function canEditSetting(NodeInterface $node, UserInterface $user): bool
{
return $this->isGrantedWithUserChroot($node, $user, 'ROLE_ACCESS_NODES_SETTING', false);
}
- private function canEditStatus(Node $node, UserInterface $user): bool
+ private function canEditStatus(NodeInterface $node, UserInterface $user): bool
{
return $this->isGrantedWithUserChroot($node, $user, 'ROLE_ACCESS_NODES_STATUS', false);
}
- private function canDelete(Node $node, UserInterface $user): bool
+ private function canDelete(NodeInterface $node, UserInterface $user): bool
{
return $this->isGrantedWithUserChroot($node, $user, 'ROLE_ACCESS_NODES_DELETE', false);
}
- private function canEditAttribute(Node $node, UserInterface $user): bool
+ private function canEditAttribute(NodeInterface $node, UserInterface $user): bool
{
return $this->isGrantedWithUserChroot($node, $user, 'ROLE_ACCESS_NODE_ATTRIBUTES', false);
}
diff --git a/lib/Rozier/src/Resources/views/widgets/nodeTree/contextualMenu.html.twig b/lib/Rozier/src/Resources/views/widgets/nodeTree/contextualMenu.html.twig
index d3fd1e7b..db09b53d 100644
--- a/lib/Rozier/src/Resources/views/widgets/nodeTree/contextualMenu.html.twig
+++ b/lib/Rozier/src/Resources/views/widgets/nodeTree/contextualMenu.html.twig
@@ -56,7 +56,7 @@
{% endif %}
- {% if not node.Locked %}
+ {% if not node.locked %}
@@ -76,7 +76,7 @@
href="#"> {% trans %}node.show{% endtrans %}
{% endif %}
- {% if not node.isPublished and workflow_can(node, 'publish') %}
+ {% if not node.published and workflow_can(node, 'publish') %}
|null
+ * @var array|null
*/
- private ?iterable $nodes = null;
+ private ?array $nodes = null;
private ?Tag $tag = null;
private bool $stackTree = false;
private ?array $filters = null;
@@ -120,12 +121,12 @@ public function setAdditionalCriteria(array $additionalCriteria): NodeTreeWidget
}
/**
- * @param Node|NodeTreeDto|null $parent
+ * @param NodeInterface|null $parent
* @param bool $subRequest
*
* @return bool
*/
- protected function canOrderByParent(Node|NodeTreeDto|null $parent = null, bool $subRequest = false): bool
+ protected function canOrderByParent(?NodeInterface $parent = null, bool $subRequest = false): bool
{
if (true === $subRequest || null === $parent) {
return false;
@@ -143,14 +144,14 @@ protected function canOrderByParent(Node|NodeTreeDto|null $parent = null, bool $
}
/**
- * @param Node|NodeTreeDto|null $parent
+ * @param NodeInterface|null $parent
* @param bool $subRequest Default: false
* @param array $additionalCriteria Default: []
* @return NodeTreeDtoListManager
* @throws \ReflectionException
*/
protected function getListManager(
- Node|NodeTreeDto|null $parent = null,
+ ?NodeInterface $parent = null,
bool $subRequest = false,
array $additionalCriteria = []
): NodeTreeDtoListManager {
@@ -205,23 +206,23 @@ protected function getListManager(
}
/**
- * @param Node|NodeTreeDto|null $parent
+ * @param NodeInterface|null $parent
* @param bool $subRequest Default: false
* @return array
* @throws \ReflectionException
*/
- public function getChildrenNodes(Node|NodeTreeDto|null $parent = null, bool $subRequest = false): array
+ public function getChildrenNodes(NodeInterface|null $parent = null, bool $subRequest = false): array
{
return $this->getListManager($parent, $subRequest)->getEntities();
}
/**
- * @param Node|NodeTreeDto|null $parent
+ * @param NodeInterface|null $parent
* @param bool $subRequest Default: false
* @return array
* @throws \ReflectionException
*/
- public function getReachableChildrenNodes(Node|NodeTreeDto|null $parent = null, bool $subRequest = false): array
+ public function getReachableChildrenNodes(?NodeInterface $parent = null, bool $subRequest = false): array
{
return $this->getListManager($parent, $subRequest, [
'nodeType.reachable' => true,
@@ -270,10 +271,10 @@ public function getAvailableTranslations(): array
}
/**
- * @return iterable
+ * @return array
* @throws \ReflectionException
*/
- public function getNodes(): iterable
+ public function getNodes(): array
{
if ($this->includeRootNode && null !== $this->getRootNode()) {
return [$this->getRootNode()];
@@ -290,7 +291,7 @@ public function getNodes(): iterable
/**
* @return array
*/
- public function getTags(Node|NodeTreeDto|null $node): array
+ public function getTags(?NodeInterface $node): array
{
if (null === $node) {
return [];