Allow schema to be extracted from static factory methods #27

Open
opened 2026-08-29 10:11:17 +02:00 by c.fahner · 0 comments
Owner

Currently the schema can only be extracted from the constructor parameters. This prevents constructing different subclasses of the entity based on the document contents. More generally it makes it more difficult to use the constructor for passing values that are not related to database storage.

Entities should be able to implement an interface that defines a static factory method and which overrides the default behavior of extracting fields from the constructor.

The method Schema::fromConstructorParameters() should then also be dropped in favor of a more generally named ::fromClass().

Currently the schema can only be extracted from the constructor parameters. This prevents constructing different subclasses of the entity based on the document contents. More generally it makes it more difficult to use the constructor for passing values that are not related to database storage. Entities should be able to implement an interface that defines a static factory method and which overrides the default behavior of extracting fields from the constructor. The method `Schema::fromConstructorParameters()` should then also be dropped in favor of a more generally named `::fromClass()`.
c.fahner added this to the v0.2 milestone 2026-08-29 10:11:17 +02:00
c.fahner changed title from Allow schema to be extracted from static constructor methods to Allow schema to be extracted from static factory methods 2026-08-29 10:11:28 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
slendium/ocd#27
No description provided.