W3cubDocs

/Drupal 8

public static function QueryBase::getNamespaces

public static QueryBase::getNamespaces($object)

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.

File

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

Class

QueryBase
The base entity query class.

Namespace

Drupal\Core\Entity\Query

Code

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Query!QueryBase.php/function/QueryBase::getNamespaces/8.1.x