Please note that this documentation is for the most recent version of this extension. It may not be relevant for older versions. Related documentation can be found in the documentation directory of the extension.
Manipulate properties after import
In order to manipulate properties after import or creation there is a Signal/Slot and an event in the Openimmo-Extension. This Signal/Slot and event is always executed when for example the ImportCommand creates or changes properties.
In order to use the functionality you need to register an own Slot or event listener in your extension.
via Event Listener
Since version 6.0.9 there is a PSR-14 event available for that. You can find an example in Classes/EventListener/AfterCreationExample.php
, the registration of the event listener is done in Configuration/Services.yaml
.
via Signal/Slot
Create a Slot
First you need to create the Slot. This Slot can be created in a file called EXT:your_extension/Classes/Slot/ImmobilieSlot.php
. In this file define a method that will be executed on receiving the Signal:
<?php
namespace YourVendor\YourExtension\Slot;
/**
* Signal/Slot for immobilie objects
*
* This is just an example slot.
*
* @package openimmo
*
* @author Thomas Deuling <typo3(at)coding(dot)ms>
*/
class ImmobilieSlot
{
/**
* Executed after immobilie creation
*
* @param int $immobilieUid
* @param int $immobilieUid
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
*/
public function afterCreation(int $immobilieUid): void
{
// ...
}
}
There is an example file in our extension in EXT:openimmo/Classes/Slot/ImmobilieSlot.php
.
Register a Slot
You need to register your new Slot so that TYPO3 recognizes it. This also happens in your extension in the file EXT:your_extension/ext_localconf.php
. Here you need the following code:
//
// Example Slot for manipulating immobilie after creation/modification
/** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
$signalSlotDispatcher->connect(
\CodingMs\Openimmo\Command\ImportCommandController::class, 'afterCreation',
\YourVendor\YourExtension\Slot\ImmobilieSlot::class, 'afterCreation'
);
After you have added the code you will need to clear the cache. Then each time properties are created or updated by the importer this method will be executed and you will be able to manipulate them.