You are here

public function GetNodes::__construct in Taxonomy Facets 8

File

src/GetNodes.php, line 13

Class

GetNodes

Namespace

Drupal\taxonomy_facets

Code

public function __construct($filters) {
  $this->filters = $filters;
  $config = \Drupal::config('taxonomy_facets.settings');
  $this->limit = $config
    ->get('number_of_nodes_per_page');

  // Set node type that are part of filtering, from user config.
  $contentTypes = \Drupal::service('entity.manager')
    ->getStorage('node_type')
    ->loadMultiple();
  foreach ($contentTypes as $contentType) {
    if ($config
      ->get('ct_' . $contentType
      ->id())) {
      $this->nodeTypes[] = $contentType
        ->id();
    }
  }
  if (empty($_REQUEST['page'])) {
    $this->start = 0;
  }
  else {
    $this->start = $_REQUEST['page'] * $this->limit;
  }
}