‪TYPO3CMS  10.4
DownloadQueue.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 
26 {
32  protected $extensionStorage = [];
33 
39  protected $extensionInstallStorage = [];
40 
46  protected $extensionCopyStorage = [];
47 
57  public function addExtensionToQueue(‪Extension $extension, $stack = 'download')
58  {
59  if (!is_string($stack) || !in_array($stack, ['download', 'update'])) {
60  throw new ‪ExtensionManagerException('Stack has to be either "download" or "update"', 1342432103);
61  }
62  if (!isset($this->‪extensionStorage[$stack])) {
63  $this->‪extensionStorage[$stack] = [];
64  }
65  if (array_key_exists($extension->‪getExtensionKey(), $this->extensionStorage[$stack])) {
66  if ($this->‪extensionStorage[$stack][$extension->‪getExtensionKey()] !== $extension) {
67  throw new ExtensionManagerException(
68  $extension->‪getExtensionKey() . ' was requested to be downloaded in different versions (' . $extension->‪getVersion()
69  . ' and ' . $this->extensionStorage[$stack][$extension->‪getExtensionKey()]->getVersion() . ').',
70  1342432101
71  );
72  }
73  }
74  $this->‪extensionStorage[$stack][$extension->‪getExtensionKey()] = $extension;
75  }
76 
80  public function ‪getExtensionQueue()
81  {
82  return $this->extensionStorage;
83  }
84 
92  public function ‪removeExtensionFromQueue(Extension $extension, $stack = 'download')
93  {
94  if (!is_string($stack) || !in_array($stack, ['download', 'update'])) {
95  throw new ExtensionManagerException('Stack has to be either "download" or "update"', 1342432104);
96  }
97  if (array_key_exists($stack, $this->‪extensionStorage) && is_array($this->‪extensionStorage[$stack])) {
98  if (array_key_exists($extension->getExtensionKey(), $this->extensionStorage[$stack])) {
99  unset($this->‪extensionStorage[$stack][$extension->getExtensionKey()]);
100  }
101  }
102  }
103 
109  public function ‪addExtensionToInstallQueue($extension)
110  {
111  $this->extensionInstallStorage[$extension->getExtensionKey()] = $extension;
112  }
113 
120  public function ‪addExtensionToCopyQueue($extensionKey, $sourceFolder)
121  {
122  $this->extensionCopyStorage[$extensionKey] = $sourceFolder;
123  }
124 
130  public function ‪removeExtensionFromCopyQueue($extensionKey)
131  {
132  if (array_key_exists($extensionKey, $this->extensionCopyStorage)) {
133  unset($this->extensionCopyStorage[$extensionKey]);
134  }
135  }
136 
142  public function ‪getExtensionInstallStorage()
143  {
144  return $this->extensionInstallStorage;
145  }
146 
153  public function ‪isQueueEmpty($stack = 'download')
154  {
155  return empty($this->‪extensionStorage[$stack]);
156  }
157 
163  public function ‪isCopyQueueEmpty()
164  {
165  return empty($this->extensionCopyStorage);
166  }
167 
174  public function ‪resetExtensionQueue($stack = null)
175  {
176  $storage = [];
177  if ($stack === null) {
178  $storage = $this->extensionStorage;
179  $this->‪extensionStorage = [];
180  } elseif (isset($this->‪extensionStorage[$stack])) {
181  $storage = $this->‪extensionStorage[$stack];
182  $this->‪extensionStorage[$stack] = [];
183  }
184 
185  return $storage;
186  }
187 
192  public function ‪resetExtensionCopyStorage()
193  {
194  $storage = $this->extensionCopyStorage;
195  $this->extensionCopyStorage = [];
196 
197  return $storage;
198  }
199 
204  public function ‪resetExtensionInstallStorage()
205  {
206  $storage = $this->extensionInstallStorage;
207  $this->extensionInstallStorage = [];
208 
209  return $storage;
210  }
211 }
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\resetExtensionCopyStorage
‪array resetExtensionCopyStorage()
Definition: DownloadQueue.php:189
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\addExtensionToCopyQueue
‪addExtensionToCopyQueue($extensionKey, $sourceFolder)
Definition: DownloadQueue.php:117
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\removeExtensionFromCopyQueue
‪removeExtensionFromCopyQueue($extensionKey)
Definition: DownloadQueue.php:127
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\resetExtensionInstallStorage
‪array resetExtensionInstallStorage()
Definition: DownloadQueue.php:201
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension
Definition: Extension.php:29
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue
Definition: DownloadQueue.php:26
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\addExtensionToInstallQueue
‪addExtensionToInstallQueue($extension)
Definition: DownloadQueue.php:106
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getVersion
‪string getVersion()
Definition: Extension.php:399
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getExtensionKey
‪string getExtensionKey()
Definition: Extension.php:270
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\extensionStorage
‪array< string, $extensionStorage=array();protected array $extensionInstallStorage=array();protected array $extensionCopyStorage=array();public function addExtensionToQueue(Extension $extension, $stack='download') { if(!is_string( $stack)||!in_array( $stack,[ 'download', 'update'])) { throw new ExtensionManagerException( 'Stack has to be either "download" or "update"', 1342432103);} if(!isset( $this->extensionStorage[ $stack])) { $this-> extensionStorage[$stack]
Definition: DownloadQueue.php:60
‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
Definition: ExtensionManagerException.php:24
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\getExtensionInstallStorage
‪array getExtensionInstallStorage()
Definition: DownloadQueue.php:139
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\getExtensionQueue
‪array getExtensionQueue()
Definition: DownloadQueue.php:77
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\isQueueEmpty
‪bool isQueueEmpty($stack='download')
Definition: DownloadQueue.php:150
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:23
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\resetExtensionQueue
‪array resetExtensionQueue($stack=null)
Definition: DownloadQueue.php:171
‪TYPO3\CMS\Extensionmanager\Domain\Model
Definition: Dependency.php:16
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\removeExtensionFromQueue
‪removeExtensionFromQueue(Extension $extension, $stack='download')
Definition: DownloadQueue.php:89
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\isCopyQueueEmpty
‪bool isCopyQueueEmpty()
Definition: DownloadQueue.php:160