function QueryBase::getNamespaces

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::getNamespaces()
  2. 10 core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::getNamespaces()
  3. 11.x core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::getNamespaces()

Gets a list of namespaces of the ancestors of a class.

Parameters

$object: An object within a namespace.

Return value

array A list containing the namespace of the class, the namespace of the parent of the class and so on and so on.

5 calls to QueryBase::getNamespaces()
PgsqlQueryFactory::__construct in core/modules/workspaces/src/EntityQuery/PgsqlQueryFactory.php
Constructs a PgsqlQueryFactory object.
QueryFactory::__construct in core/modules/workspaces/src/EntityQuery/QueryFactory.php
Constructs a QueryFactory object.
QueryFactory::__construct in core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php
Constructs a QueryFactory object.
QueryFactory::__construct in core/lib/Drupal/Core/Entity/Query/Sql/QueryFactory.php
Constructs a QueryFactory object.
QueryFactory::__construct in core/lib/Drupal/Core/Entity/Query/Null/QueryFactory.php
Constructs a QueryFactory object.

File

core/lib/Drupal/Core/Entity/Query/QueryBase.php, line 477

Class

QueryBase
The base entity query class.

Namespace

Drupal\Core\Entity\Query

Code

public static function getNamespaces($object) {
    $namespaces = [];
    for ($class = get_class($object); $class; $class = get_parent_class($class)) {
        $namespaces[] = substr($class, 0, strrpos($class, '\\'));
    }
    return $namespaces;
}

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