Passed
Pull Request — master (#5143)
by Angel Fernando Quiroz
06:49
created

ResourceLinkRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 17
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A remove() 0 10 1
A __construct() 0 3 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
declare(strict_types=1);
6
7
namespace Chamilo\CoreBundle\Repository;
8
9
use Chamilo\CoreBundle\Entity\ResourceLink;
10
use Doctrine\ORM\EntityManagerInterface;
11
use Gedmo\Sortable\Entity\Repository\SortableRepository;
12
13
class ResourceLinkRepository extends SortableRepository
14
{
15
    public function __construct(EntityManagerInterface $em)
16
    {
17
        parent::__construct($em, $em->getClassMetadata(ResourceLink::class));
18
    }
19
20
    public function remove(ResourceLink $resourceLink): void
21
    {
22
        $em = $this->getEntityManager();
23
24
        // To move the resource link at the end to reorder the list
25
        $resourceLink->setDisplayOrder(-1);
26
27
        $em->flush();
28
        $em->remove($resourceLink);
29
        $em->flush();
30
    }
31
}
32