- 🇯🇴Jordan Rajab Natshah Jordan
Quick fix for this with custom
--gin-color-primary
accentNot to load not styled gin accent while installing.
As no user Gin setting yet and no user service yet.Removing
/** * Implements hook_css_alter(). */ function hook_css_alter(&$css, AttachedAssetsInterface $assets) { global $install_state; if (isset($install_state) && empty($install_state['installation_finished'])) { // Not to load not styled gin accent while installing. // As no user Gin setting yet and not user service yet. $gin_theme_css_path = \Drupal::service('extension.list.theme')->getPath('gin') . '/dist/css'; unset($css[$gin_theme_css_path . '/base/gin.css']); } }
Looking for a better fix tho
- Status changed to Needs review
about 1 year ago 12:40pm 18 October 2023 - Assigned to Rajab Natshah
- Status changed to Active
about 1 year ago 7:47am 22 October 2023 - Issue was unassigned.
- Status changed to Needs review
about 1 year ago 9:45am 22 October 2023 - 🇫🇷France nicolasgraph Strasbourg
Thank you all for your work on this issue! It does work as far as I tested.
However, Did you think about fixing the backend part directly and only in GinSettings to keep things simple and tidy?
I don't want to pollute current patches but here is what seems to work for me.diff --git a/src/GinSettings.php b/src/GinSettings.php index 0bb6e42..15a111f 100644 --- a/src/GinSettings.php +++ b/src/GinSettings.php @@ -27,7 +27,7 @@ class GinSettings implements ContainerInjectionInterface { /** * The user data service. * - * @var \Drupal\user\UserDataInterface + * @var \Drupal\user\UserDataInterface|null */ protected $userData; @@ -41,15 +41,15 @@ class GinSettings implements ContainerInjectionInterface { /** * Settings constructor. * - * @param \Drupal\user\UserDataInterface $userData - * The user data service. * @param \Drupal\Core\Session\AccountInterface $currentUser * The current user. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory. */ - public function __construct(UserDataInterface $userData, AccountInterface $currentUser, ConfigFactoryInterface $configFactory) { - $this->userData = $userData; + public function __construct(AccountInterface $currentUser, ConfigFactoryInterface $configFactory) { + if (\Drupal::hasService('user.data')) { + $this->userData = \Drupal::service('user.data'); + } $this->currentUser = $currentUser; $this->configFactory = $configFactory; } @@ -59,7 +59,6 @@ class GinSettings implements ContainerInjectionInterface { */ public static function create(ContainerInterface $container) { return new static( - $container->get('user.data'), $container->get('current_user'), $container->get('config.factory') ); @@ -121,7 +120,7 @@ class GinSettings implements ContainerInjectionInterface { * The account object. Current user if NULL. */ public function setAll(array $settings, AccountInterface $account = NULL) { - if (!$account) { + if (!$account || !$this->userData) { $account = $this->currentUser; } // All settings are deleted to remove legacy settings. @@ -137,7 +136,7 @@ class GinSettings implements ContainerInjectionInterface { * The account object. Current user if NULL. */ public function clear(AccountInterface $account = NULL) { - if (!$account) { + if (!$account || !$this->userData) { $account = $this->currentUser; } $this->userData->delete('gin', $account->id()); @@ -164,7 +163,7 @@ class GinSettings implements ContainerInjectionInterface { * TRUE or FALSE. */ public function userOverrideEnabled(AccountInterface $account = NULL) { - if (!$account) { + if (!$account || !$this->userData) { $account = $this->currentUser; } return $this->allowUserOverrides() && (bool) $this->userData->get('gin', $account->id(), 'enable_user_settings');
- Status changed to RTBC
11 months ago 11:26am 3 January 2024 - 🇨🇭Switzerland saschaeggi Zurich
@leymannx can you create a MR for this? TY in advance!
- Merge request !355Issue #3325263 by leymannx: Fix user.data ServiceNotFoundException when using... → (Merged) created by leymannx
-
saschaeggi →
committed 7eb6d2e0 on 8.x-3.x authored by
leymannx →
Issue #3325263 by leymannx: Fix user.data ServiceNotFoundException when...
-
saschaeggi →
committed 7eb6d2e0 on 8.x-3.x authored by
leymannx →
- Status changed to Fixed
10 months ago 11:06am 10 January 2024 - 🇨🇭Switzerland saschaeggi Zurich
Thanks y'all for your participation in addressing this 🙌
Automatically closed - issue fixed for 2 weeks with no activity.