Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Uni Osnabrück
Stud.IP
Commits
f684f77e
Commit
f684f77e
authored
8 months ago
by
Elmar Ludwig
Browse files
Options
Downloads
Patches
Plain Diff
Revert "remove unused RangeTreeIndex route, fixes #4397"
This reverts commit
b4c1d253
.
parent
74077941
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/classes/JsonApi/Routes/RangeTree/RangeTreeIndex.php
+53
-0
53 additions, 0 deletions
lib/classes/JsonApi/Routes/RangeTree/RangeTreeIndex.php
with
53 additions
and
0 deletions
lib/classes/JsonApi/Routes/RangeTree/RangeTreeIndex.php
0 → 100644
+
53
−
0
View file @
f684f77e
<?php
namespace
JsonApi\Routes\RangeTree
;
use
Psr\Http\Message\ServerRequestInterface
as
Request
;
use
Psr\Http\Message\ResponseInterface
as
Response
;
use
JsonApi\Errors\AuthorizationFailedException
;
use
JsonApi\Errors\RecordNotFoundException
;
use
JsonApi\JsonApiController
;
/**
* Zeigt eine bestimmte Veranstaltung an.
*/
class
RangeTreeIndex
extends
JsonApiController
{
protected
$allowedIncludePaths
=
[
'children'
,
'courses'
,
'institute'
,
'parent'
,
];
protected
$allowedPagingParameters
=
[
'offset'
,
'limit'
];
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public
function
__invoke
(
Request
$request
,
Response
$response
,
$args
)
{
$tree
=
\TreeAbstract
::
getInstance
(
'StudipSemTree'
,
[
'visible_only'
=>
1
]);
$studyAreas
=
self
::
mapTree
(
'root'
,
$tree
);
list
(
$offset
,
$limit
)
=
$this
->
getOffsetAndLimit
();
return
$this
->
getPaginatedContentResponse
(
array_slice
(
$studyAreas
,
$offset
,
$limit
),
count
(
$studyAreas
)
);
}
private
function
mapTree
(
$parentId
,
&
$tree
)
{
$level
=
[];
$kids
=
$tree
->
getKids
(
$parentId
);
if
(
is_array
(
$kids
)
&&
count
(
$kids
)
>
0
)
{
foreach
(
$kids
as
$kid
)
{
$level
[]
=
\StudipStudyArea
::
find
(
$kid
);
$level
=
array_merge
(
$level
,
self
::
mapTree
(
$kid
,
$tree
));
}
}
return
$level
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment