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@lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german