Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Adjust to removed NodeTypeFallback #3632

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Classes/ContentRepository/Service/NodeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/**
* @Flow\Scope("singleton")
*/
class NodeService
{
/**
* @Flow\Inject
* @var ContentRepositoryRegistry
*/
protected $contentRepositoryRegistry;
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* Helper method to retrieve the closest document for a node
*/
public function getClosestDocument(Node $node): ?Node
{
if ($node->nodeType->isOfType('Neos.Neos:Document')) {
if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) {
return $node;
}

$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);

while ($node instanceof Node) {
if ($node->nodeType->isOfType('Neos.Neos:Document')) {
if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) {
return $node;
}
$node = $subgraph->findParentNode($node->nodeAggregateId);
Expand Down
14 changes: 7 additions & 7 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@
use Neos\Neos\PendingChangesProjection\ChangeFinder;
use Neos\Neos\Service\UserService;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RemoveNode;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/**
* @Flow\Scope("singleton")
*/
class WorkspaceService
{
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* @Flow\Inject
* @var UserService
Expand All @@ -44,12 +50,6 @@ class WorkspaceService
*/
protected $domainUserService;

/**
* @Flow\Inject
* @var ContentRepositoryRegistry
*/
protected $contentRepositoryRegistry;

/**
* Get all publishable node context paths for a workspace
*
Expand Down Expand Up @@ -207,7 +207,7 @@ private function getClosestDocumentNode(Node $node): ?Node
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);

while ($node instanceof Node) {
if ($node->nodeType->isOfType('Neos.Neos:Document')) {
if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) {
return $node;
}
$node = $subgraph->findParentNode($node->nodeAggregateId);
Expand Down
14 changes: 7 additions & 7 deletions Classes/Domain/Model/AbstractChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\NodeCreated;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadDocument;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateWorkspaceInfo;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

abstract class AbstractChange implements ChangeInterface
{
use NodeTypeWithFallbackProvider;

protected ?Node $subject;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* @Flow\Inject
* @var FeedbackCollection
Expand All @@ -42,12 +48,6 @@ abstract class AbstractChange implements ChangeInterface
*/
protected $persistenceManager;

/**
* @Flow\Inject
* @var ContentRepositoryRegistry
*/
protected $contentRepositoryRegistry;

public function setSubject(Node $subject): void
{
$this->subject = $subject;
Expand Down Expand Up @@ -81,7 +81,7 @@ protected function updateWorkspaceInfo(): void
final protected function findClosestDocumentNode(Node $node): ?Node
{
while ($node instanceof Node) {
if ($node->nodeType->isOfType('Neos.Neos:Document')) {
if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) {
return $node;
}
$node = $this->findParentNode($node);
Expand Down
20 changes: 10 additions & 10 deletions Classes/Domain/Model/Changes/AbstractStructuralChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RenderContentOutOfBand;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateNodeInfo;
use Neos\Neos\Ui\Domain\Model\RenderedNodeDomAddress;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/**
* A change that performs structural actions like moving or creating nodes
*/
abstract class AbstractStructuralChange extends AbstractChange
{
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* The node dom address for the parent node of the created node
*/
Expand All @@ -48,12 +54,6 @@ abstract class AbstractStructuralChange extends AbstractChange
*/
protected $nodeService;

/**
* @Flow\Inject
* @var ContentRepositoryRegistry
*/
protected $contentRepositoryRegistry;

protected ?Node $cachedSiblingNode = null;

/**
Expand Down Expand Up @@ -146,14 +146,14 @@ protected function finish(Node $node)

$this->updateWorkspaceInfo();

if ($node->nodeType->isOfType('Neos.Neos:Content')
if ($this->getNodeType($node)->isOfType('Neos.Neos:Content')
&& ($this->getParentDomAddress() || $this->getSiblingDomAddress())) {
// we can ONLY render out of band if:
// 1) the parent of our new (or copied or moved) node is a ContentCollection;
// so we can directly update an element of this content collection

$contentRepository = $this->contentRepositoryRegistry->get($parentNode->subgraphIdentity->contentRepositoryId);
if ($parentNode && $parentNode->nodeType->isOfType('Neos.Neos:ContentCollection') &&
if ($parentNode && $this->getNodeType($parentNode)->isOfType('Neos.Neos:ContentCollection') &&
// 2) the parent DOM address (i.e. the closest RENDERED node in DOM is actually the ContentCollection;
// and no other node in between
$this->getParentDomAddress() &&
Expand Down Expand Up @@ -189,12 +189,12 @@ protected function isNodeTypeAllowedAsChildNode(Node $node, NodeType $nodeType):
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);
if ($node->classification === NodeAggregateClassification::CLASSIFICATION_TETHERED) {
$parentNode = $subgraph->findParentNode($node->nodeAggregateId);
return !$parentNode || $parentNode->nodeType->allowsGrandchildNodeType(
return !$parentNode || $this->getNodeType($parentNode)->allowsGrandchildNodeType(
$node->nodeName->value,
$nodeType
);
} else {
return $node->nodeType->allowsChildNodeType($nodeType);
return $this->getNodeType($node)->allowsChildNodeType($nodeType);
}
}
}
17 changes: 12 additions & 5 deletions Classes/Domain/Model/Changes/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds;
use Neos\ContentRepository\Core\SharedModel\Node\NodeVariantSelectionStrategy;
use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Ui\Domain\Model\AbstractChange;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadContentOutOfBand;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateNodeInfo;
use Neos\Neos\Ui\Domain\Model\RenderedNodeDomAddress;
use Neos\Neos\Ui\Domain\Service\NodePropertyConversionService;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/** @codingStandardsIgnoreStart */
/** @codingStandardsIgnoreEnd */
Expand All @@ -44,6 +46,11 @@
*/
class Property extends AbstractChange
{
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* @Flow\Inject
* @var NodePropertyConversionService
Expand Down Expand Up @@ -147,7 +154,7 @@ public function apply(): void
if ($this->canApply() && !is_null($subject) && !is_null($propertyName)) {
$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);

$propertyType = $subject->nodeType->getPropertyType($propertyName);
$propertyType = $this->getNodeType($subject)->getPropertyType($propertyName);

// Use extra commands for reference handling
if ($propertyType === 'reference' || $propertyType === 'references') {
Expand Down Expand Up @@ -180,7 +187,7 @@ public function apply(): void
);
} else {
$value = $this->nodePropertyConversionService->convert(
$subject->nodeType,
$this->getNodeType($subject),
$propertyName,
$this->getValue()
);
Expand Down Expand Up @@ -273,10 +280,10 @@ public function apply(): void
$this->feedbackCollection->add($updateNodeInfo);

$reloadIfChangedConfigurationPath = sprintf('properties.%s.ui.reloadIfChanged', $propertyName);
if (!$this->getIsInline() && $node->nodeType->getConfiguration($reloadIfChangedConfigurationPath)) {
if (!$this->getIsInline() && $this->getNodeType($node)->getConfiguration($reloadIfChangedConfigurationPath)) {
if ($this->getNodeDomAddress() && $this->getNodeDomAddress()->getFusionPath()
&& $parentNode
&& $parentNode->nodeType->isOfType('Neos.Neos:ContentCollection')) {
&& $this->getNodeType($parentNode)->isOfType('Neos.Neos:ContentCollection')) {
$reloadContentOutOfBand = new ReloadContentOutOfBand();
$reloadContentOutOfBand->setNode($node);
$reloadContentOutOfBand->setNodeDomAddress($this->getNodeDomAddress());
Expand All @@ -288,7 +295,7 @@ public function apply(): void

$reloadPageIfChangedConfigurationPath = sprintf('properties.%s.ui.reloadPageIfChanged', $propertyName);
if (!$this->getIsInline()
&& $node->nodeType->getConfiguration($reloadPageIfChangedConfigurationPath)) {
&& $this->getNodeType($node)->getConfiguration($reloadPageIfChangedConfigurationPath)) {
$this->reloadDocument($node);
}
}
Expand Down
14 changes: 7 additions & 7 deletions Classes/Domain/Model/Feedback/Operations/NodeCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
use Neos\Neos\Ui\Domain\Model\FeedbackInterface;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

class NodeCreated extends AbstractFeedback
{
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* @var Node
*/
protected $node;

/**
* @Flow\Inject
* @var ContentRepositoryRegistry
*/
protected $contentRepositoryRegistry;

/**
* Set the node
*/
Expand Down Expand Up @@ -97,7 +97,7 @@ public function serializePayload(ControllerContext $controllerContext)
return [
'contextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(),
'identifier' => $node->nodeAggregateId->value,
'isDocument' => $node->nodeType->isOfType(NodeTypeNameFactory::NAME_DOCUMENT)
'isDocument' => $this->getNodeType($node)->isOfType(NodeTypeNameFactory::NAME_DOCUMENT)
];
}
}
19 changes: 9 additions & 10 deletions Classes/Domain/Service/NodePropertyConverterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindReferencesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\Reference;
use Neos\ContentRepository\Core\Projection\ContentGraph\References;
use Neos\ContentRepository\Core\Projection\NodeHiddenState\NodeHiddenStateFinder;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
Expand All @@ -30,6 +29,7 @@
use Neos\Flow\Property\PropertyMappingConfiguration;
use Neos\Flow\Property\PropertyMappingConfigurationInterface;
use Neos\Flow\Property\TypeConverterInterface;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;
use Neos\Utility\ObjectAccess;
use Neos\Utility\TypeHandling;
use Psr\Log\LoggerInterface;
Expand All @@ -44,6 +44,11 @@
*/
class NodePropertyConverterService
{
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* @Flow\InjectConfiguration(package="Neos.Neos", path="userInterface.inspector.dataTypes")
* @var array<string,array<string,mixed>>
Expand Down Expand Up @@ -78,12 +83,6 @@ class NodePropertyConverterService
*/
private $throwableStorage;

/**
* @Flow\Inject
* @var ContentRepositoryRegistry
*/
protected $contentRepositoryRegistry;

/**
* @param LoggerInterface $logger
*/
Expand Down Expand Up @@ -119,7 +118,7 @@ public function getProperty(Node $node, $propertyName)
$node->nodeAggregateId
)->isHidden;
}
$propertyType = $node->nodeType->getPropertyType($propertyName);
$propertyType = $this->getNodeType($node)->getPropertyType($propertyName);

// We handle "reference" and "references" differently than other properties;
// because we need to use another API for querying these references.
Expand Down Expand Up @@ -160,7 +159,7 @@ public function getProperty(Node $node, $propertyName)
}

if ($convertedValue === null) {
$convertedValue = $this->getDefaultValueForProperty($node->nodeType, $propertyName);
$convertedValue = $this->getDefaultValueForProperty($this->getNodeType($node), $propertyName);
if ($convertedValue !== null) {
try {
$convertedValue = $this->convertValue($convertedValue, $propertyType);
Expand Down Expand Up @@ -196,7 +195,7 @@ private function toNodeIdentifierStrings(References $references): array
public function getPropertiesArray(Node $node)
{
$properties = [];
foreach ($node->nodeType->getProperties() as $propertyName => $propertyConfiguration) {
foreach ($this->getNodeType($node)->getProperties() as $propertyName => $propertyConfiguration) {
if ($propertyName[0] === '_' && $propertyName[1] === '_') {
// skip fully-private properties
continue;
Expand Down
Loading
Loading