[Flow] Validation > Exception instead of going back to newAction

Alexander Berl a.berl at outlook.com
Wed Dec 11 13:12:23 CET 2013


It's not that hard actually. You just have to think of a practical
configuration syntax/structure to hold the relevant information, i.e.
doctrine type name/identifier, database type name and type classname.
For example this could work:
..
  doctrine:
    types:
      mydate: # doctrine type identifier
        dbtype: 'date'
	class: 'Acme\Doctrine\Types\MyDateType'


Then read through the configuration array and call the doctrine methods
to register the configured type after the $entityManager has been
created, e.g.:

$entityManager = \Doctrine\ORM\EntityManager::create(...);
foreach ($this->settings['doctrine']['types'] as $type => $config) {
	Types::addType($type, $config['class']);
	$entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping($config['dbtype'], $type);
}

just with safety checks and error handling. Maybe the dbtype setting
could even be an array, so you could register your type class for
multiple database types (date, timestamp, ..).


Regards,
Alexander


Am 11.12.2013 10:51, schrieb Axel Wüstemann:
> Thanks Alexander,
> 
> I'm afraid, tham I'm a bit swamped with it, I'm a beginner in Flow... ;=)
> 
> Axel
> 
> Am 11.12.2013 10:37, schrieb Alexander Berl:
>> You need access to the doctrine entity manager to get the connection.
>> However, the entity manager is capsulated inside the flow persistence
>> manager and not publically getable.
>>
>> The optimal solution would be to add some custom doctrine type
>> configuration within TYPO3.Flow.persistence.doctrine.* and then use that
>> configuration within
>> TYPO3\Flow\Persistence\Doctrine\EntityManagerFactory to setup the
>> doctrine types from configuration.
>> That would even be worth a changeset to contribute to flow.
>>
>> As a rough sample how such a configurable doctrine setup could look, you
>> can refer to my changeset that allows configuration of doctrine event
>> listeners/subscribers:
>>
>> https://review.typo3.org/#/c/19984/6
>>
>> Regards,
>> Alexander
>>
>> Am 10.12.2013 16:10, schrieb Axel Wüstemann:
>>> Am 09.12.2013 11:11, schrieb Alexander Berl:
>>>> maybe you can go a little different way about the core problem with
>>>> the NLS:
>>>> create your own Doctrine Type that formats the DateTime correctly,
>>>> similar to how timezone is handled here:
>>>> http://docs.doctrine-project.org/en/2.0.x/cookbook/working-with-datetime.html
>>>>
>>>>
>>>
>>>
>>> Now I'm wondering how register my DateTime to Flow/Doctrine?
>>>
>>> http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html
>>>
>>>
>>>
>>> Type::addType('money', 'My\Project\Types\MoneyType');
>>> $conn->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney',
>>> 'money');
>>>
>>> Where to put this in the Flow environment?
>> _______________________________________________
>> Flow mailing list
>> Flow at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>>
> 
> 


More information about the Flow mailing list