The getCombinedFile
hook is triggered when combining CSS or JavaScript files.
It passes the file content, a unique key for the temporary file, the mode (e.g.
'.js'
or '.css'
) and an array containing information about the file and expects
the content as return value.
string $content
Content of the file which will be added to the combiner.
string $key
A unique key that represents the current combiner. A file with this name will
be stored in system/scripts/
.
string $mode
The combiner mode (constant), either Combiner::CSS
or Combiner::JS
.
array $file
Detailed information about the file to be combined.
The contents of the combined file as a string.
// src/EventListener/GetCombinedFileListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('getCombinedFile')]
class GetCombinedFileListener
{
public function __invoke(string $content, string $key, string $mode, array $file): string
{
// Modify $content here …
return $content;
}
}