function CurrentUser::__construct
CurrentUser constructor.
Parameters
array $configuration: A configuration array containing information about the plugin instance.
string $plugin_id: The plugin_id for the plugin instance.
mixed $plugin_definition: The plugin implementation definition.
\Drupal\Core\Session\AccountInterface|null $currentUser: The current user.
Overrides PluginBase::__construct
File
-
core/
modules/ user/ src/ Plugin/ views/ argument_default/ CurrentUser.php, line 36
Class
- CurrentUser
- Default argument plugin to extract the current user.
Namespace
Drupal\user\Plugin\views\argument_defaultCode
public function __construct(array $configuration, $plugin_id, $plugin_definition, ?AccountInterface $currentUser = NULL) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
if ($this->currentUser === NULL) {
@trigger_error('Calling ' . __CLASS__ . '::__construct() without the $currentUser argument is deprecated in drupal:11.2.0 and is required in drupal:12.0.0. See https://www.drupal.org/node/3347878', E_USER_DEPRECATED);
$this->currentUser = \Drupal::currentUser();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.