diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-68047-EmitASignalForEachMappedObject.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-68047-EmitASignalForEachMappedObject.rst new file mode 100644 index 0000000000000000000000000000000000000000..40bd139d9b1595e7b661beb69577fa79403addb7 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-68047-EmitASignalForEachMappedObject.rst @@ -0,0 +1,8 @@ +====================================================== +Feature: #68047 - Emit a signal for each mapped object +====================================================== + +Description +=========== + +The signal ``afterMappingSingleRow`` is emitted whenever the DataMapper creates an object. \ No newline at end of file diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php index 7bcff55ed3429e246036fd4e5d9bc1f1c65e590a..05831da0a2b81cf3e2c0fee215f36588469bc1da 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php +++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php @@ -82,6 +82,12 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface { */ protected $objectManager; + /** + * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher + * @inject + */ + protected $signalSlotDispatcher; + /** * Maps the given rows on objects * @@ -133,12 +139,22 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface { $object = $this->createEmptyObject($className); $this->persistenceSession->registerObject($object, $row['uid']); $this->thawProperties($object, $row); + $this->emitAfterMappingSingleRow($object); $object->_memorizeCleanState(); $this->persistenceSession->registerReconstitutedEntity($object); } return $object; } + /** + * Emits a signal after mapping a single row. + * + * @param DomainObjectInterface $object The mapped object + */ + protected function emitAfterMappingSingleRow(DomainObjectInterface $object) { + $this->signalSlotDispatcher->dispatch(__CLASS__, 'afterMappingSingleRow', array($object)); + } + /** * Creates a skeleton of the specified object *