Passed
Push — master ( d88203...94a809 )
by Julito
07:42
created

CForumForumRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CourseBundle\Repository;
6
7
use Chamilo\CoreBundle\Entity\AbstractResource;
8
use Chamilo\CoreBundle\Repository\ResourceRepository;
9
use Chamilo\CourseBundle\Entity\CForumForum;
10
use Doctrine\Persistence\ManagerRegistry;
11
12
final class CForumForumRepository extends ResourceRepository
13
{
14
    public function __construct(ManagerRegistry $registry)
15
    {
16
        parent::__construct($registry, CForumForum::class);
17
    }
18
19
    public function delete(AbstractResource $resource)
20
    {
21
        /** @var CForumForum $resource */
22
        $threads = $resource->getThreads();
23
        if (!empty($threads)) {
24
            foreach ($threads as $thread) {
25
                parent::delete($thread);
26
            }
27
        }
28
29
        parent::delete($resource);
30
    }
31
}
32