diff --git a/core/modules/settings_tray/src/Form/SystemMenuOffCanvasForm.php b/core/modules/settings_tray/src/Form/SystemMenuOffCanvasForm.php index d755d092d0..14f2bd2af7 100644 --- a/core/modules/settings_tray/src/Form/SystemMenuOffCanvasForm.php +++ b/core/modules/settings_tray/src/Form/SystemMenuOffCanvasForm.php @@ -4,6 +4,7 @@ use Drupal\Component\Plugin\PluginInspectionInterface; use Drupal\Core\Access\AccessResult; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; @@ -52,17 +53,27 @@ class SystemMenuOffCanvasForm extends PluginFormBase implements ContainerInjecti */ protected $entityTypeManager; + /** + * The config factory. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + /** * SystemMenuOffCanvasForm constructor. * * @param \Drupal\Core\Entity\EntityStorageInterface $menu_storage * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation + * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory + * The config factory. */ - public function __construct(EntityStorageInterface $menu_storage, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation) { + public function __construct(EntityStorageInterface $menu_storage, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation, ConfigFactoryInterface $config_factory) { $this->menuStorage = $menu_storage; $this->entityTypeManager = $entity_type_manager; $this->stringTranslation = $string_translation; + $this->configFactory = $config_factory; } /** @@ -72,7 +83,8 @@ public static function create(ContainerInterface $container) { return new static( $container->get('entity_type.manager')->getStorage('menu'), $container->get('entity_type.manager'), - $container->get('string_translation') + $container->get('string_translation'), + $container->get('config.factory') ); } @@ -157,10 +169,15 @@ public function setPlugin(PluginInspectionInterface $plugin) { } /** + * Determines if the menu has configuration overrides. + * * @return bool + * TRUE if the menu has configuration overrides, otherwise FALSE. */ protected function hasMenuOverrides() { - return \Drupal::config($this->menu->getEntityType() + // @todo Replace the following with $this->menu->hasOverrides() in https://www.drupal.org/project/drupal/issues/2910353 + // and remove this function. + return $this->configFactory->get($this->menu->getEntityType() ->getConfigPrefix() . '.' . $this->menu->id())->hasOverrides(); }