Skip to content
Snippets Groups Projects

Issue #3107993 - Template is not defined error on node edit / admin pages

Files
3
@@ -4,6 +4,7 @@ namespace Drupal\components\Template;
@@ -4,6 +4,7 @@ namespace Drupal\components\Template;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\CacheBackendInterface;
 
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ExtensionList;
use Drupal\Core\Extension\ExtensionList;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
@@ -70,6 +71,13 @@ class ComponentsRegistry {
@@ -70,6 +71,13 @@ class ComponentsRegistry {
*/
*/
protected $fileSystem;
protected $fileSystem;
 
/**
 
* The config factory service.
 
*
 
* @var \Drupal\Core\Config\ConfigFactoryInterface
 
*/
 
protected $configFactory;
 
/**
/**
* Constructs a new ComponentsRegistry object.
* Constructs a new ComponentsRegistry object.
*
*
@@ -85,6 +93,8 @@ class ComponentsRegistry {
@@ -85,6 +93,8 @@ class ComponentsRegistry {
* Cache backend for storing the components registry info.
* Cache backend for storing the components registry info.
* @param \Drupal\Core\File\FileSystemInterface $fileSystem
* @param \Drupal\Core\File\FileSystemInterface $fileSystem
* The file system service.
* The file system service.
 
* @param \Drupal\Core\Config\ConfigFactoryInterface
 
* The config factory service.
*/
*/
public function __construct(
public function __construct(
ModuleExtensionList $moduleExtensionList,
ModuleExtensionList $moduleExtensionList,
@@ -93,6 +103,7 @@ class ComponentsRegistry {
@@ -93,6 +103,7 @@ class ComponentsRegistry {
ThemeManagerInterface $themeManager,
ThemeManagerInterface $themeManager,
CacheBackendInterface $cache,
CacheBackendInterface $cache,
FileSystemInterface $fileSystem,
FileSystemInterface $fileSystem,
 
ConfigFactoryInterface $configFactory
) {
) {
$this->moduleExtensionList = $moduleExtensionList;
$this->moduleExtensionList = $moduleExtensionList;
$this->themeExtensionList = $themeExtensionList;
$this->themeExtensionList = $themeExtensionList;
@@ -100,6 +111,20 @@ class ComponentsRegistry {
@@ -100,6 +111,20 @@ class ComponentsRegistry {
$this->themeManager = $themeManager;
$this->themeManager = $themeManager;
$this->cache = $cache;
$this->cache = $cache;
$this->fileSystem = $fileSystem;
$this->fileSystem = $fileSystem;
 
$this->configFactory = $configFactory;
 
}
 
 
/**
 
* Retrieves a configuration object.
 
*
 
* @param string $name
 
* The name of the configuration object to retrieve.
 
*
 
* @return \Drupal\Core\Config\ImmutableConfig
 
* A configuration object.
 
*/
 
protected function config($name) {
 
return $this->configFactory->get($name);
}
}
/**
/**
@@ -117,7 +142,23 @@ class ComponentsRegistry {
@@ -117,7 +142,23 @@ class ComponentsRegistry {
$this->load($themeName);
$this->load($themeName);
}
}
return $this->registry[$themeName][$name] ?? NULL;
if (!empty($this->registry[$themeName][$name])) {
 
return $this->registry[$themeName][$name];
 
}
 
 
// If the template was not found in the active theme, and the active theme
 
// is not the same as the default theme, load the default theme and check
 
// there too. We may be dealing with the admin theme.
 
$defaultThemeName = $this->config('system.theme')->get('default');
 
if (empty($defaultThemeName) || $defaultThemeName === $themeName) {
 
return NULL;
 
}
 
 
if (!isset($this->registry[$defaultThemeName])) {
 
$this->load($defaultThemeName);
 
}
 
 
return $this->registry[$defaultThemeName][$name] ?? NULL;
}
}
/**
/**
Loading