SignupMenuLink.php in Open Social 10.2.x
Same filename and directory in other branches
- 8.9 modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 8 modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 8.2 modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 8.3 modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 8.4 modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 8.5 modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 8.6 modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 8.7 modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 8.8 modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 10.3.x modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 10.0.x modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
- 10.1.x modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.php
Namespace
Drupal\social_user\Plugin\MenuFile
modules/social_features/social_user/src/Plugin/Menu/SignupMenuLink.phpView source
<?php
namespace Drupal\social_user\Plugin\Menu;
use Drupal\Core\Menu\MenuLinkDefault;
use Drupal\Core\Menu\StaticMenuLinkOverridesInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* A menu link that shows "Sign up" in the user account menu.
*/
class SignupMenuLink extends MenuLinkDefault {
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* Constructs a new SignupMenuLink.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Menu\StaticMenuLinkOverridesInterface $static_override
* The static override storage.
* @param \Drupal\Core\Session\AccountInterface $current_user
* The current user.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, StaticMenuLinkOverridesInterface $static_override, AccountInterface $current_user) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $static_override);
$this->currentUser = $current_user;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('menu_link.static.overrides'), $container
->get('current_user'));
}
/**
* {@inheritdoc}
*/
public function isEnabled() {
if ($this->currentUser
->isAuthenticated()) {
return FALSE;
}
else {
return parent::isEnabled();
}
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return [
'user.roles:authenticated',
];
}
}
Classes
Name | Description |
---|---|
SignupMenuLink | A menu link that shows "Sign up" in the user account menu. |