The reviseTable
hook is triggered when Contao removes orphan records from a
table. It passes the name of the current table, the IDs of all new records, the
name of the parent table and the names of all child tables as arguments and
does expect a boolean as return value (returning true
will cause the current
page to be reloaded).
This hook can also be implemented as an anonymous function.
string $table
The current table name.
array $newRecords
Array containing the ID of the new records. Can be null
.
string $parentTable
Optional parent table of the current table. Can be null
.
array $childTables
Optional array containing the names of the child tables. Can be null
.
Return true
if the current page should be reloaded. Otherwise return false
or null
.
// src/EventListener/ReviseTableListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('reviseTable')]
class ReviseTableListener
{
public function __invoke(string $table, ?array $newRecords, ?string $parentTable, ?array $childTables): ?bool
{
// Do something …
}
}