Unverified Commit 4a279151 authored by Stefan Auditor's avatar Stefan Auditor Committed by Stefan Auditor
Browse files

Issue #3282696 by sanduhrs: Port of l10n_community: Dependency injection

parent 3d6f786e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Drupal\Core\Block\BlockBase;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Link;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\CurrentRouteMatch;
use Drupal\Core\Url;
use Drupal\l10n_community\L10nStatistics;
use Drupal\l10n_server\Entity\L10nServerRelease;
@@ -43,12 +44,15 @@ class ProjectStatisticsBlock extends BlockBase implements ContainerFactoryPlugin
   *   The plugin implementation definition.
   * @param \Drupal\l10n_community\L10nStatistics $statistics
   *   The l10n_community.statistics service.
   * @param \Drupal\Core\Routing\CurrentRouteMatch $route_match
   *   The current_route_match service.
   */
  public function __construct(
      array $configuration,
      $plugin_id,
      $plugin_definition,
      L10nStatistics $statistics
      L10nStatistics $statistics,
      CurrentRouteMatch $route_match
  ) {
    parent::__construct(
      $configuration,
@@ -56,6 +60,7 @@ class ProjectStatisticsBlock extends BlockBase implements ContainerFactoryPlugin
      $plugin_definition
    );
    $this->statistics = $statistics;
    $this->routeMatch = $route_match;
  }

  /**
@@ -71,7 +76,8 @@ class ProjectStatisticsBlock extends BlockBase implements ContainerFactoryPlugin
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('l10n_community.statistics')
      $container->get('l10n_community.statistics'),
      $container->get('current_route_match')
    );
  }

@@ -80,7 +86,7 @@ class ProjectStatisticsBlock extends BlockBase implements ContainerFactoryPlugin
   */
  public function build() {
    /** @var \Drupal\l10n_server\Entity\L10nServerProjectInterface $project */
    if (!$project = \Drupal::routeMatch()->getParameter('l10n_server_project')) {
    if (!$project = $this->routeMatch->getParameter('l10n_server_project')) {
      return [];
    }