This gist is about using a Multi-Tenancy strategy for your Doctrine entities.
Multi-tenancy is an architecture in which a single instance of a software application serves multiple customers. Each customer is called a tenant. Tenants may be given the ability to customize some parts of the application [...] but they cannot customize the application's code.
All files are here: https://gist.github.com/CarlosEduardo/aedfa640e3f7f22451686fb7e57228e3
The Doctrine Multi-Tenancy strategy is a:
TenantFilterclass derived fromDoctrine\ORM\Query\Filter\SQLFilter(seeTenantFilter.php)TenantAwareInterfaceinterface to filter your entities (seeTenantAwareInterface.php)ExampleEntityclass as an@ORM\Entityimplements the interface (seeExampleEntity.php)
For Zend Framework with DoctrineORMModule users:
- Register the
tenantfilter in yourconfig/module.config.php(see:module.config.php) - Enable
tenantfilter in yourModule.phpatModule::onBootstrap()(see:Module.php)
For Symphony users:
- Register and enable the
tenantfilter in yourconfig.yml(see:config.yml)
For pure Doctrine (or another framework) users:
- Register and enable the
tenantfilter in any bootstrap file (see:pure-doctrine.php)
Sorry for my bad english :)
Twitter: @CarlosEduardo | E-mail: [email protected]
Reference: http://doctrine2.readthedocs.io/en/latest/reference/filters.html