public function SavedSearch::getType in Search API Saved Searches 8
Retrieves the type (bundle) entity for this saved search.
Return value
\Drupal\search_api_saved_searches\SavedSearchTypeInterface The type entity for this saved search.
Throws
\Drupal\search_api_saved_searches\SavedSearchesException Thrown if the type is unknown.
Overrides SavedSearchInterface::getType
1 call to SavedSearch::getType()
- SavedSearch::postSave in src/
Entity/ SavedSearch.php - Acts on a saved entity before the insert or update hook is invoked.
File
- src/
Entity/ SavedSearch.php, line 508
Class
- SavedSearch
- Provides an entity type for saved searches.
Namespace
Drupal\search_api_saved_searches\EntityCode
public function getType() {
if (!isset($this->cachedProperties['type'])) {
$type = \Drupal::entityTypeManager()
->getStorage('search_api_saved_search_type')
->load($this
->bundle());
$this->cachedProperties['type'] = $type ?: FALSE;
}
if (!$this->cachedProperties['type']) {
throw new SavedSearchesException("Saved search #{$this->id()} does not have a valid type set");
}
return $this->cachedProperties['type'];
}