From a52841df07aa990af12d6686a90bbab60536be24 Mon Sep 17 00:00:00 2001 From: swentel <swentel@realize.be> Date: Sun, 16 Jul 2023 16:03:26 +0200 Subject: [PATCH] Issue #3368291 by swentel: Mark read button on home still points to old setting --- src/Plugin/Block/Actions.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Plugin/Block/Actions.php b/src/Plugin/Block/Actions.php index f30dd69..ead9373 100644 --- a/src/Plugin/Block/Actions.php +++ b/src/Plugin/Block/Actions.php @@ -12,6 +12,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Drupal\reader\ReaderInterface; +use Drupal\user\UserDataInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -62,6 +63,13 @@ class Actions extends BlockBase implements ContainerFactoryPluginInterface { */ protected $moduleHandler; + /** + * The user data service. + * + * @var \Drupal\user\UserDataInterface + */ + protected $userData; + /** * Actions constructor * @@ -84,14 +92,17 @@ class Actions extends BlockBase implements ContainerFactoryPluginInterface { * The entity type manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. + * @param \Drupal\user\UserDataInterface $user_data + * The user data service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteMatchInterface $route_match, ConfigFactoryInterface $config_factory, AccountInterface $current_user, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteMatchInterface $route_match, ConfigFactoryInterface $config_factory, AccountInterface $current_user, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, UserDataInterface $user_data) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->routeMatch = $route_match; $this->configFactory = $config_factory; $this->currentUser = $current_user; $this->entityTypeManager = $entity_type_manager; $this->moduleHandler = $module_handler; + $this->userData = $user_data; } /** @@ -107,6 +118,7 @@ class Actions extends BlockBase implements ContainerFactoryPluginInterface { $container->get('current_user'), $container->get('entity_type.manager'), $container->get('module_handler'), + $container->get('user.data') ); } @@ -129,7 +141,8 @@ class Actions extends BlockBase implements ContainerFactoryPluginInterface { $id = $this->routeMatch->getParameter('id'); } elseif ($route_name == 'reader.home') { - $default_timeline = $this->configFactory->get('reader.settings')->get('default_timeline'); + $settings = $this->userData->get('reader', $this->currentUser->id(), 'settings'); + $default_timeline = !empty($settings['default_timeline']) ? $settings['default_timeline'] : ''; if (!empty($default_timeline)) { [$module, $id] = explode(ReaderInterface::SEPARATOR, $default_timeline); } -- GitLab