Completed
Push — master ( 586166...fecb59 )
by Paweł
47:58
created

ProcessArticleRulesSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 35
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSubscribedEvents() 0 6 1
A processRules() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Content Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\ContentBundle\EventListener;
16
17
use SWP\Bundle\ContentBundle\ArticleEvents;
18
use SWP\Bundle\ContentBundle\Event\ArticleEvent;
19
use SWP\Component\Rule\Processor\RuleProcessorInterface;
20
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
21
22
class ProcessArticleRulesSubscriber implements EventSubscriberInterface
23
{
24
    /**
25
     * @var RuleProcessorInterface
26
     */
27
    private $ruleProcessor;
28
29
    /**
30
     * ProcessArticleRulesSubscriber constructor.
31
     *
32
     * @param RuleProcessorInterface $ruleProcessor
33
     */
34 11
    public function __construct(RuleProcessorInterface $ruleProcessor)
35
    {
36 11
        $this->ruleProcessor = $ruleProcessor;
37 11
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 98
    public static function getSubscribedEvents()
43
    {
44
        return [
45 98
            ArticleEvents::PRE_CREATE => 'processRules',
46
        ];
47
    }
48
49
    /**
50
     * @param ArticleEvent $event
51
     */
52 9
    public function processRules(ArticleEvent $event)
53
    {
54 9
        $this->ruleProcessor->process($event->getArticle());
55 9
    }
56
}
57