You are here

public function NodeTypeCountController::nodeCountState in Node Type count 8

This is the helper function for nodeCountState() to get the count.

Of the published or unpublished content of particular content type.

Parameters

bool $status: Node status.

string $type: Machine name of the content type.

Return value

numeric Returns the count of node published or unpublished in the Content Type.

1 call to NodeTypeCountController::nodeCountState()
NodeTypeCountController::nodeTypeCountPublished in src/Controller/NodeTypeCountController.php
Constructs a page with descriptive content.

File

src/Controller/NodeTypeCountController.php, line 123
Contains \Drupal\node_type_count\Controller\NodeTypeCountController.

Class

NodeTypeCountController
Controller routines for page example routes.

Namespace

Drupal\node_type_count\Controller

Code

public function nodeCountState($status, $type) {
  $query = \Drupal::entityQuery('node')
    ->condition('status', $status)
    ->condition('type', $type);
  $result = $query
    ->count()
    ->execute();
  return $result;
}