RecordAccessGrantedEvent¶
New in version 12.0
This event serves as replacement for the removed hook
$GLOBALS
.
The PSR-14 event \TYPO3\
can be used to either define whether a record access is granted
for a user, or to modify the record in question. In case the $access
property is set (either true
or false
), the defined settings are
directly used, skipping any further event listener as well as any further
evaluation.
Example¶
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Domain\Access;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Domain\Access\RecordAccessGrantedEvent;
#[AsEventListener(
identifier: 'my-extension/set-access-granted',
)]
final readonly class MyEventListener
{
public function __invoke(RecordAccessGrantedEvent $event): void
{
// Manually set access granted
if (
$event->getTable() === 'my_table' &&
($event->getRecord()['custom_access_field'] ?? false)
) {
$event->setAccessGranted(true);
}
// Update the record to be checked
$record = $event->getRecord();
$record['some_field'] = true;
$event->updateRecord($record);
}
}
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.
API¶
- class RecordAccessGrantedEvent ¶
-
- Fully qualified name
-
\TYPO3\
CMS\ Core\ Domain\ Access\ Record Access Granted Event
Event to modify records to be checked against "enableFields".
Listeners are able to grant access or to modify the record itself to continue to use the native access check functionality with a modified dataset.
- isPropagationStopped ( ) ¶
-
- Returns
-
bool
- setAccessGranted ( bool $accessGranted) ¶
-
- param $accessGranted
-
the accessGranted
- getTable ( ) ¶
-
- Returns
-
string
- getRecord ( ) ¶
-
- Returns
-
array
- updateRecord ( array $record) ¶
-
- param $record
-
the record
- getContext ( ) ¶
-
- Returns
-
\TYPO3\
CMS\ Core\ Context\ Context