public function User::getArgument in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/src/Plugin/views/argument_default/User.php \Drupal\user\Plugin\views\argument_default\User::getArgument()
Return the default argument.
This needs to be overridden by every default argument handler to properly do what is needed.
Overrides ArgumentDefaultPluginBase::getArgument
File
- core/
modules/ user/ src/ Plugin/ views/ argument_default/ User.php, line 91 - Contains \Drupal\user\Plugin\views\argument_default\User.
Class
- User
- Default argument plugin to extract a user from request.
Namespace
Drupal\user\Plugin\views\argument_defaultCode
public function getArgument() {
// If there is a user object in the current route.
if ($user = $this->routeMatch
->getParameter('user')) {
if ($user instanceof UserInterface) {
return $user
->id();
}
}
// If option to use node author; and node in current route.
if (!empty($this->options['user']) && ($node = $this->routeMatch
->getParameter('node'))) {
if ($node instanceof NodeInterface) {
return $node
->getOwnerId();
}
}
}