You are here

public function SqlRedirectNotFoundStorage::listRequests in Redirect 8

Returns the 404 request data.

Parameters

array $header: An array containing arrays of the redirect_404 fields data.

string $search: The search text. It is possible to have multiple '*' as a wildcard.

Return value

array A list of objects with the properties:

  • path
  • count
  • timestamp
  • langcode
  • resolved

Overrides RedirectNotFoundStorageInterface::listRequests

File

modules/redirect_404/src/SqlRedirectNotFoundStorage.php, line 144

Class

SqlRedirectNotFoundStorage
Provides an SQL implementation for redirect not found storage.

Namespace

Drupal\redirect_404

Code

public function listRequests(array $header = [], $search = NULL) {
  $query = $this->database
    ->select('redirect_404', 'r404')
    ->extend('Drupal\\Core\\Database\\Query\\TableSortExtender')
    ->orderByHeader($header)
    ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')
    ->limit(25)
    ->fields('r404');
  if ($search) {

    // Replace wildcards with PDO wildcards.
    // @todo Find a way to write a nicer pattern.
    $wildcard = '%' . trim(preg_replace('!\\*+!', '%', $this->database
      ->escapeLike($search)), '%') . '%';
    $query
      ->condition('path', $wildcard, 'LIKE');
  }
  $results = $query
    ->condition('resolved', 0, '=')
    ->execute()
    ->fetchAll();
  return $results;
}