sqlCompileCommands

Details

This page shows version 4.x. The current version can be found here.

The sqlCompileCommands hook is triggered when compiling the database update commands. It passes the array of changes and expects the same as return value.

Parameters

  1. array $sql

    Array of changes that should be applied to the database.

Return Values

Return the array of changes that should be applied to the database.

Example

// src/EventListener/SqlCompileCommandsListener.php
namespace App\EventListener;

use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;

#[AsHook('sqlCompileCommands')]
class SqlCompileCommandsListener
{
    public function __invoke(array $sql): array
    {
        // Modify the array of SQL statements

        return $sql;
    }
}

References