Passed
Pull Request — master (#6127)
by Angel Fernando Quiroz
08:24
created

H5pImportEventSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 4 1
A onCreateCourse() 0 5 2
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
declare(strict_types=1);
6
7
use Chamilo\CoreBundle\HookEvent\CourseCreatedHookEvent;
8
use Chamilo\CoreBundle\HookEvent\HookEvent;
9
use Chamilo\CoreBundle\HookEvent\HookEvents;
10
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
11
12
class H5pImportEventSubscriber implements EventSubscriberInterface
13
{
14
    public static function getSubscribedEvents(): array
15
    {
16
        return [
17
            HookEvents::COURSE_CREATED => 'onCreateCourse',
18
        ];
19
    }
20
21
    public function onCreateCourse(CourseCreatedHookEvent $event): void
22
    {
23
        if (HookEvent::TYPE_POST === $event->getType()) {
24
            H5pImportPlugin::create()
25
                ->addCourseTool($event->getCourseInfo()['id'])
26
            ;
27
        }
28
    }
29
}
30