Feature #33838

Add a way to configure Doctrine Mapping Type

Added by Dominique Feyer about 2 years ago. Updated 6 months ago.

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

0%

Category:Persistence
Target version:-
PHP Version: Complexity:
Has patch:No
Votes: 0

Description

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:
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#doctrine-mapping-types

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

History

Updated by Karsten Dambekalns about 2 years ago

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

Updated by Dominique Feyer about 2 years ago

Same problem in 1.0.2

Updated by Karsten Dambekalns almost 2 years ago

  • Tracker changed from Bug to Feature

Updated by Adrian Föder 6 months ago

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

1 public 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     });
8 }

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...?

Updated by Alexander Schnitzler 6 months 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.

Updated by Karsten Dambekalns 6 months 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