feat(entity-extension): add entity extension system#59
Open
michalbiarda wants to merge 1 commit into
Open
Conversation
Any module can now add columns to an existing entity's table without modifying the entity class. Extensions are auto-discovered from src/EntityExtension/ directories, merged into the entity schema at boot, and hydrated transparently from the same DB row. Access via the typed extension() accessor which IDEs resolve through @template. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
@markshust This adds a basic Entity extensibility and could later be updated with more complex extensions (using joins, etc.). |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
src/EntityExtension/directories across vendor/modules/app at boot$entity->extension(MyExtension::class)with full IDE type inference via@templateWhat was built
EntityExtensionabstract base class +#[ExtensionOf]attribute to declare which entity a class extendsEntityExtensionRegistrysingleton +EntityExtensionDiscoveryscanner — registered and populated inmodule.phpbootExtensionMetadata+EntityExtensionMetadataFactory— parses extension classes; validates no#[Table], no primary key, no relationshipsEntityMetadata::$extensionsfield (backward-compatible last param) —EntityMetadataFactorymerges extensions and detects column/property name conflicts loud at bootEntity::extension()/setExtension()— typed accessor with@template T of EntityExtensionfor IDE inferenceEntityHydrator— hydrates extension objects from the same DB row; silently skips extensions whose columns are absent (safe during rolling deploys)Repository— INSERT/UPDATE/batch include extension columns; null/default/loud-error policy enforced at save timeSchemaBuilder— extension columns included in table schema for migration diffspackages/database/README.mdupdated with full developer workflowTest plan
🤖 Generated with Claude Code