-
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5046 from mhsdesign/feature/nodeAccessFlowQueryOp…
…erations FEATURE: 9.0 Node access flow query operations
- Loading branch information
Showing
8 changed files
with
297 additions
and
7 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/IdOperation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
namespace Neos\ContentRepository\NodeAccess\FlowQueryOperations; | ||
|
||
/* | ||
* This file is part of the Neos.ContentRepository package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
use Neos\ContentRepository\Core\Projection\ContentGraph\Node; | ||
use Neos\Eel\FlowQuery\FlowQuery; | ||
use Neos\Eel\FlowQuery\FlowQueryException; | ||
use Neos\Eel\FlowQuery\Operations\AbstractOperation; | ||
|
||
/** | ||
* Used to access the Node's identifier of a ContentRepository Node. | ||
*/ | ||
class IdOperation extends AbstractOperation | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var string | ||
*/ | ||
protected static $shortName = 'id'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var integer | ||
*/ | ||
protected static $priority = 100; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var boolean | ||
*/ | ||
protected static $final = true; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* We can only handle ContentRepository Nodes. | ||
* | ||
* @param array<int, mixed> $context $context onto which this operation should be applied (array or array-like object) | ||
* @return boolean | ||
*/ | ||
public function canEvaluate($context): bool | ||
{ | ||
return (isset($context[0]) && $context[0] instanceof Node); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @param FlowQuery<int,mixed> $flowQuery the FlowQuery object | ||
* @param array<int,mixed> $arguments the arguments for this operation | ||
* @return mixed | ||
* @throws FlowQueryException | ||
*/ | ||
public function evaluate(FlowQuery $flowQuery, array $arguments) | ||
{ | ||
if ($arguments !== []) { | ||
throw new FlowQueryException(static::$shortName . '() does not require any argument.', 1715510778); | ||
} | ||
/** @var array<int,mixed> $context */ | ||
$context = $flowQuery->getContext(); | ||
$node = $context[0] ?? null; | ||
if (!$node instanceof Node) { | ||
return null; | ||
} | ||
return $node->nodeAggregateId->value; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/LabelOperation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
namespace Neos\ContentRepository\NodeAccess\FlowQueryOperations; | ||
|
||
/* | ||
* This file is part of the Neos.ContentRepository package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
use Neos\ContentRepository\Core\Projection\ContentGraph\Node; | ||
use Neos\Eel\FlowQuery\FlowQuery; | ||
use Neos\Eel\FlowQuery\FlowQueryException; | ||
use Neos\Eel\FlowQuery\Operations\AbstractOperation; | ||
|
||
/** | ||
* Used to access the Node's label of a ContentRepository Node. | ||
*/ | ||
class LabelOperation extends AbstractOperation | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var string | ||
*/ | ||
protected static $shortName = 'label'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var integer | ||
*/ | ||
protected static $priority = 100; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var boolean | ||
*/ | ||
protected static $final = true; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* We can only handle ContentRepository Nodes. | ||
* | ||
* @param array<int, mixed> $context $context onto which this operation should be applied (array or array-like object) | ||
* @return boolean | ||
*/ | ||
public function canEvaluate($context): bool | ||
{ | ||
return (isset($context[0]) && $context[0] instanceof Node); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @param FlowQuery<int,mixed> $flowQuery the FlowQuery object | ||
* @param array<int,mixed> $arguments the arguments for this operation | ||
* @return mixed | ||
* @throws FlowQueryException | ||
*/ | ||
public function evaluate(FlowQuery $flowQuery, array $arguments) | ||
{ | ||
if ($arguments !== []) { | ||
throw new FlowQueryException(static::$shortName . '() does not require any argument.', 1715510778); | ||
} | ||
/** @var array<int,mixed> $context */ | ||
$context = $flowQuery->getContext(); | ||
$node = $context[0] ?? null; | ||
if (!$node instanceof Node) { | ||
return null; | ||
} | ||
return $node->getLabel(); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/NodeTypeNameOperation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
namespace Neos\ContentRepository\NodeAccess\FlowQueryOperations; | ||
|
||
/* | ||
* This file is part of the Neos.ContentRepository package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
use Neos\ContentRepository\Core\Projection\ContentGraph\Node; | ||
use Neos\Eel\FlowQuery\FlowQuery; | ||
use Neos\Eel\FlowQuery\FlowQueryException; | ||
use Neos\Eel\FlowQuery\Operations\AbstractOperation; | ||
|
||
/** | ||
* Used to access the NodeTypeName of a ContentRepository Node. | ||
*/ | ||
class NodeTypeNameOperation extends AbstractOperation | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var string | ||
*/ | ||
protected static $shortName = 'nodeTypeName'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var integer | ||
*/ | ||
protected static $priority = 100; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var boolean | ||
*/ | ||
protected static $final = true; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* We can only handle ContentRepository Nodes. | ||
* | ||
* @param array<int, mixed> $context $context onto which this operation should be applied (array or array-like object) | ||
* @return boolean | ||
*/ | ||
public function canEvaluate($context): bool | ||
{ | ||
return (isset($context[0]) && $context[0] instanceof Node); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @param FlowQuery<int,mixed> $flowQuery the FlowQuery object | ||
* @param array<int,mixed> $arguments the arguments for this operation | ||
* @return mixed | ||
* @throws FlowQueryException | ||
*/ | ||
public function evaluate(FlowQuery $flowQuery, array $arguments) | ||
{ | ||
if ($arguments !== []) { | ||
throw new FlowQueryException(static::$shortName . '() does not require any argument.', 1715510778); | ||
} | ||
/** @var array<int,mixed> $context */ | ||
$context = $flowQuery->getContext(); | ||
$node = $context[0] ?? null; | ||
if (!$node instanceof Node) { | ||
return null; | ||
} | ||
return $node->nodeTypeName->value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters