Manipulate properties after import

In order to manipulate properties after import or creation there is a Signal/Slot in the Openimmo-Extension. This Signal/Slot is always executed when for example the ImportCommandController creates or changes properties.

In order to use the functionality you need to register an own Slot in your extension.

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.