You are here

protected function PrettyPathsFunctionalTest::buildUrlsFromFacet in Facets Pretty Paths 8

Given a Facet, build the search results for it.

Parameters

\Drupal\facets\FacetInterface $facet: The facet.

Return value

array|\Drupal\Core\Url[] The URLs.

2 calls to PrettyPathsFunctionalTest::buildUrlsFromFacet()
PrettyPathsFunctionalTest::testPrettyPathsCoder in tests/src/Functional/PrettyPathsFunctionalTest.php
Tests that the coder plugins get called properly when generating the URLs.
PrettyPathsFunctionalTest::testPrettyPathsUrlProcessor in tests/src/Functional/PrettyPathsFunctionalTest.php
Tests the Facets Pretty Paths URL preprocessor..

File

tests/src/Functional/PrettyPathsFunctionalTest.php, line 113

Class

PrettyPathsFunctionalTest
Main functional test for the Pretty Paths URL processor.

Namespace

Drupal\Tests\facets_pretty_paths\Functional

Code

protected function buildUrlsFromFacet(FacetInterface $facet) {
  $source = $facet
    ->getFacetSource();

  /** @var \Drupal\facets\UrlProcessor\UrlProcessorPluginManager $manager */
  $manager = $this->container
    ->get('plugin.manager.facets.url_processor');

  /** @var \Drupal\facets_pretty_paths\Plugin\facets\url_processor\FacetsPrettyPathsUrlProcessor $processor */
  $processor = $manager
    ->createInstance('facets_pretty_paths', [
    'facet' => $facet,
  ]);
  $source
    ->fillFacetsWithResults([
    $facet,
  ]);

  /** @var \Drupal\facets\Result\ResultInterface[] $results */
  $results = $processor
    ->buildUrls($facet, $facet
    ->getResults());

  /** @var \Drupal\Core\Url[] $urls */
  $urls = [];
  foreach ($results as $result) {
    $urls[] = $result
      ->getUrl();
  }
  array_filter($urls);
  return $urls;
}