Commit 24431ee0 authored by Gaurav Kapoor's avatar Gaurav Kapoor Committed by Gaurav Kapoor
Browse files

Issue #3264628 by gaurav.kapoor: Removed unwanted database access code.

parent c539835c
Loading
Loading
Loading
Loading
+1 −22
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ namespace Drupal\counter\Plugin\Block;
use Drupal\counter\CounterUtility;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -35,13 +34,6 @@ class CounterBlock extends BlockBase implements ContainerFactoryPluginInterface
   */
  protected $requestStack;

  /**
   * The database connection.
   *
   * @var Drupal\Core\Database\Connection
   */
  protected $database;

  /**
   * The account interface for accessing current user.
   *
@@ -69,18 +61,15 @@ class CounterBlock extends BlockBase implements ContainerFactoryPluginInterface
   *   The config factory for the form.
   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
   *   The request stack for accessing request information.
   * @param \Drupal\Core\Database\Connection $database
   *   The database connection variable for executing queries.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The account interface for accessing current user.
   * @param \Drupal\counter\CounterUtility $counter_utility
   *   The counter utility variable to access helper functions.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, RequestStack $request_stack, Connection $database, AccountInterface $account, CounterUtility $counter_utility) {
  public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, RequestStack $request_stack, AccountInterface $account, CounterUtility $counter_utility) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->configFactory = $config_factory;
    $this->requestStack = $request_stack;
    $this->database = $database;
    $this->account = $account;
    $this->counterUtility = $counter_utility;
  }
@@ -106,7 +95,6 @@ class CounterBlock extends BlockBase implements ContainerFactoryPluginInterface
      $plugin_definition,
      $container->get('config.factory'),
      $container->get('request_stack'),
      $container->get('database'),
      $container->get('current_user'),
      $container->get('counter.counter_utility')
    );
@@ -146,15 +134,6 @@ class CounterBlock extends BlockBase implements ContainerFactoryPluginInterface
    $data_update = ($interval >= $counter_refresh_delay ? 1 : 0);

    // Read counter_data.
    $sql = " SELECT * FROM {counter_data} ORDER BY counter_name";
    $results = $this->database->query($sql);
    $i = 0;

    foreach ($results as $data) {
      $i++;
      $counter_value[$i] = $data->counter_value;
    }

    $counter_data = $this->counterUtility->getCounterDataTableData();

    // Write output.