protected function AssetReorderController::buildTree in farmOS 2.x
Build the asset tree.
Parameters
\Drupal\asset\Entity\AssetInterface|null $asset: Optionally specify the parent asset, to only build a sub-tree. If omitted, all assets will be included.
Return value
array Returns the asset tree for use in Drupal JS settings.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to AssetReorderController::buildTree()
- AssetReorderController::build in modules/
core/ ui/ location/ src/ Controller/ AssetReorderController.php - Builds the response.
File
- modules/
core/ ui/ location/ src/ Controller/ AssetReorderController.php, line 166
Class
- AssetReorderController
- Returns responses for asset drag and drop routes.
Namespace
Drupal\farm_ui_location\ControllerCode
protected function buildTree(AssetInterface $asset = NULL) {
$locations = $this
->getLocations($asset);
$tree = [];
if ($locations) {
foreach ($locations as $location) {
$element = [
'uuid' => $location
->uuid(),
'text' => $location
->label(),
'children' => $this
->buildTree($location),
'type' => $location
->bundle(),
'url' => $location
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString(),
];
$element['original_parent'] = $asset ? $asset
->uuid() : '';
$element['original_type'] = $asset ? $asset
->bundle() : '';
$tree[] = $element;
}
}
return $tree;
}