compareThemeFiles
When importing a theme Contao will show you a comparison about which database
fields are currently missing in the Contao installation and which template files
will be overwritten etc. The compareThemeFiles hook allows you to do additional
comparisons and show the user the appropriate HTML output.
Parameters
\DOMDocument
$xmlThe XML object containing the theme’s data.
\Contao\ZipReader
$zipThe ZIP archive object containing the theme’s files.
Return Values
A string containing additional HTML for the back end, showing the user the result of the custom comparison. Or an empty string.
Example
// src/EventListener/CompareThemeFilesListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\ZipReader;
#[AsHook('compareThemeFiles')]
class CompareThemeFilesListener
{
public function __invoke(\DOMDocument $xml, ZipReader $zip): string
{
// Execute your custom theme comparison
if ($this->doCustomComparison()) {
return $customComparison;
}
return '';
}
}