sqlCompileCommands

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\ServiceAnnotation\Hook;
use Terminal42\ServiceAnnotationBundle\ServiceAnnotationInterface;

class SqlCompileCommandsListener implements ServiceAnnotationInterface
{
    /**
     * @Hook("sqlCompileCommands")
     */
    public function onSqlCompileCommands(array $sql): array
    {
        // Modify the array of SQL statements

        return $sql;
    }
}

References