‪TYPO3CMS  ‪main
ModifyRecordListTableActionsEvent.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 {
32  private string ‪$noActionLabel = '';
33 
37  public function ‪__construct(
38  private array $actions,
39  private readonly string $table,
40  private readonly array $recordIds,
41  private readonly ‪DatabaseRecordList $recordList
42  ) {}
43 
51  public function ‪setAction(string $action, string $actionName = '', string $before = '', string $after = ''): void
52  {
53  if ($actionName !== '') {
54  if ($before !== '' && $this->‪hasAction($before)) {
55  $end = array_splice($this->actions, (int)(array_search($before, array_keys($this->actions), true)));
56  $this->actions = array_merge($this->actions, [$actionName => $action], $end);
57  } elseif ($after !== '' && $this->‪hasAction($after)) {
58  $end = array_splice($this->actions, (int)(array_search($after, array_keys($this->actions), true)) + 1);
59  $this->actions = array_merge($this->actions, [$actionName => $action], $end);
60  } else {
61  $this->actions[$actionName] = $action;
62  }
63  } else {
64  $this->actions[] = $action;
65  }
66  }
67 
71  public function ‪hasAction(string $actionName): bool
72  {
73  return (bool)($this->actions[$actionName] ?? false);
74  }
75 
81  public function ‪getAction(string $actionName): ?string
82  {
83  return $this->actions[$actionName] ?? null;
84  }
85 
92  public function ‪removeAction(string $actionName): bool
93  {
94  if (!isset($this->actions[$actionName])) {
95  return false;
96  }
97  unset($this->actions[$actionName]);
98  return true;
99  }
100 
101  public function ‪setActions(array $actions): void
102  {
103  $this->actions = $actions;
104  }
105 
106  public function ‪getActions(): array
107  {
108  return $this->actions;
109  }
110 
111  public function ‪setNoActionLabel(string ‪$noActionLabel): void
112  {
113  $this->noActionLabel = ‪$noActionLabel;
114  }
115 
123  public function ‪getNoActionLabel(): string
124  {
126  }
127 
128  public function ‪getTable(): string
129  {
130  return $this->table;
131  }
132 
133  public function ‪getRecordIds(): array
134  {
135  return $this->recordIds;
136  }
137 
144  {
145  return $this->recordList;
146  }
147 }
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\getRecordList
‪getRecordList()
Definition: ModifyRecordListTableActionsEvent.php:143
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\setNoActionLabel
‪setNoActionLabel(string $noActionLabel)
Definition: ModifyRecordListTableActionsEvent.php:111
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\getRecordIds
‪getRecordIds()
Definition: ModifyRecordListTableActionsEvent.php:133
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\$noActionLabel
‪string $noActionLabel
Definition: ModifyRecordListTableActionsEvent.php:32
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\getActions
‪getActions()
Definition: ModifyRecordListTableActionsEvent.php:106
‪TYPO3\CMS\Backend\RecordList\DatabaseRecordList
Definition: DatabaseRecordList.php:68
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\getAction
‪string null getAction(string $actionName)
Definition: ModifyRecordListTableActionsEvent.php:81
‪TYPO3\CMS\Backend\RecordList\Event
Definition: ModifyRecordListHeaderColumnsEvent.php:18
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\getTable
‪getTable()
Definition: ModifyRecordListTableActionsEvent.php:128
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\hasAction
‪hasAction(string $actionName)
Definition: ModifyRecordListTableActionsEvent.php:71
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\setActions
‪setActions(array $actions)
Definition: ModifyRecordListTableActionsEvent.php:101
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\removeAction
‪bool removeAction(string $actionName)
Definition: ModifyRecordListTableActionsEvent.php:92
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent
Definition: ModifyRecordListTableActionsEvent.php:27
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\__construct
‪__construct(private array $actions, private readonly string $table, private readonly array $recordIds, private readonly DatabaseRecordList $recordList)
Definition: ModifyRecordListTableActionsEvent.php:37
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\setAction
‪setAction(string $action, string $actionName='', string $before='', string $after='')
Definition: ModifyRecordListTableActionsEvent.php:51
‪TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListTableActionsEvent\getNoActionLabel
‪getNoActionLabel()
Definition: ModifyRecordListTableActionsEvent.php:123