You are here

class Search in Search API Autocomplete 8

Describes the autocomplete settings for a certain search.

Plugin annotation


@ConfigEntityType(
  id = "search_api_autocomplete_search",
  label = @Translation("Autocomplete search"),
  label_collection = @Translation("Autocomplete searches"),
  label_singular = @Translation("autocomplete search"),
  label_plural = @Translation("autocomplete searches"),
  label_count = @PluralTranslation(
    singular = "@count autocomplete search",
    plural = "@count autocomplete searches",
  ),
  handlers = {
    "storage" = "Drupal\search_api_autocomplete\Entity\SearchStorage",
    "form" = {
      "default" = "\Drupal\search_api_autocomplete\Form\SearchEditForm",
      "edit" = "\Drupal\search_api_autocomplete\Form\SearchEditForm",
      "delete" = "\Drupal\Core\Entity\EntityDeleteForm",
    },
    "list_builder" = "\Drupal\Core\Entity\EntityListBuilder",
    "route_provider" = {
      "default" = "\Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
    },
  },
  admin_permission = "administer search_api_autocomplete",
  config_prefix = "search",
  entity_keys = {
    "id" = "id",
    "label" = "label",
    "uuid" = "uuid",
    "status" = "status",
  },
  links = {
    "edit-form" = "/admin/config/search/search-api/index/{search_api_index}/autocomplete/{search_api_autocomplete_search}/edit",
    "delete-form" = "/admin/config/search/search-api/index/{search_api_index}/autocomplete/{search_api_autocomplete_search}/delete",
  },
  config_export = {
    "id",
    "label",
    "status",
    "index_id",
    "suggester_settings",
    "suggester_weights",
    "suggester_limits",
    "search_settings",
    "options",
  }
)

Hierarchy

Expanded class hierarchy of Search

8 files declare their use of Search
CacheInvalidationTest.php in tests/src/Functional/CacheInvalidationTest.php
DependencyRemovalTest.php in tests/src/Kernel/DependencyRemovalTest.php
IndexOverviewForm.php in src/Form/IndexOverviewForm.php
IntegrationTest.php in tests/src/FunctionalJavascript/IntegrationTest.php
PagesIntegrationTest.php in tests/src/FunctionalJavascript/PagesIntegrationTest.php

... See full list

5 string references to 'Search'
search_api_autocomplete.info.yml in ./search_api_autocomplete.info.yml
search_api_autocomplete.info.yml
search_api_autocomplete_test.info.yml in tests/search_api_autocomplete_test/search_api_autocomplete_test.info.yml
tests/search_api_autocomplete_test/search_api_autocomplete_test.info.yml
search_api_autocomplete_test_hooks.info.yml in tests/search_api_autocomplete_test_hooks/search_api_autocomplete_test_hooks.info.yml
tests/search_api_autocomplete_test_hooks/search_api_autocomplete_test_hooks.info.yml
search_api_autocomplete_test_pages.info.yml in tests/search_api_autocomplete_test_pages/search_api_autocomplete_test_pages.info.yml
tests/search_api_autocomplete_test_pages/search_api_autocomplete_test_pages.info.yml
views.view.search_api_autocomplete_test_view.yml in tests/search_api_autocomplete_test/config/install/views.view.search_api_autocomplete_test_view.yml
tests/search_api_autocomplete_test/config/install/views.view.search_api_autocomplete_test_view.yml

File

src/Entity/Search.php, line 64

Namespace

Drupal\search_api_autocomplete\Entity
View source
class Search extends ConfigEntityBase implements SearchInterface {

  /**
   * The entity ID.
   *
   * @var string
   */
  protected $id;

  /**
   * The entity label.
   *
   * @var string
   */
  protected $label;

  /**
   * The index ID.
   *
   * @var string
   */
  protected $index_id;

  /**
   * The search index instance.
   *
   * @var \Drupal\search_api\IndexInterface|null
   *
   * @see \Drupal\search_api_autocomplete\Entity\Search::getIndex()
   */
  protected $index;

