public function SchemaMetatagClient::getTree in Schema.org Metatag 8.2
Same name in this branch
- 8.2 src/SchemaMetatagClient.php \Drupal\schema_metatag\SchemaMetatagClient::getTree()
- 8.2 tests/modules/schema_metatag_test/src/SchemaMetatagClient.php \Drupal\schema_metatag_test\SchemaMetatagClient::getTree()
Get some or all of the object tree.
Examples:
- Use all types from 'Organization' down: $parent = 'Organization' $depth = -1
- Use all 'Organization' types, but only a maximum of two levels deep: $parent = 'Organization' $depth = 2
- Use only the top level for 'Organization': $parent = 'Organization' $depth = 0
- Both 'Place' and 'Virtual Location': $parent = 'Place,VirtualLocation' $depth = -1
Parameters
string $parent_name: The key of the desired sub-array, if any.
int $depth: The desired depth to retrieve below the parent, -1 for the whole tree.
bool $clear: Whether to clear the array created by getTree().
bool $clear_tree: Whether to clear the array created by getObjectTree().
bool $clear_objects: Whether to clear the array created by getObjects().
Return value
array A hierarchical array of the object names.
Overrides SchemaMetatagClientInterface::getTree
2 calls to SchemaMetatagClient::getTree()
- SchemaMetatagClient::getOptionList in src/
SchemaMetatagClient.php - Create a @type option list from a given tree section.
- SchemaMetatagClient::getParents in src/
SchemaMetatagClient.php - Get an array of all parents of a given class.
1 method overrides SchemaMetatagClient::getTree()
- SchemaMetatagClient::getTree in tests/
modules/ schema_metatag_test/ src/ SchemaMetatagClient.php - Get some or all of the object tree.
File
- src/
SchemaMetatagClient.php, line 219
Class
- SchemaMetatagClient
- Class SchemaMetatagClient.
Namespace
Drupal\schema_metatagCode
public function getTree($parent_name = NULL, $depth = -1, $clear = FALSE, $clear_tree = FALSE, $clear_objects = FALSE) {
$cid = "schema_metatag.{$parent_name}.{$depth}";
if (!$clear && !$clear_tree && !$clear_objects && ($cache = $this->cacheBackend
->get($cid))) {
$tree = $cache->data;
}
else {
// Get the whole tree.
$base_tree = $this
->getObjectTree($clear_tree, $clear_objects);
$tree = $this
->getUncachedTree($base_tree, $parent_name, $depth);
$this->cacheBackend
->set($cid, $tree, CacheBackendInterface::CACHE_PERMANENT);
}
return $tree;
}