Passed
Push — master ( 719760...59ab2e )
by Angel Fernando Quiroz
18:35
created

UpdatePositionLink::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 4
dl 0
loc 8
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Controller\Api;
8
9
use Chamilo\CourseBundle\Entity\CLink;
10
use Chamilo\CourseBundle\Repository\CLinkRepository;
11
use Doctrine\ORM\EntityManager;
12
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpKernel\Attribute\AsController;
15
16
#[AsController]
17
class UpdatePositionLink extends AbstractController
18
{
19
    public function __invoke(CLink $link, CLinkRepository $repo, Request $request, EntityManager $em): CLink
20
    {
21
        $requestData = json_decode($request->getContent(), true);
22
        $newPosition = (int) $requestData['position'];
23
24
        $link->setDisplayOrder($newPosition);
25
26
        return $link;
27
    }
28
}
29