Legacy Format

This manual has been automatically converted from an OpenOffice document. It is a legacy format that does not support all features of a modern documentation. Learn how to update this manual

Using SignalSlots (Hook pendant) to extend femanager:ref:

Introduction:ref:

SignalSlots (former Hooks) are the possibility for other developer to extend the runtime of a femanager process with their own code.

Sample:ref:

As an example let's build an extension which sends username and email address of a new registered user to a defined email address.

Note: this is a little bit useless because there is already a setting in flexform to inform administrators and there is a setting in TypoScript to POST values to a third-party-software, but let's use this case for an example.

Available SignalSlots:ref:

NewController.php:ref:

File

NewController.php

Located in

createAction()

Signal Name

createActionBeforePersist

Available parameters

$user, $this

Description

Use this signal if you want to hook into the process before the new user was persisted

GeneralController.php

File

GeneralController.php

Located in

finalCreate()

Signal Name

finalCreateAfterPersist

Available parameters

$user, $action, $this

Description

Use this signal if you want to hook into the process after the new user was persisted

EditController.php:ref:

File

EditController.php

Located in

updateAction()

Signal Name

updateActionBeforePersist

Available parameters

$user, $this

Description

Use this signal if you want to hook into the process before the user- profile was updated

GeneralController.php

File

GeneralController.php

Located in

updateAllConfirmed()

Signal Name

updateAllConfirmedAfterPersist

Available parameters

$user, $this

Description

Use this signal if you want to hook into the process after the user- profile was updated

?

File

?

Located in

?

Signal Name

?

Available parameters

?

Description

Do you need a new Signal in femanager? Just request one on forge.typo3.org

Use a SignalSlot:ref:

Introduction

As described before, we want to send an email to a defined address every time when a new user is registered.

Creating an extension:ref:

femanagersignalslot/ext_emconf.php:ref:

This file is important to install your new extension – write something like:

<?php

$EM_CONF[$_EXTKEY] = array(
        'title' => 'femanagersignalslot',
        'description' => 'signalslotexample for femanager',
        'state' => 'alpha',
        'version' => '0.0.1',
        'constraints' => array(
                'depends' => array(
                        'extbase' => '6.0.0-6.1.99',
                        'fluid' => '6.0.0-6.1.99',
                        'typo3' => '6.0.0-6.1.99',
                        'femanager' => '1.0.0-1.0.99',
                ),
                'conflicts' => array(
                ),
                'suggests' => array(
                ),
        ),
);

?>

femanagersignalslot/ext_localconf.php:ref:

This is an example how to use a signal from femanager – in this case we decided to use the signal “createActionBeforePersist” in class “In2FemanagerControllerNewController” and want to call a slot in class “In2FemanagersignalslotUtilitySendMail” with methodname “send()”

<?php

$signalSlotDispatcher = t3lib_div::makeInstance('TYPO3\CMS\Extbase\SignalSlot\Dispatcher');
$signalSlotDispatcher->connect(
        'In2\Femanager\Controller\NewController',
        'createActionBeforePersist',
        'In2\Femanagersignalslot\Utility\SendMail',
        'send',
        FALSE
);

?>

femanagersignalslot/Classes/Utility/SendMail.php:ref:

This is our main class which is called every time a new registration process was initiated.

<?php
namespace In2\Femanagersignalslot\Utility;

class SendMail {

        /**
         * Send mail about user information
         *
         * @param \In2\Femanager\Domain\Model\User $user
         * @param \In2\Femanager\Controller\NewController $pObj
         * @return void
         */
        public function send($user, $pObj) {
                $message = '
                        New user registered
                        Username: ' . $user->getUsername() . '
                        Email: ' . $user->getEmail() . '
                ';
                mail('your@email.com', 'SignalSlot Test', $message);
        }
}
?>