Issue
I would like to provide custom (doctrine orm) column type in a bundle, but I don't know how to register them:
Type::addType('my_col', 'MyColType');
$em->getConnection()->getDatabasePlatform()
->registerDoctrineTypeMapping('my_col', 'my_col');
MyBundleClass::boot() looks like a good place, but inside boot(), I can not access container.
Thank you.
Solution
You can use the property container
of the Bundle class to retrieve the right entity manager (usually doctrine.orm.default_entity_manager
)
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Doctrine\ORM\EntityManager;
class AcmeMyBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function boot()
{
/* @var EntityManager $em */
$em = $this->container->get('doctrine.orm.default_entity_manager');
$em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping(...);
}
Answered By - rolebi Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.