Feature #33838

Add a way to configure Doctrine Mapping Type

Added by Dominique Feyer over 9 years ago. Updated over 6 years ago.

Status:
Resolved
Priority:
Should have
Category:
Persistence
Target version:
-
Start date:
2012-02-10
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

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

#1

Updated by Karsten Dambekalns over 9 years ago

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

Updated by Dominique Feyer over 9 years ago

Same problem in 1.0.2

#3

Updated by Karsten Dambekalns over 9 years ago

  • Tracker changed from Bug to Feature
#4

Updated by Adrian Föder almost 8 years ago

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

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

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 almost 8 years 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 almost 8 years 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.

#7

Updated by Gerrit Code Review over 6 years ago

  • Status changed from Accepted to Under Review

Patch set 2 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at http://review.typo3.org/37559

#8

Updated by Gerrit Code Review over 6 years ago

Patch set 1 for branch 3.0 of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at http://review.typo3.org/37585

#9

Updated by Karsten Dambekalns over 6 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF