‪TYPO3CMS  9.5
DownloadQueue.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
24 {
30  protected ‪$extensionStorage = [];
31 
37  protected ‪$extensionInstallStorage = [];
38 
44  protected ‪$extensionCopyStorage = [];
45 
49  protected ‪$listUtility;
50 
54  public function ‪injectListUtility(\‪TYPO3\CMS\Extensionmanager\Utility\ListUtility ‪$listUtility)
55  {
56  $this->listUtility = ‪$listUtility;
57  }
58 
68  public function ‪addExtensionToQueue(\‪TYPO3\CMS\Extensionmanager\Domain\Model\‪Extension $extension, $stack = 'download')
69  {
70  if (!is_string($stack) || !in_array($stack, ['download', 'update'])) {
71  throw new ‪ExtensionManagerException('Stack has to be either "download" or "update"', 1342432103);
72  }
73  if (!isset($this->extensionStorage[$stack])) {
74  $this->extensionStorage[$stack] = [];
75  }
76  if (array_key_exists($extension->getExtensionKey(), $this->extensionStorage[$stack])) {
77  if ($this->extensionStorage[$stack][$extension->getExtensionKey()] !== $extension) {
78  throw new ExtensionManagerException(
79  $extension->getExtensionKey() . ' was requested to be downloaded in different versions (' . $extension->getVersion()
80  . ' and ' . $this->extensionStorage[$stack][$extension->getExtensionKey()]->getVersion() . ').',
81  1342432101
82  );
83  }
84  }
85  $this->extensionStorage[$stack][$extension->getExtensionKey()] = $extension;
86  }
87 
91  public function ‪getExtensionQueue()
92  {
94  }
95 
103  public function ‪removeExtensionFromQueue(\‪TYPO3\CMS\Extensionmanager\Domain\Model\‪Extension $extension, $stack = 'download')
104  {
105  if (!is_string($stack) || !in_array($stack, ['download', 'update'])) {
106  throw new ‪ExtensionManagerException('Stack has to be either "download" or "update"', 1342432104);
107  }
108  if (array_key_exists($stack, $this->extensionStorage) && is_array($this->extensionStorage[$stack])) {
109  if (array_key_exists($extension->getExtensionKey(), $this->extensionStorage[$stack])) {
110  unset($this->extensionStorage[$stack][$extension->getExtensionKey()]);
111  }
112  }
113  }
114 
120  public function ‪addExtensionToInstallQueue($extension)
121  {
122  $this->extensionInstallStorage[$extension->getExtensionKey()] = $extension;
123  }
124 
130  public function ‪removeExtensionFromInstallQueue($extensionKey)
131  {
132  if (array_key_exists($extensionKey, $this->extensionInstallStorage)) {
133  unset($this->extensionInstallStorage[$extensionKey]);
134  }
135  }
136 
143  public function ‪addExtensionToCopyQueue($extensionKey, $sourceFolder)
144  {
145  $this->extensionCopyStorage[$extensionKey] = $sourceFolder;
146  }
147 
153  public function ‪removeExtensionFromCopyQueue($extensionKey)
154  {
155  if (array_key_exists($extensionKey, $this->extensionCopyStorage)) {
156  unset($this->extensionCopyStorage[$extensionKey]);
157  }
158  }
159 
165  public function ‪getExtensionInstallStorage()
166  {
168  }
169 
175  public function ‪getExtensionCopyStorage()
176  {
178  }
179 
186  public function ‪isQueueEmpty($stack = 'download')
187  {
188  return empty($this->extensionStorage[$stack]);
189  }
190 
196  public function ‪isCopyQueueEmpty()
197  {
198  return empty($this->extensionCopyStorage);
199  }
200 
206  public function ‪isInstallQueueEmpty()
207  {
208  return empty($this->extensionInstallStorage);
209  }
210 
217  public function ‪resetExtensionQueue($stack = null)
218  {
219  $storage = [];
220  if ($stack === null) {
221  $storage = ‪$this->extensionStorage;
222  $this->extensionStorage = [];
223  } elseif (isset($this->extensionStorage[$stack])) {
224  $storage = $this->extensionStorage[$stack];
225  $this->extensionStorage[$stack] = [];
226  }
227 
228  return $storage;
229  }
230 
235  public function ‪resetExtensionCopyStorage()
236  {
238  $this->extensionCopyStorage = [];
239 
240  return $storage;
241  }
242 
247  public function ‪resetExtensionInstallStorage()
248  {
250  $this->extensionInstallStorage = [];
251 
252  return $storage;
253  }
254 }
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\addExtensionToQueue
‪addExtensionToQueue(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension, $stack='download')
Definition: DownloadQueue.php:64
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\resetExtensionCopyStorage
‪array resetExtensionCopyStorage()
Definition: DownloadQueue.php:231
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\addExtensionToCopyQueue
‪addExtensionToCopyQueue($extensionKey, $sourceFolder)
Definition: DownloadQueue.php:139
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\removeExtensionFromCopyQueue
‪removeExtensionFromCopyQueue($extensionKey)
Definition: DownloadQueue.php:149
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\injectListUtility
‪injectListUtility(\TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility)
Definition: DownloadQueue.php:50
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\resetExtensionInstallStorage
‪array resetExtensionInstallStorage()
Definition: DownloadQueue.php:243
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension
Definition: Extension.php:24
‪TYPO3
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue
Definition: DownloadQueue.php:24
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\addExtensionToInstallQueue
‪addExtensionToInstallQueue($extension)
Definition: DownloadQueue.php:116
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\$extensionCopyStorage
‪array $extensionCopyStorage
Definition: DownloadQueue.php:41
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\isInstallQueueEmpty
‪bool isInstallQueueEmpty()
Definition: DownloadQueue.php:202
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\$extensionStorage
‪Extension[string][string] $extensionStorage
Definition: DownloadQueue.php:29
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\$extensionInstallStorage
‪array $extensionInstallStorage
Definition: DownloadQueue.php:35
‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
Definition: ExtensionManagerException.php:23
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\removeExtensionFromQueue
‪removeExtensionFromQueue(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension, $stack='download')
Definition: DownloadQueue.php:99
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\getExtensionInstallStorage
‪array getExtensionInstallStorage()
Definition: DownloadQueue.php:161
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\getExtensionCopyStorage
‪array getExtensionCopyStorage()
Definition: DownloadQueue.php:171
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\getExtensionQueue
‪array getExtensionQueue()
Definition: DownloadQueue.php:87
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\$listUtility
‪TYPO3 CMS Extensionmanager Utility ListUtility $listUtility
Definition: DownloadQueue.php:45
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\isQueueEmpty
‪bool isQueueEmpty($stack='download')
Definition: DownloadQueue.php:182
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\resetExtensionQueue
‪array resetExtensionQueue($stack=null)
Definition: DownloadQueue.php:213
‪TYPO3\CMS\Extensionmanager\Domain\Model
Definition: Dependency.php:2
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\removeExtensionFromInstallQueue
‪removeExtensionFromInstallQueue($extensionKey)
Definition: DownloadQueue.php:126
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue\isCopyQueueEmpty
‪bool isCopyQueueEmpty()
Definition: DownloadQueue.php:192