Feature #33838

Add a way to configure Doctrine Mapping Type

Added by Dominique Feyer about 3 years ago. Updated over 1 year ago.

Status:Accepted Start date:2012-02-10
Priority:Should have Due date:
Assigned To:Karsten Dambekalns % Done:


Target version:-
PHP Version: Complexity:
Has patch:No


As I need some JSON object storage in FLOW3, i need to use a custome Doctrine Mapping Type to handle to conversion between object and database.

As the documentation of Doctrine2 say here:

Doctrine looks really flexible on this point, and if you found a solution to enable this in FLOW3 this could amazing.

The main problem is that $bootstrap->getEarlyInstance('Doctrine\ORM\EntityManager') or getObjectManager()->get('Doctrine\ORM\EntityManager') always return NULL in the boot method of the file package.php


#1 Updated by Karsten Dambekalns about 3 years ago

  • Category set to Persistence
  • Status changed from New to Accepted

#2 Updated by Dominique Feyer about 3 years ago

Same problem in 1.0.2

#3 Updated by Karsten Dambekalns almost 3 years ago

  • Tracker changed from Bug to Feature

#4 Updated by Adrian Föder over 1 year ago

it looks like you can do the following, at least, Package.php:

1public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap) {
2    $dispatcher = $bootstrap->getSignalSlotDispatcher();
3    $dispatcher->connect('TYPO3\Flow\Core\Booting\Sequence', 'afterInvokeStep', function(\TYPO3\Flow\Core\Booting\Step $step) {
4        if ($step->getIdentifier() === 'typo3.flow:persistence') {
5            \Doctrine\DBAL\Types\Type::addType('yourtype', 'Your\Whatever\Type');
6        }
7    });

The original "idea" of this approach can be seen here, https://github.com/Flowpack/Flowpack.ElasticSearch/blob/master/Classes/Flowpack/ElasticSearch/Package.php

// edit/update: I doubt whether that signal/slot-delay is necessary at all? Since Type::addType is statically accessed, no need to "wait" for the EntityManger or so to be available and factory'd...?

#5 Updated by Alexander Schnitzler over 1 year ago

As Adrian said it's possible to use \Doctrine\DBAL\Types\Type::addType('yourtype', 'Your\Whatever\Type'); and so on to add a new mapping type but unfortunately flow does not have a look at the mapping at all.

So imagine you want to use a geographical point object with latitude and longitude as a model property but save it as string (0.3434224,12.433445) the annotation reflection expects you to add a OneToOne-Statement though you do not want to save a related object. So the annotation parser somewhen and somehow has to look for custom mapping types.

#6 Updated by Karsten Dambekalns over 1 year ago

Alexander Schnitzler wrote:

As Adrian said it's possible to use \Doctrine\DBAL\Types\Type::addType('yourtype', 'Your\Whatever\Type'); and so on to add a new mapping type but unfortunately flow does not have a look at the mapping at all.

It does take it into account, but you need register in two places to make it work. Check https://review.typo3.org/22825 for how it works. To be fair, this isn't accessible to the "end user" so far.

Also available in: Atom PDF