Completed
Push — master ( bd5259...2bdac6 )
by Axel
05:47
created

PendingContentBlock::setRouter()   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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Zikula\BlocksModule\Block;
15
16
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
17
use Zikula\BlocksModule\AbstractBlockHandler;
18
use Zikula\BlocksModule\Event\PendingContentEvent;
19
20
class PendingContentBlock extends AbstractBlockHandler
21
{
22
    /**
23
     * @var EventDispatcherInterface
24
     */
25
    private $eventDispatcher;
26
27
    public function display(array $properties): string
28
    {
29
        if (!$this->hasPermission('PendingContent::', $properties['title'] . '::', ACCESS_OVERVIEW)) {
30
            return '';
31
        }
32
        $pendingCollection = $this->eventDispatcher->dispatch(new PendingContentEvent('pending_content'))->getContainer();
33
34
        return $this->renderView('@ZikulaBlocksModule/Block/pendingcontent.html.twig', [
35
            'pendingCollection' => $pendingCollection
36
        ]);
37
    }
38
39
    public function getType(): string
40
    {
41
        return $this->trans('Pending Content');
42
    }
43
44
    /**
45
     * @required
46
     */
47
    public function setEventDispatcher(EventDispatcherInterface $eventDispatcher): void
48
    {
49
        $this->eventDispatcher = $eventDispatcher;
50
    }
51
}
52