Support for custom ID generator
- Dominant language
- PHP
- Stars
- 181
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Description
I would like to automatically name a node based on a given prefix then an auto-generated numeric suffix, e.g.:
```
node1/
foobar-0/
foobar-1/
foobar-2/
```
This allows children to be mapped and accessed as an array (e.g. `@Children(filter=foobar-*)`.
This is not currently possible with event listeners as, on update, the child node name is required and the generator is invoked before the event is fired.
It would seem better to me to use a custom generator for this purpose. Doctrine allows a mapping for `@CustomIdGenerator`:
``` php
/**
* @Id @Column(type="string") @GeneratedValue(strategy="CUSTOM")
* @CustomIdGenerator(class="stdClass")
*/
public $id;
```
I don't really see why this cannot be a service, but we could at least copy this in the PHPCR-ODM.
Contributor guide
Research direction
The issue names no files, tests, or entry points. Start by tracing PHPCR-ODM's existing identifier generation and mapping configuration, then compare the requested prefix-and-numeric-suffix behavior with Doctrine's custom generator example. Done should include a defined configuration approach and support for generated child node names during updates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100