You are here

public function SavedSearch::getQuery in Search API Saved Searches 8

Retrieves the search query of this saved search.

Return value

\Drupal\search_api\Query\QueryInterface|null The search query of this saved search, or NULL if it couldn't be retrieved.

Overrides SavedSearchInterface::getQuery

3 calls to SavedSearch::getQuery()
SavedSearch::postCreate in src/Entity/SavedSearch.php
Acts on a created entity before hooks are invoked.
SavedSearch::postSave in src/Entity/SavedSearch.php
Acts on a saved entity before the insert or update hook is invoked.
SavedSearch::preSave in src/Entity/SavedSearch.php
Acts on an entity before the presave hook is invoked.

File

src/Entity/SavedSearch.php, line 525

Class

SavedSearch
Provides an entity type for saved searches.

Namespace

Drupal\search_api_saved_searches\Entity

Code

public function getQuery() {
  if (!isset($this->cachedProperties['query'])) {
    $this->cachedProperties['query'] = FALSE;
    $query = $this
      ->get('query')->value;
    if ($query) {
      $this->cachedProperties['query'] = unserialize($query);
    }
  }
  return $this->cachedProperties['query'] ?: NULL;
}