‪TYPO3CMS  11.5
ImmediateActionElement.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 
28 {
29  public const ‪MODULE_NAME = 'TYPO3/CMS/Backend/Storage/ModuleStateStorage';
30 
31  protected string ‪$action;
32  protected ?array ‪$args = null;
33 
34  public static function ‪forAction(string ‪$action): self
35  {
36  return new self(‪$action, null);
37  }
38 
39  public static function ‪moduleStateUpdate(string $module, $identifier, bool $select = null): self
40  {
41  return new self(
42  'TYPO3.Backend.Storage.ModuleStateStorage.update',
43  [$module, $identifier, $select]
44  );
45  }
46 
47  public static function ‪moduleStateUpdateWithCurrentMount(string $module, $identifier, bool $select = null): self
48  {
49  return new self(
50  'TYPO3.Backend.Storage.ModuleStateStorage.updateWithCurrentMount',
51  [$module, $identifier, $select]
52  );
53  }
54 
55  public static function ‪dispatchCustomEvent(string $name, array $details = null, bool $useTop = false): self
56  {
57  return new self(
58  'TYPO3.Backend.Event.EventDispatcher.dispatchCustomEvent',
59  [$name, $details, $useTop]
60  );
61  }
62 
63  private function ‪__construct(string ‪$action, ?array ‪$args)
64  {
65  $this->action = ‪$action;
66  $this->args = ‪$args;
67  }
68 
69  public function ‪__toString(): string
70  {
71  $attributes = ['action' => ‪$this->action];
72  if ($this->args !== null) {
73  $attributes['args'] = GeneralUtility::jsonEncodeForHtmlAttribute($this->args);
74  }
75  return sprintf(
76  '<typo3-immediate-action %s></typo3-immediate-action>',
77  GeneralUtility::implodeAttributes($attributes, true)
78  );
79  }
80 }
‪TYPO3\CMS\Backend\Domain\Model\Element\ImmediateActionElement\__construct
‪__construct(string $action, ?array $args)
Definition: ImmediateActionElement.php:63
‪TYPO3\CMS\Backend\Domain\Model\Element\ImmediateActionElement\moduleStateUpdateWithCurrentMount
‪static moduleStateUpdateWithCurrentMount(string $module, $identifier, bool $select=null)
Definition: ImmediateActionElement.php:47
‪TYPO3\CMS\Backend\Domain\Model\Element\ImmediateActionElement\moduleStateUpdate
‪static moduleStateUpdate(string $module, $identifier, bool $select=null)
Definition: ImmediateActionElement.php:39
‪TYPO3\CMS\Backend\Domain\Model\Element\ImmediateActionElement\dispatchCustomEvent
‪static dispatchCustomEvent(string $name, array $details=null, bool $useTop=false)
Definition: ImmediateActionElement.php:55
‪TYPO3\CMS\Backend\Domain\Model\Element\ImmediateActionElement\MODULE_NAME
‪const MODULE_NAME
Definition: ImmediateActionElement.php:29
‪TYPO3\CMS\Backend\Domain\Model\Element\ImmediateActionElement\$args
‪array $args
Definition: ImmediateActionElement.php:32
‪TYPO3\CMS\Backend\Domain\Model\Element\ImmediateActionElement\__toString
‪__toString()
Definition: ImmediateActionElement.php:69
‪TYPO3\CMS\Backend\Domain\Model\Element\ImmediateActionElement\forAction
‪static forAction(string $action)
Definition: ImmediateActionElement.php:34
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Backend\Domain\Model\Element
Definition: ImmediateActionElement.php:18
‪TYPO3\CMS\Backend\Domain\Model\Element\ImmediateActionElement
Definition: ImmediateActionElement.php:28
‪TYPO3\CMS\Backend\Domain\Model\Element\ImmediateActionElement\$action
‪string $action
Definition: ImmediateActionElement.php:31