Ulogin.php in uLogin (advanced version) 8
File
src/Plugin/Block/Ulogin.php
View source
<?php
namespace Drupal\ulogin\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
class Ulogin extends BlockBase implements ContainerFactoryPluginInterface {
protected $moduleHandler;
protected $request;
protected $routeMatch;
public function __construct(array $configuration, $plugin_id, $plugin_definition, Request $request, ModuleHandlerInterface $module_handler, RouteMatchInterface $route_match) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->request = $request;
$this->moduleHandler = $module_handler;
$this->routeMatch = $route_match;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('request_stack')
->getCurrentRequest(), $container
->get('module_handler'), $container
->get('current_route_match'));
}
public function build() {
$block = [
'#cache' => [
'max-age' => 0,
],
];
if (!\Drupal::currentUser()
->isAuthenticated() && \Drupal::currentUser()
->hasPermission('use ulogin')) {
$block['subject'] = $this
->t('User login');
$block['content'] = [
'ulogin' => [
'#type' => 'ulogin_widget',
],
];
}
return $block;
}
}
Classes
Name |
Description |
Ulogin |
Provides a 'Ulogin' block. |