denormalize your doctrine ORM entities
use FOD\OrmDenormalizer\Mapping\Annotation as DENORM;
use this annotation for entity Class
/**
* DBuilding
*
* @ORM\Table(name="denorm_d_building")
* @ORM\Entity(repositoryClass="AppBundle\Repository\Denorm\DBuildingRepository")
* @DENORM\Table
*/
class DBuilding
{
...
}
/**
* DSchool
*
* @ORM\Table(name="denorm_d_school")
* @ORM\Entity(repositoryClass="AppBundle\Repository\Denorm\DSchoolRepository")
* @DENORM\Table(name="school", excludedFields={"title"})
*/
class DSchool
{
...
}
Optional attributes:
name
- specific part of the table name in the new generated denormalized tableexcludeFields
- array of entity field names that will not be processed
# app/config/services.yml
# denormalization table manager (create table)
fod.denorm.table_manager:
class: FOD\OrmDenormalizer\DnTableManager
arguments: ['@doctrine.orm.entity_manager']
# load information about All annotated denormalized entities and write to specific connection denormalized data
fod.denorm.listeners.events_listener:
class: FOD\OrmDenormalizer\Symfony\DnEventsListener
arguments: ['@annotations.reader']
tags:
- {name: doctrine.event_listener, event: onFlush}
- {name: doctrine.event_listener, event: loadClassMetadata}
calls:
- ['setWriteConnection', ['@service_container', 'doctrine.dbal.clickhouse_connection']] # second parameter (string) is service name of doctrine connection
# optional service to register symfony console command generate SQL for create denormalized tables
fod.denorm.command.create_denormalized_tables_command:
class: FOD\OrmDenormalizer\Symfony\Command\CreateDenormalizedTablesCommand
arguments: ['@fod.denorm.table_manager', '@doctrine.orm.entity_manager']
tags:
- {name: console.command}
calls:
- ['setConnection', ['@service_container', 'doctrine.dbal.clickhouse_connection']] # second parameter (string) is service name of doctrine connection
# optional service for help transform ORM QueryBuilder to denormalize DBAL QueryBuilder
fod.denorm.query_builder_transformer:
class: FOD\OrmDenormalizer\Symfony\Services\ORMQueryBuilderTransformer
arguments: ['@fod.denorm.listeners.events_listener', '@doctrine.orm.entity_manager']
$ php bin/console fod:orm-denormalizer:migrations:generate
* run console command with option --force
if you want to execute generated SQL