-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
!!! FEATURE: Overhaul NodeCreationHandlerInterface
#3519
Conversation
@bwaidelich suggested, that instead of passing the Those domain services can be build via This would in turn mean, that the interface NodeCreationHandlerInterface extends ContentRepositoryServiceInterface
{
public function handle(NodeCreationCommands $commands, array $data): NodeCreationCommands;
} and we wouldn't register the 'Neos.Neos:Content':
options:
nodeCreationHandlers:
fooBar:
factoryClassName: 'Some\NodeCreationHandlerFactoryInterface' the factory would look like: interface NodeCreationHandlerFactoryInterface extends ContentRepositoryServiceFactoryInterface
{
public function build(ContentRepositoryServiceFactoryDependencies $serviceFactoryDependencies): NodeCreationHandlerInterface;
} and the |
bb21d12
to
d7b460b
Compare
4f9db10
to
00230e3
Compare
5ca0e4f
to
6f8fd2d
Compare
🎥 End-to-End Test Recordings These videos demonstrate the end-to-end tests for the changes in this pull request. |
db48f62
to
f233e63
Compare
NodeCreationHandler
f233e63
to
0eb406c
Compare
NodeCreationHandler
NodeCreationHandlerInterface
private array $propertyLikeValues, | ||
private array $referenceLikeValues, |
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.
private array $propertyLikeValues, | |
private array $referenceLikeValues, | |
private array $elementValues, |
array<string, NodeAggregateIds|mixed>
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.
as far as I understand it, this DTO is an object that can be used to prime the creation of nodes with some parameters and we (currently) use it to map the values of the NodeCreation dialog.
As mentioned in our weekly today, I wonder why we need to separate the values already at this point. If we do I would suggest $propertyValues
and $referencedNodeAggregateIds
but I would personally prefer to keep this as a simple key-value DTO for arbitrary parameters.
That would mean that the code below would instead of
if (!$elements->hasReferenceLike($referenceName)) {
continue;
}
$setReferencesCommands[] = SetNodeReferences::create(
$commands->first->contentStreamId,
$commands->first->nodeAggregateId,
$commands->first->originDimensionSpacePoint,
ReferenceName::fromString($referenceName),
NodeReferencesToWrite::fromNodeAggregateIds($elements->getReferenceLike($referenceName))
);
be s.th. like:
if (!$parameters->has($referenceName)) {
continue;
}
$setReferencesCommands[] = SetNodeReferences::create(
$commands->first->contentStreamId,
$commands->first->nodeAggregateId,
$commands->first->originDimensionSpacePoint,
ReferenceName::fromString($referenceName),
NodeReferencesToWrite::fromNodeAggregateIds(NodeAggregateIds::fromArrray($parameters->get($referenceName)),
);
(potentially with some error handling if the expected format does not match)
And I would even leave out the deserialization at this point..
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.
Yes thanks i had a little blockade in my brain as i somehow wanted to port the idea of separating properties and references neos/neos-development-collection#4677 into the elements as well.
I also talked to Wilhelm about that and we found that references
might be a little misleading as type here but introducing nodeAggregateIds
or anything else is not worth it.
Its just important to note that the type references
thingies have at that stage nothing in common with real reference edges. There is just a node editor that allows to "references" a node by its id.
I documented it like
The naming
references
in theelement
configuration does not refer to the content repository reference edges.
Referring to a node will just denote that an editor will be used capable of returning node ids.
The node ids might be used for setting references but that is up to a node-creation-handler.
So yes i simplified the vo and now it contains all elements in one blob.
And I would even leave out the deserialisation at this point.
Here i have a strong objection. The data in a format only the neos ui understands. If every handler serialises it differently it leads to bugs like #3719
By encapsulating it we make it an implementation detail and are later-on easier able to change the neos ui serialisation format.
to `PromotedElementsCreationHandler` as in the future it will also handle references. The naming will also better reflect what it does, and that it only handles promote elements (eg ui.showInCreationDialog)
…operties and references At this point, they are all elements and some might have the special case of referring to a node which is done via `type: references`
NodeType configuration, which resides in `ui.creationDialog` is part of the Neos.Neos.Ui
…Postprocessor` ... and colocate code with `PromotedElementsCreationHandler`
…sor` to Neos.Ui Into the `CreationDialogPostprocessor` NodeType configuration, which resides in `ui.creationDialog` is part of the Neos.Neos.Ui
The declaration `showInCreationDialog` was copied over from Neos.Neos and the explicit configuration of `creationDialog.elements.title` is obsolete. The explicit declaration of ui.label: i18n would lead to `Neos.Neos:NodeTypes.Document:creationDialog.title` instead of `Neos.Neos:NodeTypes.Document:properties.title` being used. That made it hard to set a simple title as the translation was more eager. Resolves #3509 The previously used creationDialog translation is now obsolete (resided in Neos.Neos) See also #1539
669d400
to
ea20dc1
Compare
As this is a promoted property, it will otherwise appear "after" the explicit elements, which causes the test > SelectBox opens above in creation dialog if there's not enough space below to fail, and just makes sense correcting
…ntNodeCreationHandler` Normally due to the `showInCreationDialog` property the `PromotedElementsCreationHandler` will handle this already. Also, the references editor with `createNew` will leverage this silently but with #3730 this has to be refactored either way
…420885` As with #3515 the `nodeName` will be null, so we dont need to use it for generating the uripath
Thank you so much for your kind words and the extensive feedback! ❤️ I could answer a few questions already:
It is technically, but 100% marked as footgun and not to do, as it contradicts the intention, and will crash if the ui cant find the node id afterwards ;)
Hmm i think as well that this would be moving to fast and maybe we can implement this for a |
…e Neos.Ui after a discussion with Wilhelm we concluded that this object should rather stay internal and not be part of the api of the Ui
…ationHandlerInterface
the public api is rather the yaml configuration of FlowPack.NodeTemplates
As discussed with Wilhelm and Christian we will make the node creation handlers internal for now, as there is not much demand for the api and the main consumers are the NeosUi itself or Flowpack.NodeTemplates. Currently its not worth to draft out the perfect api and declare it as such, even though the implementation will unlikely change in the next time (hopefully ^^) Additionally using the interface NodeCreationHandlerFactoryInterface
{
public function build(ContentRepository $contentRepository): NodeCreationHandlerInterface;
} but as its internal now either way, it shouldnt matter too much ^^ |
…ationHandlerInterface` in neos/neos-ui#3519
Neos.Neos adjustment neos/neos-development-collection#4630
Replaces: #3720 for Neos9
Resolves: #3615
Resolves: #3509
For now the api will be internal, Flowpack.NodeTemplates provides a good abstraction for this.
The
NodeCreationHandlerInterface
Contract to hook into the process before the node creation command is handled by the content repository
You can add additional steps to the node creation.
For example adding initial properties
NodeCreationCommands::withInitialPropertyValues()
,or queuing additional commands like to create a child via
NodeCreationCommands::withAdditionalCommands()
The node creation handlers factory can be registered on a NodeType:
The factory must implement the
NodeCreationHandlerFactoryInterface
andreturn an implementation with this
NodeCreationHandlerInterface
interface.The current content-repository or NodeType-manager will be accessible via the content repository.
The new signature of the interface is as follows:
Additionally the interface was relocated to
Neos\Neos\Ui\Domain\NodeCreation\NodeCreationHandlerInterface
.The
NodeCreationCommands
A collection of commands that describe a node creation from the Neos Ui.
The node creation can be enriched via a node creation handler.
The first command points to the triggered node creation command.
To not contradict the users intend it is ensured that the initial node
creation will be mostly preserved by only allowing to add additional properties.
Additional commands can be also appended, to be run after the initial node creation command.
All commands will be executed blocking.
You can retrieve the subgraph or the parent node (where the first node will be created in) the following way:
The
NodeCreationElements
Holds the deserialized elements of the submitted node creation dialog form
Elements are configured like properties or references in the schema,
but its up to the node-creation-handler if they are handled in any way or just left out.
Elements that are of simple types or objects, will be available according to its type.
For example myImage will be an actual image object instance.
Elements that refer to nodes are of type
references
orreference
.They will be available as NodeAggregateIds collection.
The naming
references
in theelement
configuration does not refer to the content repository reference edges.Referring to a node will just denote that an editor will be used capable of returning node ids.
The node ids might be used for setting references but that is up to a node-creation-handler.
To promoted properties / references the same rules apply: