‪TYPO3CMS  9.5
DownloadUtility.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 
22 {
26  protected ‪$terUtility;
27 
31  protected ‪$repositoryHelper;
32 
36  protected ‪$downloadPath = 'Local';
37 
41  protected ‪$fileHandlingUtility;
42 
46  public function ‪injectTerUtility(\‪TYPO3\CMS\Extensionmanager\Utility\Connection\TerUtility ‪$terUtility)
47  {
48  $this->terUtility = ‪$terUtility;
49  }
50 
54  public function ‪injectRepositoryHelper(\‪TYPO3\CMS\Extensionmanager\Utility\Repository\Helper ‪$repositoryHelper)
55  {
56  $this->repositoryHelper = ‪$repositoryHelper;
57  }
58 
62  public function ‪injectFileHandlingUtility(\‪TYPO3\CMS\Extensionmanager\Utility\‪FileHandlingUtility ‪$fileHandlingUtility)
63  {
64  $this->fileHandlingUtility = ‪$fileHandlingUtility;
65  }
66 
72  public function ‪download(\‪TYPO3\CMS\Extensionmanager\Domain\Model\‪Extension $extension)
73  {
74  $mirrorUrl = $this->repositoryHelper->getMirrors()->getMirrorUrl();
75  $fetchedExtension = $this->terUtility->fetchExtension($extension->getExtensionKey(), $extension->getVersion(), $extension->getMd5hash(), $mirrorUrl);
76  if (isset($fetchedExtension['extKey']) && !empty($fetchedExtension['extKey']) && is_string($fetchedExtension['extKey'])) {
77  $this->fileHandlingUtility->unpackExtensionFromExtensionDataArray($fetchedExtension, $extension, $this->‪getDownloadPath());
78  }
79  }
80 
87  public function ‪setDownloadPath(‪$downloadPath)
88  {
89  if (!in_array(‪$downloadPath, \‪TYPO3\CMS\Extensionmanager\Domain\Model\‪Extension::returnAllowedInstallTypes())) {
90  throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException(‪$downloadPath . ' not in allowed download paths', 1344766387);
91  }
92  $this->downloadPath = ‪$downloadPath;
93  }
94 
100  public function ‪getDownloadPath()
101  {
102  return ‪$this->downloadPath;
103  }
104 }
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility\setDownloadPath
‪setDownloadPath($downloadPath)
Definition: DownloadUtility.php:83
‪TYPO3\CMS\Extensionmanager\Utility
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension
Definition: Extension.php:24
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility\getDownloadPath
‪string getDownloadPath()
Definition: DownloadUtility.php:96
‪TYPO3
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility\$fileHandlingUtility
‪TYPO3 CMS Extensionmanager Utility FileHandlingUtility $fileHandlingUtility
Definition: DownloadUtility.php:37
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility\$terUtility
‪TYPO3 CMS Extensionmanager Utility Connection TerUtility $terUtility
Definition: DownloadUtility.php:25
‪TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility
Definition: FileHandlingUtility.php:33
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility\$repositoryHelper
‪TYPO3 CMS Extensionmanager Utility Repository Helper $repositoryHelper
Definition: DownloadUtility.php:29
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility
Definition: DownloadUtility.php:22
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility\injectFileHandlingUtility
‪injectFileHandlingUtility(\TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility $fileHandlingUtility)
Definition: DownloadUtility.php:58
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility\download
‪download(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension)
Definition: DownloadUtility.php:68
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility\injectTerUtility
‪injectTerUtility(\TYPO3\CMS\Extensionmanager\Utility\Connection\TerUtility $terUtility)
Definition: DownloadUtility.php:42
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility\injectRepositoryHelper
‪injectRepositoryHelper(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper $repositoryHelper)
Definition: DownloadUtility.php:50
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\returnAllowedInstallTypes
‪static array returnAllowedInstallTypes()
Definition: Extension.php:467
‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility\$downloadPath
‪string $downloadPath
Definition: DownloadUtility.php:33