[TYPO3-mvc] Using repositories in validators

Matthew Colton mat.colton at web-xs.de
Sat Jan 10 15:42:31 CET 2015


I don't know why, but injects didn't work for me in validators (even
after flushing the cache). Here's what I did:

$objectManager =
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$reservationRepository =
$objectManager->get('VENDOR\Extname\Domain\Repository\ReservationRepository');

Cheers
Mat

Am 09.01.2015 um 16:58 schrieb Jonas Eberle:
> Hi Matthew,
>
> Am 19.12.2014 um 17:40 schrieb Matthew Colton:
>> it results in the following PHP error:
>>
>> Fatal error: Call to a member function
>> amountOfReserverationsOfEventDate() on a non-object in
>> /var/www/laks/hessen-szene.de/cms/typo3conf/ext/laks/Classes/Validation/Validator/EnoughTicketsAvailableValidator.php
>>
>> on line 69
> That error is very common if you use @annotations. You need to clear
> the system cache for @inject to work because code annotations are cached.
> I do not see why @inject should not work in a Validator.
>
> Regards,
> Jonas
>



More information about the TYPO3-project-typo3v4mvc mailing list