snoke / interface-associations
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.2
- doctrine/doctrine-bundle: ^2.12
- doctrine/orm: ^3.2
- symfony/dependency-injection: ^7.1
- symfony/http-kernel: ^7.1
This package is auto-updated.
Last update: 2025-04-16 09:25:40 UTC
README
Bundle for Symfony7 with Doctrine ORM
The Interface Associations Bundle provides a way to replace ORM relations with interfaces and map them to concrete classes at runtime. This enables the development of abstract components.
installation
run composer req snoke/interface-associations
Functionality
The bundle allows configuring remappings. You can specify which classes or interfaces should be replaced by other classes or interfaces, either globally or specifically for certain classes and properties.
configuration
edit config/packages/snoke_interface_associations.yaml
as follows:
snoke_interface_associations: remap: - source: 'App\Interface\EntityInterface' target: 'App\Entity\User' class: 'App\Entity\AuthToken' field: 'user'
-
source: The source class or interface to be remapped.
-
target: The target class to remap to.
-
class (optional): The class where the remapping should be applied. If not specified, the remapping is global.
-
property (optional): The property within the class where the remapping should be applied. If not specified, the remapping applies to all properties of the class.
this way you can produce code having interfaces as relationships
#[ORM\ManyToOne(inversedBy: 'accessTokens')] private EntityInterface $user;