EventDispatcher (PSR-14 Events)
Register ClassifyContent Event Listener
- Open your Services.yaml or Services.php file from your Extension.
- Add the following code snippet to register the
Classify
event listener:Content
YourVendor\YourSitepackage\EventListner\ClassifyContent:
tags:
- name: event.listener
Copied!
Handling the 'ClassifyContentEvent'
The Classify
event listener handles the Classify
and performs custom logic.
- Create a new PHP class in your TYPO3 extension, e.g.,
EXT:
.your_ sitepackage/ Classes/ Event Listner/ Classify Content. php - Implement the
__
method in the class, which will handle the event. The method should accept ainvoke Classify
object as a parameter.Content Event
namespace YourVendor\YourSitepackage\EventListner;
use CodingFreaks\CfCookiemanager\Event\ClassifyContentEvent;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
class ClassifyContent
{
/**
* Handle the ClassifyContentEvent, handle the provider URL and set the service identifier.
*
* @param ClassifyContentEvent $event The ClassifyContentEvent object
*/
public function __invoke(ClassifyContentEvent $event): void
{
// Custom logic goes here
// Example: Dump a debug message
// DebuggerUtility::var_dump("SitePackage invoke");
// Example: Access the provider URL
// DebuggerUtility::var_dump($event->getProviderURL());
// Example: Set the service identifier
// $event->setServiceIdentifier("TESTServiceIdentifier");
}
}
Copied!
Tip
Please note that you need to replace: YourVendorYourSitepackagewith the correct namespaces for your extension.