  /**
   * The settings of the suggesters selected for this search.
   *
   * The array has the following structure:
   *
   * @code
   * [
   *   'SUGGESTER_ID' => [
   *     // Settings …
   *   ],
   *   …
   * ]
   * @endcode
   *
   * @var array
   */
  protected $suggester_settings = [];

  /**
   * The suggester weights, keyed by suggester ID.
   *
   * @var int[]
   */
  protected $suggester_weights = [];

  /**
   * The suggester limits (where set), keyed by suggester ID.
   *
   * @var int[]
   */
  protected $suggester_limits = [];

  /**
   * The loaded suggester plugins.
   *
   * @var \Drupal\search_api_autocomplete\Suggester\SuggesterInterface[]|null
   */
  protected $suggesterInstances;

  /**
   * The settings for the search plugin.
   *
   * The array has the following structure:
   *
   * @code
   * [
   *   'SEARCH_ID' => [
   *     // Settings …
   *   ]
   * ]
   * @endcode
   *
   * There is always just a single entry in the array.
   *
   * @var array
   */
  protected $search_settings = [];

  /**
   * The search plugin.
   *
   * @var \Drupal\search_api_autocomplete\Search\SearchPluginInterface|null
   */
  protected $searchPlugin;

  /**
   * An array of general options for this search.
   *
   * @var array
   */
  protected $options = [];

  /**
   * {@inheritdoc}
   */
  public static function getDefaultOptions() {
    return [
      'autosubmit' => TRUE,
      'delay' => NULL,
      'limit' => 10,
      'min_length' => 1,
      'submit_button_selector' => ':submit',
    ];
  }

  /**
   * {@inheritdoc}
   */
  protected function urlRouteParameters($rel) {
    $parameters = parent::urlRouteParameters($rel);
    $parameters['search_api_index'] = $this
      ->getIndexId();
    return $parameters;
  }

  /**
   * {@inheritdoc}
   */
  public function getIndexId() {
    return $this->index_id;
  }

  /**
   * {@inheritdoc}
   */
  public function hasValidIndex() {
    return $this->index || Index::load($this->index_id);
  }

  /**
   * {@inheritdoc}
   */
  public function getIndex() {
    if (!isset($this->index)) {
      $this->index = Index::load($this->index_id);
      if (!$this->index) {
        throw new SearchApiAutocompleteException("The index with ID \"{$this->index_id}\" could not be loaded.");
      }
    }
    return $this->index;
  }

  /**
   * {@inheritdoc}
   */
  public function getSuggesters() {
    if ($this->suggesterInstances === NULL) {
      $this->suggesterInstances = \Drupal::getContainer()
        ->get('search_api_autocomplete.plugin_helper')
        ->createSuggesterPlugins($this, array_keys($this->suggester_settings));
    }
    return $this->suggesterInstances;
  }

  /**
   * {@inheritdoc}
   */
  public function getSuggesterIds() {
    if ($this->suggesterInstances !== NULL) {
      return array_keys($this->suggesterInstances);
    }
    return array_keys($this->suggester_settings);
  }

  /**
   * {@inheritdoc}
   */
  public function isValidSuggester($suggester_id) {
    $suggesters = $this
      ->getSuggesters();
    return !empty($suggesters[$suggester_id]);
  }

  /**
   * {@inheritdoc}
   */
  public function getSuggester($suggester_id) {
    $suggesters = $this
      ->getSuggesters();
    if (empty($suggesters[$suggester_id])) {
      $index_label = $this
        ->label();
      throw new SearchApiAutocompleteException("The suggester with ID '{$suggester_id}' could not be retrieved for index '{$index_label}'.");
    }
    return $suggesters[$suggester_id];
  }

