actionListTree($request->getRouteParams(), $request->getParsedBody(), $request); } $where = $request->getQueryParams()['where'] ?? null; $parentId = $request->getQueryParam('parentId'); $maxDepth = $request->getQueryParam('maxDepth'); $onlyNotEmpty = (bool) $request->getQueryParam('onlyNotEmpty'); if ($where !== null && !is_array($where)) { throw new BadRequest(); } if ($maxDepth !== null) { $maxDepth = (int) $maxDepth; } $collection = $this->getRecordTreeService()->getTree( $parentId, [ 'where' => $where, 'onlyNotEmpty' => $onlyNotEmpty, ], $maxDepth ); if (!$collection) { throw new Error(); } return (object) [ 'list' => $collection->getValueMapList(), 'path' => $this->getRecordTreeService()->getTreeItemPath($parentId), 'data' => $this->getRecordTreeService()->getCategoryData($parentId), ]; } /** * @return string[] * @throws Forbidden */ public function getActionLastChildrenIdList(Request $request): array { if (!$this->acl->check($this->name, 'read')) { throw new Forbidden(); } $parentId = $request->getQueryParam('parentId'); return $this->getRecordTreeService()->getLastChildrenIdList($parentId); } /** * @return Service<\Espo\Core\ORM\Entity> */ protected function getRecordTreeService(): Service { $service = $this->getRecordService(); assert($service instanceof Service); return $service; } }