Passed
Push — master ( 370563...eb17c3 )
by Angel Fernando Quiroz
10:49 queued 14s
created

UpdateVisibilityLink::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\CoreBundle\ServiceHelper\CidReqHelper;
10
use Chamilo\CourseBundle\Entity\CLink;
11
use Chamilo\CourseBundle\Repository\CLinkRepository;
12
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
13
use Symfony\Component\HttpKernel\Attribute\AsController;
14
15
#[AsController]
16
class UpdateVisibilityLink extends AbstractController
17
{
18
    public function __construct(
19
        private readonly CidReqHelper $cidReqHelper,
20
    ) {}
21
22
    public function __invoke(CLink $link, CLinkRepository $repo): CLink
23
    {
24
        $repo->toggleVisibilityPublishedDraft(
25
            $link,
26
            $this->cidReqHelper->getCourseEntity(),
27
            $this->cidReqHelper->getSessionEntity()
28
        );
29
        $link->toggleVisibility();
30
31
        return $link;
32
    }
33
}
34