Skip to content
Snippets Groups Projects
Commit 967981b1 authored by baldwinlouie's avatar baldwinlouie Committed by Yas Naoi
Browse files

Issue #3164709 by baldwinlouie, yas: Fix "Error: Call to a member function getParameter() on null"

parent af5b4338
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -54,6 +55,13 @@ class ResourcesBlock extends BlockBase implements ContainerFactoryPluginInterfac
*/
protected $cloudConfigPluginManager;
/**
* The route match object.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* Creates a ResourcesBlock instance.
*
......@@ -71,6 +79,8 @@ class ResourcesBlock extends BlockBase implements ContainerFactoryPluginInterfac
* An entity type manager instance.
* @param \Drupal\cloud\Plugin\cloud\config\CloudConfigPluginManagerInterface $cloud_config_plugin_manager
* The cloud config plugin manager.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match object.
*/
public function __construct(
array $configuration,
......@@ -79,13 +89,15 @@ class ResourcesBlock extends BlockBase implements ContainerFactoryPluginInterfac
ConfigFactoryInterface $config_factory,
AccountInterface $current_user,
EntityTypeManagerInterface $entity_type_manager,
CloudConfigPluginManagerInterface $cloud_config_plugin_manager
CloudConfigPluginManagerInterface $cloud_config_plugin_manager,
RouteMatchInterface $route_match
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configFactory = $config_factory;
$this->currentUser = $current_user;
$this->entityTypeManager = $entity_type_manager;
$this->cloudConfigPluginManager = $cloud_config_plugin_manager;
$this->routeMatch = $route_match;
}
/**
......@@ -99,7 +111,8 @@ class ResourcesBlock extends BlockBase implements ContainerFactoryPluginInterfac
$container->get('config.factory'),
$container->get('current_user'),
$container->get('entity_type.manager'),
$container->get('plugin.manager.cloud_config_plugin')
$container->get('plugin.manager.cloud_config_plugin'),
$container->get('current_route_match')
);
}
......
......@@ -45,7 +45,8 @@ trait ResourceBlockTrait {
*/
protected function runEntityQuery($entity_name, array $params) {
$cloud_context = $this->configuration['cloud_context'];
$cloud_project = $this->routeMatch->getParameter('cloud_project');
/* @var \Drupal\Core\Routing\RouteMatchInterface $route_match */
$cloud_project = \Drupal::routeMatch()->getParameter('cloud_project');
if (empty($cloud_project) && !empty($cloud_context)) {
$params['cloud_context'] = $cloud_context;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment