‪TYPO3CMS  10.4
ItemProvider.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
27 {
31  protected ‪$itemsConfiguration = [
32  'exportT3d' => [
33  'type' => 'item',
34  'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang.xlf:export',
35  'iconIdentifier' => 'actions-document-export-t3d',
36  'callbackAction' => 'exportT3d'
37  ],
38  'importT3d' => [
39  'type' => 'item',
40  'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang.xlf:import',
41  'iconIdentifier' => 'actions-document-import-t3d',
42  'callbackAction' => 'importT3d',
43  ]
44  ];
45 
51  public function ‪canHandle(): bool
52  {
53  return $this->table !== 'sys_file' && strpos($this->table, '-drag') === false;
54  }
55 
61  public function ‪getPriority(): int
62  {
63  return 50;
64  }
65 
72  public function ‪addItems(array $items): array
73  {
74  $this->‪initDisabledItems();
75  $localItems = $this->‪prepareItems($this->itemsConfiguration);
76  if (isset($items['more']['childItems'])) {
77  $items['more']['childItems'] = $items['more']['childItems'] + $localItems;
78  } else {
79  $items += $localItems;
80  }
81  return $items;
82  }
83 
89  protected function ‪canRender(string $itemName, string $type): bool
90  {
91  if (in_array($itemName, $this->disabledItems, true)) {
92  return false;
93  }
94  $canRender = false;
95  switch ($itemName) {
96  case 'exportT3d':
97  $canRender = $this->backendUser->isExportEnabled();
98  break;
99  case 'importT3d':
100  $canRender = $this->table === 'pages' && $this->backendUser->isImportEnabled();
101  break;
102  }
103  return $canRender;
104  }
105 
112  protected function ‪getAdditionalAttributes(string $itemName): array
113  {
114  return ['data-callback-module' => 'TYPO3/CMS/Impexp/ContextMenuActions'];
115  }
116 }
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\getAdditionalAttributes
‪array getAdditionalAttributes(string $itemName)
Definition: ItemProvider.php:111
‪TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider\prepareItems
‪array prepareItems(array $itemsConfiguration)
Definition: AbstractProvider.php:171
‪TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider
Definition: AbstractProvider.php:31
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\canRender
‪bool canRender(string $itemName, string $type)
Definition: ItemProvider.php:88
‪TYPO3\CMS\Impexp\ContextMenu
Definition: ItemProvider.php:18
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider
Definition: ItemProvider.php:27
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\canHandle
‪bool canHandle()
Definition: ItemProvider.php:50
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\addItems
‪array addItems(array $items)
Definition: ItemProvider.php:71
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\getPriority
‪int getPriority()
Definition: ItemProvider.php:60
‪TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider\initDisabledItems
‪initDisabledItems()
Definition: AbstractProvider.php:142
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\$itemsConfiguration
‪array $itemsConfiguration
Definition: ItemProvider.php:30