Christophe, thank you for the advice!

But what about the console? As far as I understand I am not able to
use all the benefits of the custom mapping type until I have generated
the entities and the DB schema. And, of course, this requires the type
to be registered as well.

The must be a universal solution, and I hope that it will be added to
the Symfony documentation.

On Feb 1, 9:09 pm, Christophe COEVOET <s...@notk.org> wrote:
> Le 01/02/2011 20:04, Alexander Kachkaev a crit :
>
>
>
> > Hello, guys!
>
> > Does anyone know how to integrate a custom doctrine mapping type into
> > a Symfony 2 project?
>
> > There is a great documentation on how to do that simply using Doctrine
> > (http://www.doctrine-project.org/docs/dbal/2.0/en/reference/
> > types.html#custom-mapping-types), but there is no information on the
> > web about how to migrate the registration of the type into Symfony.
>
> > It is said that to register a type it is necessary to write the
> > following:
> > Type::addType('money', 'My\Project\Types\MoneyType');
> > $conn->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney',
> > 'money');
>
> > These lines must be written somewhere in a bootstrap code, e. i. src/
> > autoload.php to make the type available both from controllers and
> > console. The key issue here is in the second line, which requires the
> > connection to be defined. To get it a $entityManager->getConnection()
> > can be called, and EntityManager can be taken from $this-
> >> get('doctrine.orm.entity_manager') if we are in the controller.
> > But how to get the reference to the EntityManager or any other
> > resource object outside the controller (e. g. autoload.php)?
>
> A solution is to make that in the boot() method of your bundle. this
> way, it will be done after the building of the container (so you can
> access the connection) but before you use it.
>
> --
> Christophe | Stof

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to