-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Neos 9 Support #133
Open
samsauter
wants to merge
6
commits into
neos:master
Choose a base branch
from
samsauter:master
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Neos 9 Support #133
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2cd1162
chore: change compatibility to allow neos 9.
samsauter cfeecd0
chore: use new cr models and interfaces in form processors.
samsauter b6f6ef5
chore: replace deprecated fusion prototypes.
samsauter 6be99e8
chore: add .gitignore
samsauter 85de8a9
chore: remove connection to missing / removed node signal slots.
samsauter ed89f4f
chore: fix implementation of Neos.Fusion:Loop - use items instead of …
samsauter File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,22 @@ | ||
# Project files | ||
/.idea/workspace.xml | ||
/.idea/tasks.xml | ||
/.idea/markdown-navigator* | ||
/.idea/shelf | ||
/dev/.vagrant/ | ||
/dev/php_errors.log | ||
/dev/dev-control/ | ||
/dev/db_backup_* | ||
/dev/local.itermocil.yaml | ||
|
||
|
||
# General swap/backup files | ||
*.so | ||
*.log | ||
*.out | ||
*~ | ||
*.swp | ||
*.DS_Store | ||
*.sass-cache* | ||
|
||
!*.gitkeep | ||
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 |
---|---|---|
|
@@ -7,24 +7,29 @@ | |
class SelectOptionCollectionImplementation extends AbstractArrayFusionObject | ||
{ | ||
|
||
protected $ignoreProperties = ['prependOptionLabel', 'prependOptionValue', 'labelPropertyPath', 'valuePropertyPath']; | ||
protected $ignoreProperties = [ | ||
'prependOptionLabel', | ||
'prependOptionValue', | ||
'labelPropertyPath', | ||
'valuePropertyPath' | ||
]; | ||
|
||
public function evaluate() | ||
{ | ||
$collection = $this->getCollection(); | ||
$items = $this->getItems(); | ||
$options = []; | ||
if (!empty($prependLabel = $this->getPrependOptionLabel())) { | ||
$options[$this->getPrependOptionValue()] = $prependLabel; | ||
} | ||
if ($collection === null) { | ||
if ($items === null) { | ||
foreach ($this->properties as $propertyName => $propertyValue) { | ||
if (in_array($propertyName, $this->ignoreProperties)) { | ||
continue; | ||
} | ||
$options[$propertyName] = $propertyValue; | ||
} | ||
} else { | ||
foreach ($collection as $item) { | ||
foreach ($items as $item) { | ||
$value = ObjectAccess::getPropertyPath($item, $this->getValuePropertyPath()); | ||
$label = ObjectAccess::getPropertyPath($item, $this->getLabelPropertyPath()); | ||
if (strlen($label) === 0) { | ||
|
@@ -39,9 +44,9 @@ public function evaluate() | |
/** | ||
* @return array|\Traversable | ||
*/ | ||
private function getCollection() | ||
private function getItems() | ||
{ | ||
return $this->fusionValue('collection'); | ||
return $this->fusionValue('items'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wondering: Why did you rename that? Doesn't that lead to a needless breaking change? |
||
} | ||
|
||
private function getValuePropertyPath(): string | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
<?php | ||
namespace Neos\Form\Builder\NodeType; | ||
|
||
use Neos\ContentRepository\Domain\Model\NodeInterface; | ||
|
||
use Neos\Neos\Ui\NodeCreationHandler\NodeCreationHandlerInterface; | ||
use Neos\ContentRepository\Core\ContentRepository; | ||
use Neos\ContentRepository\Core\Feature\NodeCreation\Command\CreateNodeAggregateWithNode; | ||
|
||
class SelectOptionsCreationHandler implements NodeCreationHandlerInterface | ||
{ | ||
|
||
/** | ||
* @param NodeInterface $node The newly created node | ||
* @param array $data incoming data from the creationDialog | ||
* @return void | ||
* @param CreateNodeAggregateWithNode $command The original node creation command | ||
* @param array<string|int,mixed> $data incoming data from the creationDialog | ||
* @return CreateNodeAggregateWithNode the original command or a new creation command with altered properties | ||
*/ | ||
public function handle(NodeInterface $node, array $data) | ||
public function handle(CreateNodeAggregateWithNode $command, array $data, ContentRepository $contentRepository): CreateNodeAggregateWithNode | ||
{ | ||
if (!$node->getNodeType()->isOfType('Neos.Form.Builder:SelectOption')) { | ||
return; | ||
if (!$contentRepository->getNodeTypeManager()->getNodeType($command->nodeTypeName)->isOfType('Neos.Form.Builder:SelectOption')) { | ||
return $command; | ||
} | ||
|
||
if (isset($data['value'])) { | ||
$node->setProperty('value', $data['value']); | ||
$propertyValues = $propertyValues->withValue('value', $data['value']); | ||
} | ||
if (isset($data['label'])) { | ||
$node->setProperty('label', $data['label']); | ||
$propertyValues = $propertyValues->withValue('label', $data['label']); | ||
} | ||
|
||
return $command->withInitialPropertyValues($propertyValues); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,74 +1,24 @@ | ||
<?php | ||
namespace Neos\Form\Builder; | ||
|
||
use Neos\ContentRepository\Domain\Model\NodeInterface; | ||
use Neos\ContentRepository\Core\Projection\ContentGraph\Node; | ||
use Neos\Eel\FlowQuery\FlowQuery; | ||
use Neos\Flow\Core\Bootstrap; | ||
use Neos\ContentRepository\Domain\Model\Node; | ||
use Neos\Flow\Package\Package as BasePackage; | ||
|
||
/** | ||
* The Package class, wiring signal/slot during boot. | ||
*/ | ||
class Package extends BasePackage | ||
{ | ||
private const NODE_TYPE_IDENTIFIER_MIXIN = 'Neos.Form.Builder:IdentifierMixin'; | ||
|
||
/** | ||
* @param Bootstrap $bootstrap The current bootstrap | ||
* @return void | ||
*/ | ||
public function boot(Bootstrap $bootstrap) | ||
{ | ||
$dispatcher = $bootstrap->getSignalSlotDispatcher(); | ||
|
||
$dispatcher->connect(Node::class, 'nodePropertyChanged', function (NodeInterface $node, $propertyName, $_, $newValue) { | ||
if ($propertyName !== 'identifier' || empty($newValue) || !$node->getNodeType()->isOfType(self::NODE_TYPE_IDENTIFIER_MIXIN)) { | ||
return; | ||
} | ||
|
||
$this->setUniqueFormElementIdentifier($node, $newValue); | ||
}); | ||
|
||
$dispatcher->connect(Node::class, 'nodeAdded', function (NodeInterface $node) { | ||
try { | ||
$identifier = $node->getProperty('identifier'); | ||
|
||
if (empty($identifier) || !$node->getNodeType()->isOfType(self::NODE_TYPE_IDENTIFIER_MIXIN)) { | ||
return; | ||
} | ||
} catch (\Neos\ContentRepository\Exception\NodeException $e) { | ||
return; | ||
} | ||
|
||
$this->setUniqueFormElementIdentifier($node, $identifier); | ||
}); | ||
} | ||
|
||
/** | ||
* @param NodeInterface $node | ||
* @param string $identifier | ||
* @throws \Neos\Eel\Exception | ||
*/ | ||
private function setUniqueFormElementIdentifier(NodeInterface $node, string $identifier): void | ||
{ | ||
/** @noinspection PhpUndefinedMethodInspection */ | ||
$flowQuery = (new FlowQuery([$node]))->context([ | ||
'invisibleContentShown' => true, | ||
'removedContentShown' => true, | ||
'inaccessibleContentShown' => true | ||
]); | ||
$possibleIdentifier = $identifier; | ||
$i = 1; | ||
/** @noinspection PhpUndefinedMethodInspection */ | ||
while ($flowQuery | ||
->closest('[instanceof Neos.Form.Builder:NodeBasedForm]') | ||
// [identifier=".."] matches the Form Element identifier, [_identiier!="..."] excludes the current node | ||
->find(sprintf('[instanceof %s][identifier="%s"][_identifier!="%s"]', | ||
self::NODE_TYPE_IDENTIFIER_MIXIN ,$possibleIdentifier, $node->getIdentifier())) | ||
->count() > 0) { | ||
$possibleIdentifier = $identifier . '-' . $i++; | ||
} | ||
$node->setProperty('identifier', $possibleIdentifier); | ||
# BREAKING in Neos 9: No node signals anymore | ||
# Missing here: Setting of identifier for Neos.Form.Builder:NodeBasedForm on nodePropertyChanged and nodeAdded | ||
} | ||
} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ignore these in your local working copy (
vi .git/info/exclude
)