Skip to content

Allow switching admin-themes #6

Description

@jissereitsma

Currently, when the Nebula Admin Theme is installed, it takes over everything. However, when an issue arises with a third party extension (for example, within Nebula I was not able to find my Yireo EmailTester extension anywhere) it would be nice to disable the Nebula Admin Theme temporarily. For this, the https://github.com/mage-os/module-theme-adminhtml-switcher would be ideal.

To allow for such a thing, I created some WIP code for myself. The class \Qoliber\Nebula\Plugin\ForceAdminTheme was modified to only override things if the MageOS_ThemeAdminhtmlSwitcher module is not enabled:

<?php

declare(strict_types=1);

namespace Qoliber\Nebula\Plugin;

use Magento\Framework\App\Area;
use Magento\Framework\Module\Manager as ModuleManager;
use Magento\Framework\View\LayoutInterface;
use Magento\Theme\Model\View\Design;

class ForceAdminTheme
{
    private const THEME_PATH = 'Qoliber/Nebula';

    public function __construct(
        private readonly ModuleManager $moduleManager,
        private readonly LayoutInterface $layout
    ) {
    }

    public function beforeSetDesignTheme(
        Design $subject,
        mixed $themeId = null,
        ?string $area = null
    ): array {
        if (
            $area !== Area::AREA_ADMINHTML
            || ($area !== null || $subject->getArea() !== Area::AREA_ADMINHTML)
        ) {
            return [$themeId, $area];
        }

        if ($this->moduleManager->isEnabled('MageOS_ThemeAdminhtmlSwitcher')) {
            return [$themeId, $area];
        }

        foreach ($this->layout->getUpdate()->getHandles() as $handle) {
            $this->layout->getUpdate()->addHandle('nebula_'.$handle);
        }

        return [self::THEME_PATH, $area];
    }
}

It also adds XML layout prefixes with nebula_.

Next, this change would obviously require all of the XML layout files of any Nebula Admin module to be renamed to include this nebula_ prefix.

On top of it, classes like \Qoliber\Nebula\Block\Config\Form\Fieldset would need to check upon whether the current theme is actually the Nebula theme.

Would this (heavy) change be something to dive into?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions