You are here

public function DraggableBlock::__construct in Draggable dashboard 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Block/DraggableBlock.php \Drupal\draggable_dashboard\Plugin\Block\DraggableBlock::__construct()

DraggableBlock constructor.

Parameters

array $configuration: Plugin configuration.

string $plugin_id: Plugin id.

array $plugin_definition: Plugin definition.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: Entity Type Manager.

\Symfony\Component\HttpFoundation\RequestStack $request_stack: Request stack.

\Drupal\Core\Routing\RouteMatchInterface $route_match: Current Route Matcher.

\Drupal\Core\Theme\ThemeManagerInterface $theme_manager: The theme manager.

\Drupal\Core\Controller\TitleResolverInterface $title_resolver: Title resolver.

\Drupal\Core\Block\BlockManagerInterface $block_plugin_manager: Block manager.

\Drupal\Core\Session\AccountProxyInterface $current_user: Current user.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

Overrides BlockPluginTrait::__construct

File

src/Plugin/Block/DraggableBlock.php, line 110

Class

DraggableBlock
Provides a draggable block with a simple text.

Namespace

Drupal\draggable_dashboard\Plugin\Block

Code

public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityTypeManagerInterface $entity_type_manager, RequestStack $request_stack, RouteMatchInterface $route_match, ThemeManagerInterface $theme_manager, TitleResolverInterface $title_resolver, BlockManagerInterface $block_plugin_manager, AccountProxyInterface $current_user) {
  parent::__construct($configuration, $plugin_id, $plugin_definition);
  $this->themeManager = $theme_manager;
  $this->titleResolver = $title_resolver;
  $this->entityTypeManager = $entity_type_manager;
  $this->blockManager = $block_plugin_manager;
  $config = $this
    ->getConfiguration();
  $did = preg_replace('%[^\\d]%', '', $config['id']);
  $this->dashboard = $this->entityTypeManager
    ->getStorage('dashboard_entity')
    ->load($did);
  $this->currentUser = $current_user;
  $this->routeMatch = $route_match;
  $this->requestStack = $request_stack;
}