Completed
Push — DomainModel ( fc9939...030411 )
by Tomas Norre
02:52
created

ItemProvider::getAdditionalAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace AOE\Crawler\ContextMenu;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2017 AOE GmbH <[email protected]>
8
 *
9
 *  All rights reserved
10
 *
11
 *  This script is part of the TYPO3 project. The TYPO3 project is
12
 *  free software; you can redistribute it and/or modify
13
 *  it under the terms of the GNU General Public License as published by
14
 *  the Free Software Foundation; either version 3 of the License, or
15
 *  (at your option) any later version.
16
 *
17
 *  The GNU General Public License can be found at
18
 *  http://www.gnu.org/copyleft/gpl.html.
19
 *
20
 *  This script is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU General Public License for more details.
24
 *
25
 *  This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27
28
use TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider;
29
30
/**
31
 * Class ItemProvider
32
 *
33
 * @package AOE\Crawler\Context
34
 */
35
class ItemProvider extends AbstractProvider
36
{
37
38
    protected $itemsConfiguration = [
39
        'crawler' => [
40
            'type' => 'item',
41
            'label' => 'Add page to crawler queue', //todo: use label
42
            'iconIdentifier' => 'tx-crawler-ext-icon',
43
            'callbackAction' => 'crawlerAddPageToQueue'
44
        ],
45
46
    ];
47
48
    public function addItems(array $items): array
49
    {
50
        $this->initDisabledItems();
51
        $localItems = $this->prepareItems($this->itemsConfiguration);
52
        if (isset($items['more']['childItems'])) {
53
            $items['more']['childItems'] = $items['more']['childItems'] + $localItems;
54
        } else {
55
            $items += $localItems;
56
        }
57
        return $items;
58
    }
59
60
    public function getPriority(): int
61
    {
62
        return 70;
63
    }
64
65
    public function canHandle(): bool
66
    {
67
        return true;
68
    }
69
70
    protected function getAdditionalAttributes(string $itemName): array
71
    {
72
        return ['data-callback-module' => '\AOE\Crawler\ContextMenuActions'];
73
    }
74
}