compileDefinition
Details
This page shows version 4.x. The current version can be found here.
The compileDefinition hook is triggered when a format definition of an internal
style sheet is written. It passes the database record of the style definition as
an array and expects a string as return value.
Note
Using the compileDefinition hook has been deprecated and will no longer work in Contao 5.0. There is no replacement as the internal stylesheet functionality has been removed in Contao 5.0.
Parameters
array
$rowThe style definition database record (
tl_style_sheet).bool
$writeToFileDefines whether or not the style definition will be written to a file.
array
$varsCSS variables from the theme.
array
$parentThe parent record of the style definition (
tl_style).
Return Values
A string containing the customized style definition. Or an empty string, if the original definition should be used.
Example
// src/EventListener/CompileDefinitionListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('compileDefinition')]
class CompileDefinitionListener
{
public function __invoke(array $row, bool $writeToFile, array $vars, array $parent): string
{
if (isset($row['border-radius'])) {
return "\nborder-radius:" . $arrRow['border-radius'] . ";";
}
return '';
}
}