Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [1.2.1] - 2026-04-21

### Changed

- PHP 8.4 and 8.5 compatibility: typed parameters and properties, explicit nullable types, typed class constants
- `composer.json` now declares PHP `~8.2.0||~8.3.0||~8.4.0||~8.5.0`

## [1.2.0] - 2025-06-10

### Added
Expand Down
21 changes: 8 additions & 13 deletions Model/Config/Source/AdminThemeList.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

class AdminThemeList implements OptionSourceInterface
{
private ThemeList $themeList;
protected const DEFAULT_ADMIN_THEME_PATH = 'Magento/backend';

protected ThemeList $themeList;

/**
* AdminThemeList constructor.
*
* @param ThemeList $themeList
*/
public function __construct(ThemeList $themeList)
Expand All @@ -21,8 +21,6 @@ public function __construct(ThemeList $themeList)
}

/**
* Get a list of all installed adminhtml themes.
*
* @return array
*/
public function toOptionArray(): array
Expand All @@ -32,20 +30,17 @@ public function toOptionArray(): array

foreach ($this->themeList->getItems() as $theme) {
$path = $theme->getData('theme_path');

// Replace default admin theme title as 'Magento 2 backend' is not user friendly
$title = $theme->getData('theme_title');
if ($path === 'Magento/backend') {
$title = (string)__('Magento Default');
}
$title = $path === self::DEFAULT_ADMIN_THEME_PATH
? (string)__('Magento Default')
: $theme->getData('theme_title');

$themes[$title] = [
'label' => $title . ' (' . $path . ')',
'value' => $path
'value' => $path,
];
}

ksort($themes); // Sort themes alphabetically
ksort($themes);

return $themes;
}
Expand Down
18 changes: 8 additions & 10 deletions Plugin/ThemeAdminhtmlSwitcherPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace MageOS\ThemeAdminhtmlSwitcher\Plugin;

use Magento\Framework\App\Area;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Theme\Model\View\Design;
use Magento\Framework\App\Area;

class ThemeAdminhtmlSwitcherPlugin
{
private ScopeConfigInterface $scopeConfig;
protected const XML_PATH_ACTIVE_THEME = 'admin/system_admin_design/active_theme';

protected ScopeConfigInterface $scopeConfig;

/**
* ThemeAdminhtmlSwitcherPlugin constructor.
*
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
Expand All @@ -22,14 +22,12 @@ public function __construct(
}

/**
* Before method for setting backend area design theme.
*
* @param Design $subject
* @param string|null $themeId
* @param mixed $themeId
* @param string|null $area
* @return array
*/
public function beforeSetDesignTheme(Design $subject, $themeId = null, $area = null)
public function beforeSetDesignTheme(Design $subject, mixed $themeId = null, ?string $area = null): array
{
if ($area !== null && $area !== Area::AREA_ADMINHTML) {
return [$themeId, $area];
Expand All @@ -40,10 +38,10 @@ public function beforeSetDesignTheme(Design $subject, $themeId = null, $area = n
}

$activeTheme = $this->scopeConfig->getValue(
'admin/system_admin_design/active_theme',
self::XML_PATH_ACTIVE_THEME,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);

return [$activeTheme ?? $themeId, $area];
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
}
],
"require": {
"php": "~8.2.0||~8.3.0||~8.4.0||~8.5.0",
"magento/framework": "^103.0",
"magento/module-backend": "^102.0",
"magento/module-config": "^101.0"
Expand All @@ -24,4 +25,4 @@
"MageOS\\ThemeAdminhtmlSwitcher\\": ""
}
}
}
}
Loading