interface AlterableInterface

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Query/AlterableInterface.php \Drupal\Core\Database\Query\AlterableInterface
  2. 8.9.x core/lib/Drupal/Core/Database/Query/AlterableInterface.php \Drupal\Core\Database\Query\AlterableInterface
  3. 10 core/lib/Drupal/Core/Database/Query/AlterableInterface.php \Drupal\Core\Database\Query\AlterableInterface

Interface for a query that can be manipulated via an alter hook.

Hierarchy

Expanded class hierarchy of AlterableInterface

All classes that implement AlterableInterface

14 files declare their use of AlterableInterface
block_content.module in core/modules/block_content/block_content.module
Allows the creation of content blocks through the user interface.
database_test.module in core/modules/system/tests/modules/database_test/database_test.module
DefaultSelection.php in core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
entity_test.module in core/modules/system/tests/modules/entity_test/entity_test.module
GroupwiseMax.php in core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php

... See full list

File

core/lib/Drupal/Core/Database/Query/AlterableInterface.php, line 8

Namespace

Drupal\Core\Database\Query
View source
interface AlterableInterface {
    
    /**
     * Adds a tag to a query.
     *
     * Tags are strings that identify a query. A query may have any number of
     * tags. Tags are used to mark a query so that alter hooks may decide if they
     * wish to take action. Tags should be all lower-case and contain only
     * letters, numbers, and underscore, and start with a letter. That is, they
     * should follow the same rules as PHP identifiers in general.
     *
     * @param $tag
     *   The tag to add.
     *
     * @return $this
     *   The called object.
     */
    public function addTag($tag);
    
    /**
     * Determines if a given query has a given tag.
     *
     * @param $tag
     *   The tag to check.
     *
     * @return bool
     *   TRUE if this query has been marked with this tag, FALSE otherwise.
     */
    public function hasTag($tag);
    
    /**
     * Determines if a given query has all specified tags.
     *
     * Each tag to check should be supplied as a separate argument.
     *
     * @todo Restore PHPDoc of variadic argument in Drupal 8.8, see
     * https://www.drupal.org/project/drupal/issues/3029729
     *
     * @return bool
     *   TRUE if this query has been marked with all specified tags, FALSE
     *   otherwise.
     */
    public function hasAllTags();
    
    /**
     * Determines if a given query has any specified tag.
     *
     * Each tag to check should be supplied as a separate argument.
     *
     * @todo Restore PHPDoc of variadic argument in Drupal 8.8, see
     * https://www.drupal.org/project/drupal/issues/3029729
     *
     * @return bool
     *   TRUE if this query has been marked with at least one of the specified
     *   tags, FALSE otherwise.
     */
    public function hasAnyTag();
    
    /**
     * Adds additional metadata to the query.
     *
     * Often, a query may need to provide additional contextual data to alter
     * hooks. Alter hooks may then use that information to decide if and how
     * to take action.
     *
     * @param $key
     *   The unique identifier for this piece of metadata. Must be a string that
     *   follows the same rules as any other PHP identifier.
     * @param $object
     *   The additional data to add to the query. May be any valid PHP variable.
     *
     * @return $this
     *   The called object.
     */
    public function addMetaData($key, $object);
    
    /**
     * Retrieves a given piece of metadata.
     *
     * @param $key
     *   The unique identifier for the piece of metadata to retrieve.
     *
     * @return mixed
     *   The previously attached metadata object, or NULL if one doesn't exist.
     */
    public function getMetaData($key);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
AlterableInterface::addMetaData public function Adds additional metadata to the query. 3
AlterableInterface::addTag public function Adds a tag to a query. 3
AlterableInterface::getMetaData public function Retrieves a given piece of metadata. 3
AlterableInterface::hasAllTags public function Determines if a given query has all specified tags. 3
AlterableInterface::hasAnyTag public function Determines if a given query has any specified tag. 3
AlterableInterface::hasTag public function Determines if a given query has a given tag. 3

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.