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

  1. \DOMDocument $xml

    The XML object containing the theme’s data.

  2. \Contao\ZipReader $zip

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

class CompareThemeFilesListener implements ServiceAnnotationInterface
{
    /**
     * @Hook("compareThemeFiles")
     */
    public function onCompareThemeFiles(\DOMDocument $xml, ZipReader $zip): string
    {
        // Execute your custom theme comparison
        if ($this->doCustomComparison()) {
            return $customComparison;
        }
        
        return '';
    }
}

References