You are here

public function W3CProcessor::findAllPages in W3C Validator 8

Find all pages URL to validate in the site.

Currently, this method returns :

  • frontpage
  • nodes.

@todo return other pages.

Return value

array List of pages to validate.

1 call to W3CProcessor::findAllPages()
W3CProcessor::validateAllPages in src/W3CProcessor.php
Validates all flagged pages in the limit of the number given.

File

src/W3CProcessor.php, line 121

Class

W3CProcessor
Processor for page validation.

Namespace

Drupal\w3c_validator

Code

public function findAllPages() {
  $all_site_pages = [];

  // Add frontpage to list.
  $site_frontpage = $this->configFactory
    ->get('system.site')
    ->get('page.front');
  $all_site_pages[$site_frontpage] = [
    'route' => '<front>',
    'url' => $site_frontpage,
    'title' => $this
      ->t('Frontpage'),
  ];

  // Add all nodes.
  $query = $this->connection
    ->select('node_field_data', 'n');
  $query
    ->fields('n', [
    'nid',
    'title',
  ]);
  $query
    ->addExpression("CONCAT('entity.node.canonical', '')", 'route');
  $query
    ->addExpression("CONCAT('node/', n.nid)", 'url');
  $nodes = $query
    ->execute()
    ->fetchAllAssoc('url', \PDO::FETCH_ASSOC);
  $all_site_pages = array_merge($all_site_pages, $nodes);

  // All route names.
  if ($this
    ->moduleSettings()
    ->get('admin_pages')) {
    $query = $this->connection
      ->select('router', 'r');
    $query
      ->addField('r', 'pattern_outline', 'url');
    $query
      ->addField('r', 'name', 'title');
    $query
      ->addField('r', 'name', 'route');
    $query
      ->condition('pattern_outline', '%\\%%', 'NOT LIKE');
    $query
      ->condition('pattern_outline', '%<%', 'NOT LIKE');
    $paths = $query
      ->execute()
      ->fetchAllAssoc('url', \PDO::FETCH_ASSOC);
    $all_site_pages = array_merge($all_site_pages, $paths);
  }
  return $all_site_pages;
}