AfterPackageActivationEvent
New in version 10.3
The event was introduced to replace the Signal/Slot
\TYPO3\
.
The PSR-14 event \TYPO3\
is triggered after a package has been activated.
Attention
This event is dispatched when an extension is activated in the Extension Manager, therefore starting with TYPO3 v11 this event is only dispatched in legacy installations, not in Composer-based installations. Use installer events by Composer for Composer-based installations.
Example
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Package\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Package\Event\AfterPackageActivationEvent;
#[AsEventListener(
identifier: 'my-extension/extension-activated',
)]
final readonly class MyEventListener
{
public function __invoke(AfterPackageActivationEvent $event)
{
if ($event->getPackageKey() === 'my_extension') {
$this->executeInstall();
}
}
private function executeInstall(): void
{
// do something
}
}
New in version 13.0
The PHP attribute \TYPO3\
has been
introduced to tag a PHP class as an event listener. Alternatively, or if you
need to be compatible with older TYPO3 versions, you can also register an
event listener via the Configuration/
file. Switch to
an older version of this page for an example or have a look at the section
Implementing an event listener in your extension.