public function boot()
    {
        /** @var Environment $environment */
        $environment = System::getContainer()->get('contao.framework')->getAdapter(Environment::class);
        $script      = explode('?', $environment->get('relativeRequest'), 2)[0];

        // There is no need to boot in login or install screen.
        if (('contao/login' === $script) || ('contao/install' === $script)) {
            return;
        }

        // Ensure all tables are created.
        $connection = System::getContainer()->get('database_connection');
        if (!$connection->getSchemaManager()->tablesExist(
            [
                'tl_metamodel',
                'tl_metamodel_dca',
                'tl_metamodel_dca_sortgroup',
                'tl_metamodel_dcasetting',
                'tl_metamodel_dcasetting_condition',
                'tl_metamodel_attribute',
                'tl_metamodel_filter',
                'tl_metamodel_filtersetting',
                'tl_metamodel_rendersettings',
                'tl_metamodel_rendersetting',
                'tl_metamodel_dca_combine',
            ]
        )) {
            System::getContainer()
                ->get('logger')
                ->error('MetaModels startup interrupted. Not all MetaModels tables have been created.');
            return;
        }

        $event = new MetaModelsBootEvent();
        $this->tryDispatch(MetaModelsEvents::SUBSYSTEM_BOOT, $event);

        $determinator = System::getContainer()->get('cca.dc-general.scope-matcher');
        switch (true) {
            case $determinator->currentScopeIsFrontend():
                $this->tryDispatch(MetaModelsEvents::SUBSYSTEM_BOOT_FRONTEND, $event);
                break;
            case $determinator->currentScopeIsBackend():
                $this->tryDispatch(MetaModelsEvents::SUBSYSTEM_BOOT_BACKEND, $event);
                break;
            default:
        }
    }