-
Notifications
You must be signed in to change notification settings - Fork 9
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 #8 from punktDe/bugfix/use-condtion-from-node-move…
…Into TASK: Use Feedback objects to signal the frontend what actually happened
- Loading branch information
Showing
5 changed files
with
176 additions
and
12 deletions.
There are no files selected for viewing
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,40 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PunktDe\Archivist; | ||
|
||
/* | ||
* This file is part of the PunktDe.Archivist package. | ||
* | ||
* 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\Domain\Model\NodeInterface; | ||
use Neos\Flow\Annotations as Flow; | ||
|
||
/** | ||
* @Flow\Scope("singleton") | ||
*/ | ||
class AffectedNodeStorage | ||
{ | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $affectedNodePaths = []; | ||
|
||
public function addNode(NodeInterface $node): void | ||
{ | ||
$this->affectedNodePaths[] = (string)$node->getContextPath(); | ||
} | ||
|
||
/** | ||
* @param NodeInterface $node | ||
* @return bool | ||
*/ | ||
public function hasNode(NodeInterface $node): bool | ||
{ | ||
return in_array($node->getContextPath(), $this->affectedNodePaths); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PunktDe\Archivist\Aspect; | ||
|
||
/* | ||
* This file is part of the PunktDe.Archivist package. | ||
* | ||
* 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\Domain\Model\NodeInterface; | ||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Flow\Aop\JoinPointInterface; | ||
use Neos\Flow\Log\Utility\LogEnvironment; | ||
use Psr\Log\LoggerInterface; | ||
use PunktDe\Archivist\AffectedNodeStorage; | ||
|
||
/** | ||
* @Flow\Scope("singleton") | ||
* @Flow\Aspect | ||
*/ | ||
class FeedbackCreationAspect | ||
{ | ||
/** | ||
* @Flow\Inject | ||
* @var AffectedNodeStorage | ||
*/ | ||
protected $affectedNodeStorage; | ||
|
||
/** | ||
* @Flow\Inject | ||
* @var LoggerInterface | ||
*/ | ||
protected $logger; | ||
|
||
/** | ||
* @Flow\Around("method(Neos\Neos\Ui\Domain\Model\AbstractChange->addNodeCreatedFeedback())") | ||
* @param JoinPointInterface $joinPoint The current join point | ||
* @return void | ||
*/ | ||
public function addNodeCreatedFeedback(JoinPointInterface $joinPoint): void | ||
{ | ||
/** @var NodeInterface $subject */ | ||
$subject = $joinPoint->getMethodArgument('subject'); | ||
if($subject instanceof NodeInterface && $this->affectedNodeStorage->hasNode($subject)) { | ||
$this->logger->debug('Prevented the original node created feedback, as it would return the wrong node path.', LogEnvironment::fromMethodName(__METHOD__)); | ||
return; | ||
} | ||
|
||
$joinPoint->getAdviceChain()->proceed($joinPoint); | ||
} | ||
} |
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