Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
GetTreeService
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 handle
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace oat\tao\model\Tree;
4
5use common_exception_IsAjaxAction;
6use oat\oatbox\service\ConfigurableService;
7use oat\tao\model\GenerisTreeFactory;
8use tao_helpers_Request;
9
10class GetTreeService extends ConfigurableService
11{
12    public const SERVICE_ID = 'tao/GetTree';
13
14    /**
15     * @param GetTreeRequest $request
16     * @return TreeWrapper
17     *
18     * @throws common_exception_IsAjaxAction
19     */
20    public function handle(GetTreeRequest $request)
21    {
22        if (!tao_helpers_Request::isAjax()) {
23            throw new common_exception_IsAjaxAction(__FUNCTION__);
24        }
25
26        $factory = new GenerisTreeFactory(
27            $request->isShowInstance(),
28            $request->getOpenNodes(),
29            $request->getLimit(),
30            $request->getOffset(),
31            $request->getResourceUrisToShow(),
32            $request->getFilters(),
33            $request->getFiltersOptions(),
34            []
35        );
36
37        $treeWrapper = new TreeWrapper($factory->buildTree($request->getClass()));
38
39        if ($request->isHideNode()) {
40            $treeWrapper = $treeWrapper->getDefaultChildren();
41        }
42
43        return $treeWrapper;
44    }
45}