Completed
Push — master ( 120557...b81336 )
by Craig
04:55
created

AbstractExtensionMenu::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
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\MenuModule\ExtensionMenu;
15
16
use Knp\Menu\FactoryInterface;
17
use Knp\Menu\ItemInterface;
18
use Zikula\PermissionsModule\Api\ApiInterface\PermissionApiInterface;
19
20
abstract class AbstractExtensionMenu implements ExtensionMenuInterface
21
{
22
    /**
23
     * @var FactoryInterface
24
     */
25
    protected $factory;
26
27
    /**
28
     * @var PermissionApiInterface
29
     */
30
    protected $permissionApi;
31
32
    public function __construct(
33
        FactoryInterface $factory,
34
        PermissionApiInterface $permissionApi
35
    ) {
36
        $this->factory = $factory;
37
        $this->permissionApi = $permissionApi;
38
    }
39
40
    public function get(string $type = self::TYPE_ADMIN): ?ItemInterface
41
    {
42
        if (self::TYPE_ADMIN === $type) {
43
            return $this->getAdmin();
44
        }
45
46
        return null;
47
    }
48
49
    abstract protected function getAdmin(): ?ItemInterface;
50
}
51