1

I want to make Doctrine 2 extension, that will add an extra field to entity. I will also need new table. Field and table will be based on my custom annotation added to that entity. I think it must be added somehow in loadClassMetadata event.

can You provide some info how to achieve this?

Yavin
  • 445
  • 3
  • 15

1 Answers1

2

I foud it.

Event Subscriber can subscribe also to ORM tool events, such as postGenerateSchemaTable event.

public function getSubscribedEvents()
{
    return array(
        Doctrine\ORM\Tools\ToolEvents::postGenerateSchemaTable,
        Doctrine\ORM\Tools\ToolEvents::postGenerateSchema,
    );
}

in event you can get schema object, and insert modify it there

$schema = $eventArgs->getSchema();
$schema->createTable( ... )
Yavin
  • 445
  • 3
  • 15