You are here

private function SpiController::getQuantum in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getQuantum()
  2. 3.x src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getQuantum()

Gather information about nodes, users and comments.

Return value

array An associative array.

1 call to SpiController::getQuantum()
SpiController::get in src/Controller/SpiController.php
Gather site profile information about this site.

File

src/Controller/SpiController.php, line 958

Class

SpiController
SPI Controller class.

Namespace

Drupal\acquia_connector\Controller

Code

private function getQuantum() {
  $quantum = [];
  if ($this
    ->moduleHandler()
    ->moduleExists('node')) {

    // Get only published nodes.
    $quantum['nodes'] = Database::getConnection()
      ->select('node_field_data', 'n')
      ->fields('n', [
      'nid',
    ])
      ->condition('n.status', NodeInterface::PUBLISHED)
      ->countQuery()
      ->execute()
      ->fetchField();
  }

  // Get only active users.
  $quantum['users'] = Database::getConnection()
    ->select('users_field_data', 'u')
    ->fields('u', [
    'uid',
  ])
    ->condition('u.status', 1)
    ->countQuery()
    ->execute()
    ->fetchField();
  if ($this
    ->moduleHandler()
    ->moduleExists('comment')) {

    // Get only active comments.
    $quantum['comments'] = Database::getConnection()
      ->select('comment_field_data', 'c')
      ->fields('c', [
      'cid',
    ])
      ->condition('c.status', 1)
      ->countQuery()
      ->execute()
      ->fetchField();
  }
  return $quantum;
}