Skip to content

Commit

Permalink
BUGFIX: Some 9.0 fixes (#3459)
Browse files Browse the repository at this point in the history
* BUGFIX: Some 9.0 fixes

* TASK: Remove outdated incorrect use statement

---------

Co-authored-by: Anke Häslich <[email protected]>
  • Loading branch information
bwaidelich and ahaeslich authored Apr 12, 2023
1 parent a08a6cb commit a8d780d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 40 deletions.
25 changes: 14 additions & 11 deletions Classes/Domain/Model/Feedback/Operations/Redirect.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<?php
namespace Neos\Neos\Ui\Domain\Model\Feedback\Operations;

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\Service\LinkingService;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
use Neos\Neos\Ui\Domain\Model\FeedbackInterface;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

class Redirect extends AbstractFeedback
{
/**
* @var NodeInterface
* @var \Neos\ContentRepository\Core\Projection\ContentGraph\Node
*/
protected $node;

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

/**
* @Flow\Inject
Expand All @@ -31,18 +32,18 @@ class Redirect extends AbstractFeedback
/**
* Set the node
*
* @param NodeInterface $node
* @param \Neos\ContentRepository\Core\Projection\ContentGraph\Node $node
* @return void
*/
public function setNode(NodeInterface $node)
public function setNode(Node $node)
{
$this->node = $node;
}

/**
* Get the node
*
* @return NodeInterface
* @return Node
*/
public function getNode()
{
Expand All @@ -66,7 +67,7 @@ public function getType()
*/
public function getDescription()
{
return sprintf('Redirect to node "%s".', $this->getNode()->getContextPath());
return sprintf('Redirect to node "%s".', $this->getNode()->getLabel());
}

/**
Expand All @@ -81,7 +82,7 @@ public function isSimilarTo(FeedbackInterface $feedback)
return false;
}

return $this->getNode()->getContextPath() === $feedback->getNode()->getContextPath();
return $this->getNode()->subgraphIdentity->equals($feedback->getNode()->subgraphIdentity);
}

/**
Expand All @@ -94,10 +95,12 @@ public function serializePayload(ControllerContext $controllerContext)
{
$node = $this->getNode();
$redirectUri = $this->linkingService->createNodeUri($controllerContext, $node, null, null, true);
$contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

return [
'redirectUri' => $redirectUri,
'redirectContextPath' => $node->getContextPath()
'redirectContextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(),
];
}
}
25 changes: 18 additions & 7 deletions Classes/Domain/Model/Feedback/Operations/UpdateNodePreviewUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,43 @@
* source code.
*/

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
use Neos\Neos\Ui\Domain\Model\FeedbackInterface;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

class UpdateNodePreviewUrl extends AbstractFeedback
{
/**
* @var NodeInterface
* @var Node
*/
protected $node;

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

/**
* Set the node
*
* @param NodeInterface $node
* @param Node $node
* @return void
*/
public function setNode(NodeInterface $node)
public function setNode(Node $node)
{
$this->node = $node;
}

/**
* Get the node
*
* @return NodeInterface
* @return Node
*/
public function getNode()
{
Expand Down Expand Up @@ -76,7 +85,7 @@ public function isSimilarTo(FeedbackInterface $feedback)
if (!$feedback instanceof UpdateNodePreviewUrl) {
return false;
}
return $this->getNode()->getContextPath() === $feedback->getNode()->getContextPath();
return $this->getNode()->subgraphIdentity->equals($feedback->getNode()->subgraphIdentity);
}

/**
Expand All @@ -92,8 +101,10 @@ public function serializePayload(ControllerContext $controllerContext)
$contextPath = '';
} else {
$nodeInfoHelper = new NodeInfoHelper();
$contentRepository = $this->contentRepositoryRegistry->get($this->node->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
$newPreviewUrl = $nodeInfoHelper->createRedirectToNode($this->node, $controllerContext);
$contextPath = $this->node->getContextPath();
$contextPath = $nodeAddressFactory->createFromNode($this->node)->serializeForUri();
}
return [
'newPreviewUrl' => $newPreviewUrl,
Expand Down
9 changes: 5 additions & 4 deletions Classes/Domain/Model/ReferencingChangeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* source code.
*/

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;


/**
* A change that needs to reference another node
Expand All @@ -22,15 +23,15 @@ interface ReferencingChangeInterface extends ChangeInterface
/**
* Set the reference
*
* @param NodeInterface $reference
* @param Node $reference
* @return void
*/
public function setReference(NodeInterface $reference);
public function setReference(Node $reference);

/**
* Get the reference
*
* @return NodeInterface
* @return Node
*/
public function getReference();
}
1 change: 0 additions & 1 deletion Classes/Domain/Service/NodePropertyConversionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* source code.
*/

use Neos\ContentRepository\Core\Projection\ContentGraph\NodeInterface;
use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\MvcPropertyMappingConfiguration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace Neos\TestNodeTypes\DataSources;

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Neos\Service\DataSource\AbstractDataSource;
use Neos\ContentRepository\Domain\Model\NodeInterface;

class NodeWithDependingPropertiesDataSource extends AbstractDataSource
{
Expand All @@ -12,18 +12,18 @@ class NodeWithDependingPropertiesDataSource extends AbstractDataSource
protected static $identifier = 'node-with-depending-properties-data-source';

/**
* @param NodeInterface $node The node that is currently edited (optional)
* @param Node|null $node The node that is currently edited (optional)
* @param array $arguments Additional arguments (key / value)
* @return array
*/
public function getData(NodeInterface $node = null, array $arguments = [])
public function getData(Node $node = null, array $arguments = []): array
{
$options = range(1, 10);

$evenOrOdd = $arguments['evenOrOdd'];

$filteredOptions = array_filter($options, function ($option) use ($evenOrOdd) {
if ($evenOrOdd == 'even') {
if ($evenOrOdd === 'even') {
return $option % 2 === 0;
} else {
return $option % 2 === 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
* source code.
*/

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Feature\NodeCreation\Command\CreateNodeAggregateWithNode;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Property\PropertyMapper;
use Neos\Flow\Property\TypeConverter\PersistentObjectConverter;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Media\Domain\Model\ImageInterface;
use Neos\Neos\Ui\NodeCreationHandler\NodeCreationHandlerInterface;

Expand All @@ -26,22 +27,17 @@ class ImagePropertyNodeCreationHandler implements NodeCreationHandlerInterface
*/
protected $propertyMapper;

/**
* Set the node title for the newly created Document node
*
* @param NodeInterface $node The newly created node
* @param array $data incoming data from the creationDialog
* @return void
*/
public function handle(NodeInterface $node, array $data)
public function handle(CreateNodeAggregateWithNode $command, array $data, ContentRepository $contentRepository): CreateNodeAggregateWithNode
{
if (!isset($data['image'])) {
return $command;
}
$propertyMappingConfiguration = $this->propertyMapper->buildPropertyMappingConfiguration();
$propertyMappingConfiguration->forProperty('*')->allowAllProperties();
$propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED, true);
$image = $this->propertyMapper->convert($data['image'], ImageInterface::class, $propertyMappingConfiguration);

if (isset($data['image'])) {
$image = $this->propertyMapper->convert($data['image'], ImageInterface::class, $propertyMappingConfiguration);
$node->setProperty('image', $image);
}
$propertyValues = $command->initialPropertyValues->withValue('image', $image);
return $command->withInitialPropertyValues($propertyValues);
}
}

0 comments on commit a8d780d

Please sign in to comment.