  /**
   * {@inheritdoc}
   */
  public function addSuggester(SuggesterInterface $suggester) {

    // Make sure the suggesterInstances are loaded before trying to add a plugin
    // to them.
    if ($this->suggesterInstances === NULL) {
      $this
        ->getSuggesters();
    }
    $this->suggesterInstances[$suggester
      ->getPluginId()] = $suggester;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function removeSuggester($suggester_id) {

    // Depending on whether the suggesters have already been loaded, we have to
    // either remove the settings or the instance.
    if ($this->suggesterInstances === NULL) {
      unset($this->suggester_settings[$suggester_id]);
    }
    else {
      unset($this->suggesterInstances[$suggester_id]);
    }
    unset($this->suggester_weights[$suggester_id]);
    unset($this->suggester_limits[$suggester_id]);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setSuggesters(array $suggesters = NULL) {
    $this->suggesterInstances = $suggesters;

    // Sanitize the suggester weights and limits.
    $this->suggester_weights = array_intersect_key($this->suggester_weights, $suggesters);
    $this->suggester_limits = array_intersect_key($this->suggester_limits, $suggesters);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getSuggesterWeights() {
    return $this->suggester_weights;
  }

  /**
   * {@inheritdoc}
   */
  public function getSuggesterLimits() {
    return $this->suggester_limits;
  }

  /**
   * {@inheritdoc}
   */
  public function hasValidSearchPlugin() {
    return (bool) \Drupal::getContainer()
      ->get('plugin.manager.search_api_autocomplete.search')
      ->getDefinition($this
      ->getSearchPluginId(), FALSE);
  }

  /**
   * {@inheritdoc}
   */
  public function getSearchPluginId() {
    if ($this->searchPlugin) {
      return $this->searchPlugin
        ->getPluginId();
    }
    reset($this->search_settings);
    return key($this->search_settings);
  }

  /**
   * {@inheritdoc}
   */
  public function getSearchPlugin() {
    if (!$this->searchPlugin) {
      $plugin_id = $this
        ->getSearchPluginId();
      $configuration = [];
      if (!empty($this->search_settings[$plugin_id])) {
        $configuration = $this->search_settings[$plugin_id];
      }
      $this->searchPlugin = \Drupal::getContainer()
        ->get('search_api_autocomplete.plugin_helper')
        ->createSearchPlugin($this, $plugin_id, $configuration);
    }
    return $this->searchPlugin;
  }

  /**
   * {@inheritdoc}
   */
  public function getOption($name) {
    $options = $this
      ->getOptions();
    return isset($options[$name]) ? $options[$name] : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getOptions() {
    return $this->options + static::getDefaultOptions();
  }

  /**
   * {@inheritdoc}
   */
  public function setOption($name, $option) {
    $this->options[$name] = $option;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setOptions(array $options) {
    $this->options = $options;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function createQuery($keys, array $data = []) {
    return $this
      ->getSearchPlugin()
      ->createQuery($keys, $data);
  }

  /**
   * {@inheritdoc}
   */
  public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);

    // Make sure the search plugin's index matches this entity's index.
    $plugin_index_id = $this
      ->getSearchPlugin()
      ->getIndexId();
    if ($this
      ->getIndexId() !== $plugin_index_id) {
      throw new SearchApiAutocompleteException("Attempt to save autocomplete search '{$this->id()}' with search plugin '{$this->getSearchPluginId()}' of index '{$plugin_index_id}' while the autocomplete search points to index '{$this->getIndexId()}'");
    }

    // Make sure only one search entity is ever saved for a certain search
    // plugin.

    /** @var \Drupal\search_api_autocomplete\Entity\SearchStorage $storage */
    $search = $storage
      ->loadBySearchPlugin($this
      ->getSearchPluginId());
    if ($search && $search
      ->id() !== $this
      ->id()) {
      throw new SearchApiAutocompleteException("Attempt to save autocomplete search '{$this->id()}' with search plugin '{$this->getSearchPluginId()}' when this plugin is already used for '{$search->id()}'");
    }

    // If we are in the process of syncing, we shouldn't change any entity
    // properties (or other configuration).
    if ($this
      ->isSyncing()) {
      return;
    }

    // Write the plugin settings to the persistent *_settings properties.
    $this
      ->writeChangesToSettings();

    // If there are no suggesters set for the search, it can't be enabled.
    if (!$this
      ->getSuggesters()) {
      $this
        ->disable();
    }
  }

  /**
   * {@inheritdoc}
   */
  protected function invalidateTagsOnSave($update) {
    parent::invalidateTagsOnSave($update);
    $plugin_id = $this
      ->getSearchPluginId();
    Cache::invalidateTags([
      "search_api_autocomplete_search_list:{$plugin_id}",
    ]);
  }

  /**
   * {@inheritdoc}
   */
  protected static function invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities) {
    parent::invalidateTagsOnDelete($entity_type, $entities);
    $tags = [];
    foreach ($entities as $entity) {
      if ($entity instanceof Search) {
        $plugin_id = $entity
          ->getSearchPluginId();
        $tags[] = "search_api_autocomplete_search_list:{$plugin_id}";
      }
    }
    if ($tags) {
      Cache::invalidateTags(array_unique($tags));
    }
  }

  /**
   * Prepares for changes to this search to be persisted.
   *
   * To this end, the settings for all loaded plugin objects are written back to
   * the corresponding *_settings properties.
   *
   * @return $this
   */
  protected function writeChangesToSettings() {

    // Write the enabled suggesters to the settings property.
    $this->suggester_settings = [];
    foreach ($this
      ->getSuggesters() as $suggester_id => $suggester) {
      if ($suggester
        ->supportsSearch($this)) {
        $configuration = $suggester
          ->getConfiguration();
        $this->suggester_settings[$suggester_id] = $configuration;
      }
      else {
        unset($this->suggesterInstances[$suggester_id]);
      }
    }

    // Write the search plugin configuration to the settings property.
    if ($this->searchPlugin !== NULL) {
      $plugin_id = $this->searchPlugin
        ->getPluginId();
      $this->search_settings = [
        $plugin_id => $this->searchPlugin
          ->getConfiguration(),
      ];
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    $dependencies = $this
      ->getDependencyData();

    // Keep only "enforced" dependencies, then add those computed by
    // getDependencyData().
    $this->dependencies = array_intersect_key($this->dependencies, [
      'enforced' => TRUE,
    ]);
    $this->dependencies += array_map('array_keys', $dependencies);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function onDependencyRemoval(array $dependencies) {
    $changed = parent::onDependencyRemoval($dependencies);
    $plugins = $this
      ->getAllPlugins();
    $dependency_data = $this
      ->getDependencyData();

    // Make sure our dependency data has the exact same keys as $dependencies,
    // to simplify the subsequent code.
    $dependencies = array_filter($dependencies);
    $dependency_data = array_intersect_key($dependency_data, $dependencies);
    $dependency_data += array_fill_keys(array_keys($dependencies), []);
    $call_on_removal = [];
    foreach ($dependencies as $dependency_type => $dependency_objects) {

      // Annoyingly, modules and theme dependencies come not keyed by dependency
      // name here, while entities do. Flip the array for modules and themes to
      // make the code simpler.
      if (in_array($dependency_type, [
        'module',
        'theme',
      ])) {
        $dependency_objects = array_flip($dependency_objects);
      }
      $dependency_data[$dependency_type] = array_intersect_key($dependency_data[$dependency_type], $dependency_objects);
      foreach ($dependency_data[$dependency_type] as $name => $dependency_sources) {

        // We first remove all the "hard" dependencies.
        if (!empty($dependency_sources['always'])) {
          foreach ($dependency_sources['always'] as $plugin_type => $type_plugins) {

            // We can hardly remove the search entity itself.
            if ($plugin_type == 'entity') {
              continue;
            }

            // Otherwise, we need to remove the plugin in question.
            $changed = TRUE;
            $plugins[$plugin_type] = array_diff_key($plugins[$plugin_type], $type_plugins);
          }
        }

        // Then, collect all the optional ones.
        if (!empty($dependency_sources['optional'])) {

          // However this plays out, it will lead to a change.
          $changed = TRUE;
          foreach ($dependency_sources['optional'] as $plugin_type => $type_plugins) {

            // Only include those plugins that have not already been removed.
            $type_plugins = array_intersect_key($type_plugins, $plugins[$plugin_type]);
            foreach ($type_plugins as $plugin_id => $plugin) {
              $call_on_removal[$plugin_type][$plugin_id][$dependency_type][$name] = $dependency_objects[$name];
            }
          }
        }
      }
    }

    // Now for all plugins with optional dependencies (stored in
    // $call_on_removal, mapped to their removed dependencies) call their
    // onDependencyRemoval() methods.
    foreach ($call_on_removal as $plugin_type => $type_plugins) {
      foreach ($type_plugins as $plugin_id => $plugin_dependencies) {
        $plugin = $plugins[$plugin_type][$plugin_id];
        $removal_successful = $plugin
          ->onDependencyRemoval($plugin_dependencies);
        if (!$removal_successful) {
          unset($plugins[$plugin_type][$plugin_id]);
        }
      }
    }

    // If we had to remove the search plugin, the search entity cannot be
    // "rescued". Return FALSE in this case, which will cause the entity to be
    // deleted.
    if (empty($plugins['search_plugin'])) {
      return FALSE;
    }

    // If there are no suggesters left, we just disable the search.
    if (empty($plugins['suggesters'])) {
      $this
        ->disable();
    }

    // In case we removed any suggesters, set our suggesters to the remaining
    // ones. (If we didn't remove any, this is a no-op.) Since the plugins
    // already changed their configuration, if necessary, those changes should
    // be propagated automatically when saving via preSave().
    $this
      ->setSuggesters($plugins['suggesters']);
    return $changed;
  }

  /**
   * Retrieves data about this search entity's dependencies.
   *
   * The return value is structured as follows:
   *
   * @code
   * [
   *   'config' => [
   *     'CONFIG_DEPENDENCY_KEY' => [
   *       'always' => [
   *         'search_plugin' => [
   *           'SEARCH_ID' => $search_plugin,
   *         ],
   *         'suggesters' => [
   *           'SUGGESTER_ID_1' => $suggester_1,
   *           'SUGGESTER_ID_2' => $suggester_2,
   *         ],
   *       ],
   *       'optional' => [
   *         'entity' => [
   *           'SEARCH_ID' => $search,
   *         ],
   *       ],
   *     ],
   *   ],
   * ]
   * @endcode
   *
   * Enforced dependencies are not included in this method's return value.
   *
   * @return object[][][][][]
   *   An associative array containing the search's dependencies. The array is
   *   first keyed by the config dependency type ("module", "config", etc.) and
   *   then by the names of the config dependencies of that type which the index
   *   has. The values are associative arrays with up to two keys, "always" and
   *   "optional", specifying whether the dependency is a hard one by the plugin
   *   (or entity) in question or potentially depending on the configuration.
   *   The values on this level are arrays with keys "entity", "search_plugin"
   *   and/or "suggesters" and values arrays of IDs mapped to their entities or
   *   plugins.
   */
  protected function getDependencyData() {
    $dependency_data = [];

    // Since calculateDependencies() will work directly on the $dependencies
    // property, we first save its original state and then restore it
    // afterwards.
    $original_dependencies = $this->dependencies;
    parent::calculateDependencies();
    unset($this->dependencies['enforced']);
    foreach ($this->dependencies as $dependency_type => $list) {
      foreach ($list as $name) {
        $dependency_data[$dependency_type][$name]['always']['entity'][$this->id] = $this;
      }
    }
    $this->dependencies = $original_dependencies;

    // Include the dependency to the search index.
    if ($this
      ->hasValidIndex()) {
      $name = $this
        ->getIndex()
        ->getConfigDependencyName();
      $dependency_data['config'][$name]['always']['entity'][$this->id] = $this;
    }

    // All other plugins can be treated uniformly.
    foreach ($this
      ->getAllPlugins() as $plugin_type => $type_plugins) {
      foreach ($type_plugins as $plugin_id => $plugin) {

        // Largely copied from
        // \Drupal\Core\Plugin\PluginDependencyTrait::calculatePluginDependencies().
        $definition = $plugin
          ->getPluginDefinition();

        // First, always depend on the module providing the plugin.
        $dependency_data['module'][$definition['provider']]['always'][$plugin_type][$plugin_id] = $plugin;

        // Plugins can declare additional dependencies in their definition.
        if (isset($definition['config_dependencies'])) {
          foreach ($definition['config_dependencies'] as $dependency_type => $list) {
            foreach ($list as $name) {
              $dependency_data[$dependency_type][$name]['always'][$plugin_type][$plugin_id] = $plugin;
            }
          }
        }

        // Finally, add the dynamically-calculated dependencies of the plugin.
        foreach ($plugin
          ->calculateDependencies() as $dependency_type => $list) {
          foreach ($list as $name) {
            $dependency_data[$dependency_type][$name]['optional'][$plugin_type][$plugin_id] = $plugin;
          }
        }
      }
    }
    return $dependency_data;
  }

  /**
   * Retrieves all the plugins contained in this search entity.
   *
   * @return \Drupal\search_api_autocomplete\Plugin\PluginInterface[][]
   *   All plugins contained in this search, keyed by the plugin type
   *   ("search_plugin" or "suggesters") and their plugin IDs.
   */
  protected function getAllPlugins() {
    $plugins = [];
    if ($this
      ->hasValidSearchPlugin()) {
      $plugin_id = $this
        ->getSearchPluginId();
      $plugins['search_plugin'][$plugin_id] = $this
        ->getSearchPlugin();
    }
    $plugins['suggesters'] = $this
      ->getSuggesters();
    return $plugins;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ConfigEntityBase::$isUninstalling private property Whether the config is being deleted by the uninstall process.
ConfigEntityBase::$langcode protected property The language code of the entity's default language.
ConfigEntityBase::$originalId protected property The original ID of the configuration entity.
ConfigEntityBase::$status protected property The enabled/disabled status of the configuration entity. 4
ConfigEntityBase::$third_party_settings protected property Third party entity settings.
ConfigEntityBase::$trustedData protected property Trust supplied data and not use configuration schema on save.
ConfigEntityBase::$uuid protected property The UUID for this entity.
ConfigEntityBase::$_core protected property Information maintained by Drupal core about configuration.
ConfigEntityBase::addDependency protected function Overrides \Drupal\Core\Entity\DependencyTrait:addDependency().
ConfigEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides EntityBase::createDuplicate 1
ConfigEntityBase::disable public function Disables the configuration entity. Overrides ConfigEntityInterface::disable 1
ConfigEntityBase::enable public function Enables the configuration entity. Overrides ConfigEntityInterface::enable
ConfigEntityBase::get public function Returns the value of a property. Overrides ConfigEntityInterface::get
ConfigEntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides EntityBase::getCacheTagsToInvalidate 1
ConfigEntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityBase::getConfigDependencyName
ConfigEntityBase::getConfigManager protected static function Gets the configuration manager.
ConfigEntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityBase::getConfigTarget
ConfigEntityBase::getDependencies public function Gets the configuration dependencies. Overrides ConfigEntityInterface::getDependencies
ConfigEntityBase::getOriginalId public function Gets the original ID. Overrides EntityBase::getOriginalId
ConfigEntityBase::getThirdPartyProviders public function Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface::getThirdPartyProviders
ConfigEntityBase::getThirdPartySetting public function Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface::getThirdPartySetting
ConfigEntityBase::getThirdPartySettings public function Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface::getThirdPartySettings
ConfigEntityBase::getTypedConfig protected function Gets the typed config manager.
ConfigEntityBase::hasTrustedData public function Gets whether on not the data is trusted. Overrides ConfigEntityInterface::hasTrustedData
ConfigEntityBase::isInstallable public function Checks whether this entity is installable. Overrides ConfigEntityInterface::isInstallable 2
ConfigEntityBase::isNew public function Overrides Entity::isNew(). Overrides EntityBase::isNew
ConfigEntityBase::isUninstalling public function Returns whether this entity is being changed during the uninstall process. Overrides ConfigEntityInterface::isUninstalling
ConfigEntityBase::link public function Deprecated way of generating a link to the entity. See toLink(). Overrides EntityBase::link
ConfigEntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityBase::preDelete 8
ConfigEntityBase::save public function Saves an entity permanently. Overrides EntityBase::save 1
ConfigEntityBase::set public function Sets the value of a property. Overrides ConfigEntityInterface::set
ConfigEntityBase::setOriginalId public function Sets the original ID. Overrides EntityBase::setOriginalId
ConfigEntityBase::setStatus public function Sets the status of the configuration entity. Overrides ConfigEntityInterface::setStatus
ConfigEntityBase::setThirdPartySetting public function Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface::setThirdPartySetting
ConfigEntityBase::setUninstalling public function
ConfigEntityBase::sort public static function Helper callback for uasort() to sort configuration entities by weight and label. 6
ConfigEntityBase::status public function Returns whether the configuration entity is enabled. Overrides ConfigEntityInterface::status 4
ConfigEntityBase::toArray public function Gets an array of all property values. Overrides EntityBase::toArray 2
ConfigEntityBase::toUrl public function Gets the URL object for the entity. Overrides EntityBase::toUrl
ConfigEntityBase::trustData public function Sets that the data should be trusted. Overrides ConfigEntityInterface::trustData
ConfigEntityBase::unsetThirdPartySetting public function Unsets a third-party setting. Overrides ThirdPartySettingsInterface::unsetThirdPartySetting
ConfigEntityBase::url public function Gets the public URL for this entity. Overrides EntityBase::url
ConfigEntityBase::urlInfo public function Gets the URL object for the entity. Overrides EntityBase::urlInfo
ConfigEntityBase::__construct public function Constructs an Entity object. Overrides EntityBase::__construct 10
ConfigEntityBase::__sleep public function Overrides EntityBase::__sleep 4
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencySerializationTrait::__wakeup public function 2
DependencyTrait::$dependencies protected property The object's dependencies.
DependencyTrait::addDependencies protected function Adds multiple dependencies.
DependencyTrait::addDependency protected function Adds a dependency. Aliased as: addDependencyTrait
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::access public function Checks data value access. Overrides AccessibleInterface::access 1
EntityBase::bundle public function Gets the bundle of the entity. Overrides EntityInterface::bundle 1
EntityBase::create public static function Constructs a new entity object, without permanently saving it. Overrides EntityInterface::create
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::entityManager Deprecated protected function Gets the entity manager.
EntityBase::entityTypeBundleInfo protected function Gets the entity type bundle info service.
EntityBase::entityTypeManager protected function Gets the entity type manager.
EntityBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
EntityBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
EntityBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
EntityBase::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
EntityBase::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
EntityBase::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
EntityBase::getListCacheTagsToInvalidate protected function The list cache tags to invalidate for this entity.
EntityBase::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
EntityBase::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
EntityBase::id public function Gets the identifier. Overrides EntityInterface::id 11
EntityBase::label public function Gets the label of the entity. Overrides EntityInterface::label 6
EntityBase::language public function Gets the language of the entity. Overrides EntityInterface::language 1
EntityBase::languageManager protected function Gets the language manager.
EntityBase::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityInterface::postCreate 4
EntityBase::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface::postDelete 16
EntityBase::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
EntityBase::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides EntityInterface::postSave 14
EntityBase::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 5
EntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityInterface::referencedEntities 1
EntityBase::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
EntityBase::uriRelationships public function Gets a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityInterface::uuid 1
EntityBase::uuidGenerator protected function Gets the UUID generator.
PluginDependencyTrait::calculatePluginDependencies protected function Calculates and adds dependencies of a specific plugin instance. 1
PluginDependencyTrait::getPluginDependencies protected function Calculates and returns dependencies of a specific plugin instance.
PluginDependencyTrait::moduleHandler protected function Wraps the module handler. 1
PluginDependencyTrait::themeHandler protected function Wraps the theme handler. 1
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
Search::$id protected property The entity ID.
Search::$index protected property The search index instance.
Search::$index_id protected property The index ID.
Search::$label protected property The entity label.
Search::$options protected property An array of general options for this search.
Search::$searchPlugin protected property The search plugin.
Search::$search_settings protected property The settings for the search plugin.
Search::$suggesterInstances protected property The loaded suggester plugins.
Search::$suggester_limits protected property The suggester limits (where set), keyed by suggester ID.
Search::$suggester_settings protected property The settings of the suggesters selected for this search.
Search::$suggester_weights protected property The suggester weights, keyed by suggester ID.
Search::addSuggester public function Adds a suggester to this search. Overrides SearchInterface::addSuggester
Search::calculateDependencies public function Calculates dependencies and stores them in the dependency property. Overrides ConfigEntityBase::calculateDependencies
Search::createQuery public function Creates a query object for this search. Overrides SearchInterface::createQuery
Search::getAllPlugins protected function Retrieves all the plugins contained in this search entity.
Search::getDefaultOptions public static function Retrieves the default options for a search. Overrides SearchInterface::getDefaultOptions
Search::getDependencyData protected function Retrieves data about this search entity's dependencies.
Search::getIndex public function Retrieves the index this search belongs to. Overrides SearchInterface::getIndex
Search::getIndexId public function Retrieves the ID of the index this search belongs to. Overrides SearchInterface::getIndexId
Search::getOption public function Gets a specific option's value. Overrides SearchInterface::getOption
Search::getOptions public function Gets the search's options. Overrides SearchInterface::getOptions
Search::getSearchPlugin public function Retrieves the search plugin. Overrides SearchInterface::getSearchPlugin
Search::getSearchPluginId public function Retrieves the search plugin's ID. Overrides SearchInterface::getSearchPluginId
Search::getSuggester public function Retrieves a specific suggester plugin for this search. Overrides SearchInterface::getSuggester
Search::getSuggesterIds public function Retrieves the IDs of all suggesters enabled for this search. Overrides SearchInterface::getSuggesterIds
Search::getSuggesterLimits public function Retrieves the individual limits set for the search's suggesters. Overrides SearchInterface::getSuggesterLimits
Search::getSuggesters public function Retrieves this search's suggester plugins. Overrides SearchInterface::getSuggesters
Search::getSuggesterWeights public function Retrieves the weights set for the search's suggesters. Overrides SearchInterface::getSuggesterWeights
Search::hasValidIndex public function Determines whether this search has a valid index set. Overrides SearchInterface::hasValidIndex
Search::hasValidSearchPlugin public function Determines whether the search plugin set for this search is valid. Overrides SearchInterface::hasValidSearchPlugin
Search::invalidateTagsOnDelete protected static function Override to never invalidate the individual entities' cache tags; the config system already invalidates them. Overrides ConfigEntityBase::invalidateTagsOnDelete
Search::invalidateTagsOnSave protected function Override to never invalidate the entity's cache tag; the config system already invalidates it. Overrides ConfigEntityBase::invalidateTagsOnSave
Search::isValidSuggester public function Determines whether the given suggester ID is valid for this search. Overrides SearchInterface::isValidSuggester
Search::onDependencyRemoval public function Informs the entity that entities it depends on will be deleted. Overrides ConfigEntityBase::onDependencyRemoval
Search::preSave public function Acts on an entity before the presave hook is invoked. Overrides ConfigEntityBase::preSave
Search::removeSuggester public function Removes a suggester from this search. Overrides SearchInterface::removeSuggester
Search::setOption public function Sets an option. Overrides SearchInterface::setOption
Search::setOptions public function Sets the search options. Overrides SearchInterface::setOptions
Search::setSuggesters public function Sets this search's suggester plugins. Overrides SearchInterface::setSuggesters
Search::urlRouteParameters protected function Gets an array of placeholders for this entity. Overrides EntityBase::urlRouteParameters
Search::writeChangesToSettings protected function Prepares for changes to this search to be persisted.
SynchronizableEntityTrait::$isSyncing protected property Whether this entity is being created, updated or deleted through a synchronization process.
SynchronizableEntityTrait::isSyncing public function
SynchronizableEntityTrait::setSyncing public function