- 🇺🇸United States astringer
The patch in #29, works for me on Drupal 9.5.3 using 8.x-1.9 of Userswitch.
This fixes the `LoggerChannelFactory` type in the `__construct()` function to be `LoggerChannelFactoryInterface`, so alternative logging methods can be used (such as the `Monolog Datadog` module).
- 🇮🇹Italy apaderno Brescia, 🇮🇹
+ /** + * Drupal\userswitch\UserSwitch definition. + * + * @var \Drupal\userswitch\UserSwitch + */ protected $userSwitch; + + /** + * Drupal\Core\Session\AccountInterface definition. + * + * @var \Drupal\Core\Session\AccountInterface + */ protected $currentUser; + + /** + * Drupal\Core\Database\Connection definition. + * + * @var \Drupal\Core\Database\Connection + */ protected $database; + + /** + * Drupal\Core\Messenger\MessengerInterface definition. + * + * @var \Drupal\Core\Messenger\MessengerInterface + */ protected $messenger;
Property descriptions must not repeat the property type, which is already given in the
@var
line.+ // Initialize an empty array. + $output = [];
That comment is not necessary, since
$output = [];
is quiet clear.+ catch (PluginException $e) { + \Drupal::logger('userswitch')->error($e->getMessage()); + return [];
Like other dependencies, also the logger must be injected using the dependency container.
- public function switchuser($uid) { - if ($this->userswitch->switchToOther($uid)) { + public function switchuser(User $user) {
Since that line is changed, also the method name should be changed to
switchUser()
.+ * @return \Symfony\Component\HttpFoundation\Response + * Returns redirect response.
Return value descriptions must not start with Returns nor Return.
- 🇫🇷France nicodh
Hi,
I rerolled the patch with @apaderno comments (services declarations, comments, method names).
I added a retro compat test for switchToOther service method (accepts uid or User entity).
I also unified route paths, and fix user toolbar link for switching back (with Gin theme - not tested in others - classes made the link hidden).
As it is this module is unusable IMHO (without entity operation and without switch back link). - 🇮🇹Italy apaderno Brescia, 🇮🇹
+ /** + * @var \Drupal\userswitch\UserSwitch + */ protected $userSwitch; + + /** + * @var \Drupal\Core\Session\AccountInterface + */ protected $currentUser;
The property descriptions are missing.
- 🇫🇷France nicodh
I thought the property names were self-describing, but I rerolled the patch
- Status changed to Needs review
about 1 year ago 8:19am 21 September 2023 - 🇮🇳India ash2303
Fixed small entityquery accesscheck issue.
Kept it to TRUE as per module functionality.