You are here

protected function SavedSearch::urlRouteParameters in Search API Saved Searches 8

Gets an array of placeholders for this entity.

Individual entity classes may override this method to add additional placeholders if desired. If so, they should be sure to replicate the property caching logic.

Parameters

string $rel: The link relationship type, for example: canonical or edit-form.

Return value

array An array of URI placeholders.

Overrides EntityBase::urlRouteParameters

File

src/Entity/SavedSearch.php, line 455

Class

SavedSearch
Provides an entity type for saved searches.

Namespace

Drupal\search_api_saved_searches\Entity

Code

protected function urlRouteParameters($rel) {
  $params = parent::urlRouteParameters($rel);

  // Since Drupal is still not able to reproduce field values in their correct
  // data types, we cast to string to get a correct check even for ""/NULL.
  if ($rel === 'activate' || (string) $this
    ->getOwnerId() === '0') {
    $operations = [
      'canonical' => 'view',
      'activate' => 'activate',
      'edit-form' => 'edit',
      'delete-form' => 'delete',
    ];
    if (isset($operations[$rel])) {
      $params['token'] = $this
        ->getAccessToken($operations[$rel]);
    }
  }
  return $params;
}