Events
After deserialization
An event that is dispatched after request payload is deserialized to objects. May be useful when it is needed e.g. to change datetime property to current or assign current TYPO3 user as an author. This event gives access to following data:
operation- instance of\SourceBroker\ T3api\ Domain\ Model\ Operation Interface object- object deserialized from payload
Example event registration in Services.:
V\Site\EventListener\AfterDeserializeOperationEventListener:
tags:
- name: 'event.listener'
Example implementation:
<?php
namespace V\Site\EventListener;
use SourceBroker\T3api\Event\AfterDeserializeOperationEvent;
class AfterDeserializeOperationEventListener
{
public function __invoke(AfterDeserializeOperationEvent $event): void
{
$operation = $event->getOperation();
$object = $event->getObject();
...
$event->setObject($object);
}
}
After processing operation
An event that is dispatched after an operation is processed and before objects are passed to the serializer. This event gives access to following data:
operation- instance of\SourceBroker\ T3api\ Domain\ Model\ Operation Interface result- instance of resource class (entity) or, in collection GET request, instance of\Source(Broker\ T3api\ Response\ Abstract Collection Response \Sourceby default if not customized)Broker\ T3api\ Response\ Hydra Collection Response
Example event registration in Services.:
V\Site\EventListener\AfterProcessOperationEventListener:
tags:
- name: 'event.listener'
Example implementation:
<?php
namespace V\Site\EventListener;
use SourceBroker\T3api\Event\AfterProcessOperationEvent;
class AfterProcessOperationEventListener
{
public function __invoke(AfterProcessOperationEvent $event): void
{
$operation = $event->getOperation();
$result = $event->getResult();
}
}
After create context for operation
Event emitted during building serialization context. Useful to modify serialization context attributes (e.g. add groups which can conditionally include some properties in API response). This event gives access to following data:
operation- instance of\SourceBroker\ T3api\ Domain\ Model\ Operation Interface request- instance ofSymfony\Component\ Http Foundation\ Request context- instance ofJMS\(orSerializer\ Serialization Context JMS\when context for deserialization of request payload is created)Serializer\ Deserialization Context
Example event registration in Services.:
V\Site\EventListener\AfterCreateContextForOperationEventListener:
tags:
- name: 'event.listener'
Example implementation:
<?php
namespace V\Site\EventListener;
use SourceBroker\T3api\Event\AfterCreateContextForOperationEvent;
class AfterCreateContextForOperationEventListener
{
public function __invoke(AfterCreateContextForOperationEvent $event): void
{
$operation = $event->getOperation();
$request = $event->getRequest();
$context = $event->getContext();
}
}
Before grant access
\Source and \Source
are services used to decide if filter or operation are allowed for current request
(check security documentation for more information).
There are 3 events dispatched before evaluation of security expressions.
Note
Before using these events consider if build-in TYPO3 mechanism to extend expression language won't be a better solution. Keep in mind that registering variables within these events will make it available only in t3api context while using TYPO3 mechanism makes it possible to be used also in other places (e.g. TypoScript conditions).
Before grant operation access
Event dispatched before grant operation access. This event gives access to following data:
operation- instance of\SourceBroker\ T3api\ Domain\ Model\ Operation Interface expression- array of variables passed to expression language (empty array)Language Variables
Example event registration in Services.:
V\Site\EventListener\BeforeOperationAccessGrantedEventListener:
tags:
- name: 'event.listener'
Example implementation:
<?php
namespace V\Site\EventListener;
use SourceBroker\T3api\Event\BeforeOperationAccessGrantedEvent;
class BeforeOperationAccessGrantedEventListener
{
public function __invoke(BeforeOperationAccessGrantedEvent $event): void
{
$operation = $event->getOperation();
$expressionLanguageVariables = $event->getExpressionLanguageVariables();
...
}
}
Before grant post denormalize operation access
Event dispatched before grant post denormalize operation access. This event gives access to following data:
operation- instance of\SourceBroker\ T3api\ Domain\ Model\ Operation Interface expression- array of variables passed to expression language (contains denormalizedLanguage Variables object)
Example event registration in Services.:
V\Site\EventListener\BeforeOperationAccessGrantedPostDenormalizeEventListener:
tags:
- name: 'event.listener'
Example implementation:
<?php
namespace V\Site\EventListener;
use SourceBroker\T3api\Event\BeforeOperationAccessGrantedPostDenormalizeEvent;
class BeforeOperationAccessGrantedPostDenormalizeEventListener
{
public function __invoke(BeforeOperationAccessGrantedPostDenormalizeEvent $event): void
{
$operation = $event->getOperation();
$expressionLanguageVariables = $event->getExpressionLanguageVariables();
...
}
}
Before grant filter access
Event dispatched before grant filter access. This event gives access to following data:
filter- instance of\SourceBroker\ T3api\ Domain\ Model\ Api Filter expression- array of variables passed to expression language (empty array)Language Variables
Example event registration in Services.:
V\Site\EventListener\BeforeFilterAccessGrantedEventListener:
tags:
- name: 'event.listener'
Example implementation:
<?php
namespace V\Site\EventListener;
use SourceBroker\T3api\Event\BeforeFilterAccessGrantedEvent;
class BeforeFilterAccessGrantedEventListener
{
public function __invoke(BeforeFilterAccessGrantedEvent $event): void
{
$filter = $event->getFilter();
$expressionLanguageVariables = $event->getExpressionLanguageVariables();
...
}
}
Record updated / deleted
\Source and \Source are used
to invalidate the response cache when records are changed. You can also dispatch them yourself,
e.g. after changing records with plain SQL, to flush cached API responses. See Write-triggered invalidation.