[TYPO3-german] afterAllOperations-Hook in Extbase-Extension: $repository->update($model) schlägt fehl
conPassione gmbh
info at conpassione.ch
Wed Jan 23 15:29:04 CET 2013
Hallo Thomas
mir scheint, dass Du etwas updaten willst, was noch gar nicht in die DB
geschrieben wurde.... d.h. wenn der User speichern will, wird zuerst
Deine Funktion aufgerufen, ohne den Datensatz zu speichern. Deshalb
funktioniert dann das Update nicht (keine ID ...). Oder passiert das bei
bereits vorhandenen Datensätzen auch?
Gruss Renzo
--
________________________________________________________________________
Renzo Bauen
conPassione gmbh
T +41 33 345 00 92
M +41 79 330 10 11
http://www.conpassione.ch
TYPO3 Bronce Associate
Am Mittwoch, den 23.01.2013, 14:47 +0100 schrieb Thomas Fricke:
> Hallo Liste,
>
> beim Erstellen/Ändern eines Datensatzes im Backend möchte ich (unter
> bestimmten Voraussetzungen) eingreifen und eine E-Mail versenden. Dazu
> verwende ich den Hook "processDatamap_afterAllOperations()", was an sich
> auch prima funktioniert. Sobald ich in der Funktion aber eine Änderung
> an dem Datensatz vornehmen und diese via
> $eventRepository->update($event) speichern will, erhalte ich diese
> Fehlermeldung, die darauf schließen lässt, dass das Backend nicht
> verfügbar ist:
>
> "Fatal error: Call to a member function replaceObject() on a non-object
> in
> /typo3_src-4.7.7/typo3/sysext/extbase/Classes/Persistence/Repository.php
> on line 222"
>
> Das Repository ist vorhanden (mit t3lib_div::makeInstance(), weil mir
> das Injecten in der Hookklasse nicht zur Verfügung steht) und andere
> Abfragen ans Repository, z.B. findByUid(), funktionieren auch tadellos
> (daher müsste doch das Backend eigentlich verfügbar sein, oder?).
> Weiß jemand, was dort los ist, bzw. warum beim update() plötzlich kein
> Backend mehr verfügbar zu sein scheint?
>
> Hier noch etwas Code:
>
>
> // Einbinden des Hooks in der ext_localconf.php:
> $GLOBALS
> ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][]
> =
> 'EXT:' . $_EXTKEY .
> '/Classes/Utility/TceMainHook.php:Tx_WrCalendar_Utility_TceMainHook';
>
>
>
> // Relevanter Code aus der Hookklasse:
> <?php
> class Tx_WrCalendar_Utility_TceMainHook {
>
> /**
> * @param $pObj
> */
> public function processDatamap_afterAllOperations(&$pObj) {
>
> foreach ($pObj->datamap as $table => $data) {
> foreach($data as $id => $fields) {
>
> if (strpos($id, 'NEW')) {
> $newUid = $pObj->substNEWwithIDs[$id];
> } else {
> $newUid = $id;
> }
>
> $eventRepository =
> t3lib_div::makeInstance('Tx_WrCalendar_Domain_Repository_EventRepository');
> *$event = $eventRepository->findByUid($newUid); // WORKS FINE*
>
> if ($event instanceof Tx_WrCalendar_Domain_Model_Event) {
> [snip] removed some irrelevant logic [/snip]
> $event->setApproved(TRUE);
> *$eventRepository->update($event); // THROWS ERROR*
> }
> }
> }
> }
> }
> ?>
>
> Gruß und vielen Dank,
> Thomas F.
> _______________________________________________
> TYPO3-german mailing list
> TYPO3-german at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german
More information about the TYPO3-german
mailing list