first commit
This commit is contained in:
commit
1218dd1517
12716 files changed
+989233
No files matched your search
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Extensionmanager\Domain\Model;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* Main extension model
|
||||
* @internal This class is a specific domain model implementation and is not part of the Public TYPO3 API.
|
||||
*/
|
||||
class Dependency extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $identifier = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $lowestVersion = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $highestVersion = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $dependencyTypes = [
|
||||
'depends',
|
||||
'conflicts',
|
||||
'suggests'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $specialDependencies = [
|
||||
'typo3',
|
||||
'php'
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $highestVersion
|
||||
*/
|
||||
public function setHighestVersion($highestVersion)
|
||||
{
|
||||
$this->highestVersion = $highestVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHighestVersion()
|
||||
{
|
||||
return $this->highestVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $identifier
|
||||
*/
|
||||
public function setIdentifier($identifier)
|
||||
{
|
||||
$this->identifier = $identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $lowestVersion
|
||||
*/
|
||||
public function setLowestVersion($lowestVersion)
|
||||
{
|
||||
$this->lowestVersion = $lowestVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLowestVersion()
|
||||
{
|
||||
return $this->lowestVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException if no valid dependency type was given
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
if (in_array($type, self::$dependencyTypes)) {
|
||||
$this->type = $type;
|
||||
} else {
|
||||
throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException($type . ' was not a valid dependency type.', 1476122402);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Extensionmanager\Domain\Model;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
|
||||
|
||||
/**
|
||||
* Download Queue - storage for extensions to be downloaded
|
||||
* @internal This class is a specific domain model implementation and is not part of the Public TYPO3 API.
|
||||
*/
|
||||
class DownloadQueue implements \TYPO3\CMS\Core\SingletonInterface
|
||||
{
|
||||
/**
|
||||
* Storage for extensions to be downloaded
|
||||
*
|
||||
* @var Extension[string][string]
|
||||
*/
|
||||
protected $extensionStorage = [];
|
||||
|
||||
/**
|
||||
* Storage for extensions to be installed
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $extensionInstallStorage = [];
|
||||
|
||||
/**
|
||||
* Storage for extensions to be copied
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $extensionCopyStorage = [];
|
||||
|
||||
/**
|
||||
* @var \TYPO3\CMS\Extensionmanager\Utility\ListUtility
|
||||
*/
|
||||
protected $listUtility;
|
||||
|
||||
/**
|
||||
* @param \TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility
|
||||
*/
|
||||
public function injectListUtility(\TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility)
|
||||
{
|
||||
$this->listUtility = $listUtility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an extension to the download queue.
|
||||
* If the extension was already requested in a different version
|
||||
* an exception is thrown.
|
||||
*
|
||||
* @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
|
||||
* @param string $stack
|
||||
* @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
|
||||
*/
|
||||
public function addExtensionToQueue(\TYPO3\CMS\Extensionmanager\Domain\Model\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] = [];
|
||||
}
|
||||
if (array_key_exists($extension->getExtensionKey(), $this->extensionStorage[$stack])) {
|
||||
if ($this->extensionStorage[$stack][$extension->getExtensionKey()] !== $extension) {
|
||||
throw new ExtensionManagerException(
|
||||
$extension->getExtensionKey() . ' was requested to be downloaded in different versions (' . $extension->getVersion()
|
||||
. ' and ' . $this->extensionStorage[$stack][$extension->getExtensionKey()]->getVersion() . ').',
|
||||
1342432101
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->extensionStorage[$stack][$extension->getExtensionKey()] = $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getExtensionQueue()
|
||||
{
|
||||
return $this->extensionStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an extension from download queue
|
||||
*
|
||||
* @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
|
||||
* @param string $stack Stack to remove extension from (download, update or install)
|
||||
* @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
|
||||
*/
|
||||
public function removeExtensionFromQueue(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension, $stack = 'download')
|
||||
{
|
||||
if (!is_string($stack) || !in_array($stack, ['download', 'update'])) {
|
||||
throw new ExtensionManagerException('Stack has to be either "download" or "update"', 1342432104);
|
||||
}
|
||||
if (array_key_exists($stack, $this->extensionStorage) && is_array($this->extensionStorage[$stack])) {
|
||||
if (array_key_exists($extension->getExtensionKey(), $this->extensionStorage[$stack])) {
|
||||
unset($this->extensionStorage[$stack][$extension->getExtensionKey()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an extension to the install queue for later installation
|
||||
*
|
||||
* @param Extension $extension
|
||||
*/
|
||||
public function addExtensionToInstallQueue($extension)
|
||||
{
|
||||
$this->extensionInstallStorage[$extension->getExtensionKey()] = $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an extension from the install queue
|
||||
*
|
||||
* @param string $extensionKey
|
||||
*/
|
||||
public function removeExtensionFromInstallQueue($extensionKey)
|
||||
{
|
||||
if (array_key_exists($extensionKey, $this->extensionInstallStorage)) {
|
||||
unset($this->extensionInstallStorage[$extensionKey]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an extension to the copy queue for later copying
|
||||
*
|
||||
* @param string $extensionKey
|
||||
* @param string $sourceFolder
|
||||
*/
|
||||
public function addExtensionToCopyQueue($extensionKey, $sourceFolder)
|
||||
{
|
||||
$this->extensionCopyStorage[$extensionKey] = $sourceFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an extension from extension copy storage
|
||||
*
|
||||
* @param $extensionKey
|
||||
*/
|
||||
public function removeExtensionFromCopyQueue($extensionKey)
|
||||
{
|
||||
if (array_key_exists($extensionKey, $this->extensionCopyStorage)) {
|
||||
unset($this->extensionCopyStorage[$extensionKey]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extension installation queue
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtensionInstallStorage()
|
||||
{
|
||||
return $this->extensionInstallStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extension copy queue
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtensionCopyStorage()
|
||||
{
|
||||
return $this->extensionCopyStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the queue contains extensions or not
|
||||
*
|
||||
* @param string $stack
|
||||
* @return bool
|
||||
*/
|
||||
public function isQueueEmpty($stack = 'download')
|
||||
{
|
||||
return empty($this->extensionStorage[$stack]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the copy queue contains extensions or not
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCopyQueueEmpty()
|
||||
{
|
||||
return empty($this->extensionCopyStorage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the install queue contains extensions or not
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInstallQueueEmpty()
|
||||
{
|
||||
return empty($this->extensionInstallStorage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the extension queue and returns old extensions
|
||||
*
|
||||
* @param string|null $stack if null, all stacks are reset
|
||||
* @return array
|
||||
*/
|
||||
public function resetExtensionQueue($stack = null)
|
||||
{
|
||||
$storage = [];
|
||||
if ($stack === null) {
|
||||
$storage = $this->extensionStorage;
|
||||
$this->extensionStorage = [];
|
||||
} elseif (isset($this->extensionStorage[$stack])) {
|
||||
$storage = $this->extensionStorage[$stack];
|
||||
$this->extensionStorage[$stack] = [];
|
||||
}
|
||||
|
||||
return $storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the copy queue and returns the old extensions
|
||||
* @return array
|
||||
*/
|
||||
public function resetExtensionCopyStorage()
|
||||
{
|
||||
$storage = $this->extensionCopyStorage;
|
||||
$this->extensionCopyStorage = [];
|
||||
|
||||
return $storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the install queue and returns the old extensions
|
||||
* @return array
|
||||
*/
|
||||
public function resetExtensionInstallStorage()
|
||||
{
|
||||
$storage = $this->extensionInstallStorage;
|
||||
$this->extensionInstallStorage = [];
|
||||
|
||||
return $storage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,602 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Extensionmanager\Domain\Model;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Core\Environment;
|
||||
|
||||
/**
|
||||
* Main extension model
|
||||
* @internal This class is a specific domain model implementation and is not part of the Public TYPO3 API.
|
||||
*/
|
||||
class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
||||
{
|
||||
/**
|
||||
* Category index for distributions
|
||||
*/
|
||||
const DISTRIBUTION_CATEGORY = 10;
|
||||
|
||||
/**
|
||||
* Contains default categories.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $defaultCategories = [
|
||||
0 => 'be',
|
||||
1 => 'module',
|
||||
2 => 'fe',
|
||||
3 => 'plugin',
|
||||
4 => 'misc',
|
||||
5 => 'services',
|
||||
6 => 'templates',
|
||||
8 => 'doc',
|
||||
9 => 'example',
|
||||
self::DISTRIBUTION_CATEGORY => 'distribution'
|
||||
];
|
||||
|
||||
/**
|
||||
* Contains default states.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $defaultStates = [
|
||||
0 => 'alpha',
|
||||
1 => 'beta',
|
||||
2 => 'stable',
|
||||
3 => 'experimental',
|
||||
4 => 'test',
|
||||
5 => 'obsolete',
|
||||
6 => 'excludeFromUpdates',
|
||||
7 => 'deprecated',
|
||||
999 => 'n/a'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $extensionKey = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $version = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $integerVersion = 0;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $title = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $state = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $category = 0;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $lastUpdated;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $updateComment = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $authorName = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $authorEmail = '';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $currentVersion = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $md5hash = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $reviewState;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $alldownloadcounter;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $serializedDependencies = '';
|
||||
|
||||
/**
|
||||
* @var \SplObjectStorage<\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency>
|
||||
*/
|
||||
protected $dependencies;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @var int
|
||||
*/
|
||||
protected $position = 0;
|
||||
|
||||
/**
|
||||
* @param \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager
|
||||
*/
|
||||
public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager)
|
||||
{
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $authorEmail
|
||||
*/
|
||||
public function setAuthorEmail($authorEmail)
|
||||
{
|
||||
$this->authorEmail = $authorEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthorEmail()
|
||||
{
|
||||
return $this->authorEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $authorName
|
||||
*/
|
||||
public function setAuthorName($authorName)
|
||||
{
|
||||
$this->authorName = $authorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthorName()
|
||||
{
|
||||
return $this->authorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $category
|
||||
*/
|
||||
public function setCategory($category)
|
||||
{
|
||||
$this->category = $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategoryString()
|
||||
{
|
||||
$categoryString = '';
|
||||
if (isset(self::$defaultCategories[$this->getCategory()])) {
|
||||
$categoryString = self::$defaultCategories[$this->getCategory()];
|
||||
}
|
||||
return $categoryString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns category index from a given string or an integer.
|
||||
* Fallback to 4 - 'misc' in case string is not found or integer ist out of range.
|
||||
*
|
||||
* @param string|int $category Category string or integer
|
||||
* @return int Valid category index
|
||||
*/
|
||||
public function getCategoryIndexFromStringOrNumber($category)
|
||||
{
|
||||
$categoryIndex = 4;
|
||||
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($category)) {
|
||||
$categoryIndex = (int)$category;
|
||||
if ($categoryIndex < 0 || $categoryIndex > 10) {
|
||||
$categoryIndex = 4;
|
||||
}
|
||||
} elseif (is_string($category)) {
|
||||
$categoryIndex = array_search($category, self::$defaultCategories);
|
||||
if ($categoryIndex === false) {
|
||||
$categoryIndex = 4;
|
||||
}
|
||||
}
|
||||
return $categoryIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $extensionKey
|
||||
*/
|
||||
public function setExtensionKey($extensionKey)
|
||||
{
|
||||
$this->extensionKey = $extensionKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExtensionKey()
|
||||
{
|
||||
return $this->extensionKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $lastUpdated
|
||||
*/
|
||||
public function setLastUpdated(\DateTime $lastUpdated)
|
||||
{
|
||||
$this->lastUpdated = $lastUpdated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getLastUpdated()
|
||||
{
|
||||
return $this->lastUpdated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $state
|
||||
*/
|
||||
public function setState($state)
|
||||
{
|
||||
$this->state = $state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get State string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStateString()
|
||||
{
|
||||
$stateString = '';
|
||||
if (isset(self::$defaultStates[$this->getState()])) {
|
||||
$stateString = self::$defaultStates[$this->getState()];
|
||||
}
|
||||
return $stateString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns either array with all default states or index/title
|
||||
* of a state entry.
|
||||
*
|
||||
* @param mixed $state state title or state index
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefaultState($state = null)
|
||||
{
|
||||
$defaultState = '';
|
||||
if ($state === null) {
|
||||
$defaultState = self::$defaultStates;
|
||||
} else {
|
||||
if (is_string($state)) {
|
||||
$stateIndex = array_search(strtolower($state), self::$defaultStates);
|
||||
if ($stateIndex === false) {
|
||||
// default state
|
||||
$stateIndex = 999;
|
||||
}
|
||||
$defaultState = $stateIndex;
|
||||
} else {
|
||||
if (is_int($state) && $state >= 0) {
|
||||
if (array_key_exists($state, self::$defaultStates)) {
|
||||
$stateTitle = self::$defaultStates[$state];
|
||||
} else {
|
||||
// default state
|
||||
$stateTitle = 'n/a';
|
||||
}
|
||||
$defaultState = $stateTitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $defaultState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $updateComment
|
||||
*/
|
||||
public function setUpdateComment($updateComment)
|
||||
{
|
||||
$this->updateComment = $updateComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUpdateComment()
|
||||
{
|
||||
return $this->updateComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $version
|
||||
*/
|
||||
public function setVersion($version)
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $currentVersion
|
||||
*/
|
||||
public function setCurrentVersion($currentVersion)
|
||||
{
|
||||
$this->currentVersion = $currentVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getCurrentVersion()
|
||||
{
|
||||
return $this->currentVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $md5hash
|
||||
*/
|
||||
public function setMd5hash($md5hash)
|
||||
{
|
||||
$this->md5hash = $md5hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMd5hash()
|
||||
{
|
||||
return $this->md5hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible install paths
|
||||
*
|
||||
* @static
|
||||
* @return array
|
||||
*/
|
||||
public static function returnInstallPaths()
|
||||
{
|
||||
$installPaths = [
|
||||
'System' => Environment::getFrameworkBasePath() . '/',
|
||||
'Global' => Environment::getBackendPath() . '/ext/',
|
||||
'Local' => Environment::getExtensionsPath() . '/'
|
||||
];
|
||||
return $installPaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowed install paths
|
||||
*
|
||||
* @static
|
||||
* @return array
|
||||
*/
|
||||
public static function returnAllowedInstallPaths()
|
||||
{
|
||||
$installPaths = self::returnInstallPaths();
|
||||
if (empty($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowGlobalInstall'])) {
|
||||
unset($installPaths['Global']);
|
||||
}
|
||||
if (empty($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowLocalInstall'])) {
|
||||
unset($installPaths['Local']);
|
||||
}
|
||||
return $installPaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowed install names: System, Global, Local
|
||||
*
|
||||
* @static
|
||||
* @return array
|
||||
*/
|
||||
public static function returnAllowedInstallTypes()
|
||||
{
|
||||
$installPaths = self::returnAllowedInstallPaths();
|
||||
return array_keys($installPaths);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dependencies
|
||||
*/
|
||||
public function setSerializedDependencies($dependencies)
|
||||
{
|
||||
$this->serializedDependencies = $dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSerializedDependencies()
|
||||
{
|
||||
return $this->serializedDependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \SplObjectStorage $dependencies
|
||||
*/
|
||||
public function setDependencies($dependencies)
|
||||
{
|
||||
$this->dependencies = $dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \SplObjectStorage
|
||||
*/
|
||||
public function getDependencies()
|
||||
{
|
||||
if (!is_object($this->dependencies)) {
|
||||
/** @var \TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility $extensionModelUtility */
|
||||
$extensionModelUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility::class);
|
||||
$this->setDependencies($extensionModelUtility->convertDependenciesToObjects($this->getSerializedDependencies()));
|
||||
}
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency
|
||||
*/
|
||||
public function addDependency(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency)
|
||||
{
|
||||
$this->dependencies->attach($dependency);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $integerVersion
|
||||
*/
|
||||
public function setIntegerVersion($integerVersion)
|
||||
{
|
||||
$this->integerVersion = $integerVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIntegerVersion()
|
||||
{
|
||||
return $this->integerVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $reviewState
|
||||
*/
|
||||
public function setReviewState($reviewState)
|
||||
{
|
||||
$this->reviewState = $reviewState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getReviewState()
|
||||
{
|
||||
return $this->reviewState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $position
|
||||
*/
|
||||
public function setPosition($position)
|
||||
{
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPosition()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $alldownloadcounter
|
||||
*/
|
||||
public function setAlldownloadcounter($alldownloadcounter)
|
||||
{
|
||||
$this->alldownloadcounter = $alldownloadcounter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAlldownloadcounter()
|
||||
{
|
||||
return $this->alldownloadcounter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Extensionmanager\Domain\Model;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* Repository mirrors object for extension manager.
|
||||
* @internal This class is a specific domain model implementation and is not part of the Public TYPO3 API.
|
||||
*/
|
||||
class Mirrors extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
||||
{
|
||||
/**
|
||||
* Keeps mirrors.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $mirrors = [];
|
||||
|
||||
/**
|
||||
* Keeps currently select mirror.
|
||||
*
|
||||
* Is array index.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $currentMirror;
|
||||
|
||||
/**
|
||||
* Keeps information if a mirror should
|
||||
* be randomly selected.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isRandomSelection = true;
|
||||
|
||||
/**
|
||||
* Method selects one specific mirror to be used.
|
||||
*
|
||||
* @param int $mirrorId number (>=1) of mirror or NULL for random selection
|
||||
* @see $currentMirror
|
||||
*/
|
||||
public function setSelect($mirrorId = null)
|
||||
{
|
||||
if ($mirrorId === null) {
|
||||
$this->isRandomSelection = true;
|
||||
} else {
|
||||
if (is_int($mirrorId) && $mirrorId >= 1 && $mirrorId <= count($this->mirrors)) {
|
||||
$this->currentMirror = $mirrorId - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns one mirror for use.
|
||||
*
|
||||
* Mirror has previously been selected or is chosen
|
||||
* randomly.
|
||||
*
|
||||
* @return array array of a mirror's properties or NULL in case of errors
|
||||
*/
|
||||
public function getMirror()
|
||||
{
|
||||
$sumMirrors = count($this->mirrors);
|
||||
if ($sumMirrors > 0) {
|
||||
if (!is_int($this->currentMirror)) {
|
||||
$this->currentMirror = rand(0, $sumMirrors - 1);
|
||||
}
|
||||
return $this->mirrors[$this->currentMirror];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mirror url from selected mirror
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMirrorUrl()
|
||||
{
|
||||
$mirror = $this->getMirror();
|
||||
$mirrorUrl = $mirror['host'] . $mirror['path'];
|
||||
return 'https://' . $mirrorUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns all available mirrors.
|
||||
*
|
||||
* @return array multidimensional array with mirrors and their properties
|
||||
* @see $mirrors, setMirrors()
|
||||
*/
|
||||
public function getMirrors()
|
||||
{
|
||||
return $this->mirrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method sets available mirrors.
|
||||
*
|
||||
* @param array $mirrors multidimensional array with mirrors and their properties
|
||||
* @see $mirrors, getMirrors()
|
||||
*/
|
||||
public function setMirrors(array $mirrors)
|
||||
{
|
||||
if (count($mirrors) >= 1) {
|
||||
$this->mirrors = $mirrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Extensionmanager\Domain\Model;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* Repository object for extension manager.
|
||||
* @internal This class is a specific domain model implementation and is not part of the Public TYPO3 API.
|
||||
*/
|
||||
class Repository extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
||||
{
|
||||
/**
|
||||
* Keeps repository title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* Keeps repository description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* Keeps mirror list URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $mirrorListUrl;
|
||||
|
||||
/**
|
||||
* Keeps repository mirrors object.
|
||||
*
|
||||
* @var \TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors
|
||||
*/
|
||||
protected $mirrors;
|
||||
|
||||
/**
|
||||
* Keeps wsdl URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $wsdlUrl;
|
||||
|
||||
/**
|
||||
* Keeps last update.
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $lastUpdate;
|
||||
|
||||
/**
|
||||
* Keeps extension count.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $extensionCount;
|
||||
|
||||
/**
|
||||
* Method returns title of a repository.
|
||||
*
|
||||
* @return string title of repository
|
||||
* @see $title, setTitle()
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method sets title of a repository.
|
||||
*
|
||||
* @param string $title title of repository to set
|
||||
* @see $title, getTitle()
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
if (!empty($title) && is_string($title)) {
|
||||
$this->title = $title;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns description of a repository.
|
||||
*
|
||||
* @return string title of repository
|
||||
* @see $title, setTitle()
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method sets description of a repository.
|
||||
*
|
||||
* @param string $description title of repository to set
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
if (!empty($description) && is_string($description)) {
|
||||
$this->description = $description;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns URL of a resource that contains repository mirrors.
|
||||
*
|
||||
* @return string URL of file that contains repository mirrors
|
||||
* @see $mirrorListUrl, getMirrorListUrl()
|
||||
*/
|
||||
public function getMirrorListUrl()
|
||||
{
|
||||
return $this->mirrorListUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method sets URL of a resource that contains repository mirrors.
|
||||
*
|
||||
* Parameter is typically a remote gzipped xml file.
|
||||
*
|
||||
* @param string $url URL of file that contains repository mirrors
|
||||
* @see $mirrorListUrl, getMirrorListUrl()
|
||||
*/
|
||||
public function setMirrorListUrl($url)
|
||||
{
|
||||
if (empty($url) || !empty($url) && \TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($url)) {
|
||||
$this->mirrorListUrl = $url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns URL of repository WSDL.
|
||||
*
|
||||
* @return string URL of repository WSDL
|
||||
* @see $wsdlUrl, setWsdlUrl()
|
||||
*/
|
||||
public function getWsdlUrl()
|
||||
{
|
||||
return $this->wsdlUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method sets URL of repository WSDL.
|
||||
*
|
||||
* @param string $url URL of repository WSDL
|
||||
* @see $wsdlUrl, getWsdlUrl()
|
||||
*/
|
||||
public function setWsdlUrl($url)
|
||||
{
|
||||
if (!empty($url) && \TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($url)) {
|
||||
$this->wsdlUrl = $url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns LastUpdate.
|
||||
*
|
||||
* @return \DateTime timestamp of last update
|
||||
*/
|
||||
public function getLastUpdate()
|
||||
{
|
||||
return $this->lastUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method sets LastUpdate.
|
||||
*
|
||||
* @param \DateTime $time URL of repository WSDL
|
||||
*/
|
||||
public function setLastUpdate(\DateTime $time)
|
||||
{
|
||||
$this->lastUpdate = $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns extension count
|
||||
*
|
||||
* @return int count of read extensions
|
||||
*/
|
||||
public function getExtensionCount()
|
||||
{
|
||||
return $this->extensionCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method sets extension count
|
||||
*
|
||||
* @param string $count count of read extensions
|
||||
*/
|
||||
public function setExtensionCount($count)
|
||||
{
|
||||
$this->extensionCount = $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method registers repository mirrors object.
|
||||
*
|
||||
* Repository mirrors object is passed by reference.
|
||||
*
|
||||
* @param \TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors $mirrors mirror list
|
||||
* @see $mirrors, getMirrors(), hasMirrors(), removeMirrors()
|
||||
*/
|
||||
public function addMirrors(\TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors $mirrors)
|
||||
{
|
||||
$this->mirrors = $mirrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns information if a repository mirrors
|
||||
* object has been registered to this repository.
|
||||
*
|
||||
* @return bool TRUE, if a repository mirrors object has been registered, otherwise FALSE
|
||||
* @see $mirrors, addMirrors(), getMirrors(), removeMirrors()
|
||||
*/
|
||||
public function hasMirrors()
|
||||
{
|
||||
$hasMirrors = false;
|
||||
if (is_object($this->mirrors)) {
|
||||
$hasMirrors = true;
|
||||
}
|
||||
return $hasMirrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns a repository mirrors object.
|
||||
*
|
||||
* @return \TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors mirrors for repository
|
||||
* @see $mirrors, addMirrors(), hasMirrors(), removeMirrors()
|
||||
*/
|
||||
public function getMirrors()
|
||||
{
|
||||
return $this->hasMirrors() ? $this->mirrors : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method unregisters a repository mirrors object.
|
||||
*
|
||||
* @see $mirrors, addMirrors(), getMirrors(), hasMirrors()
|
||||
*/
|
||||
public function removeMirrors()
|
||||
{
|
||||
unset($this->mirrors);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user