‪TYPO3CMS  9.5
Extension.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 {
29 
35  protected static ‪$defaultCategories = [
36  0 => 'be',
37  1 => 'module',
38  2 => 'fe',
39  3 => 'plugin',
40  4 => 'misc',
41  5 => 'services',
42  6 => 'templates',
43  8 => 'doc',
44  9 => 'example',
45  self::DISTRIBUTION_CATEGORY => 'distribution'
46  ];
47 
53  protected static ‪$defaultStates = [
54  0 => 'alpha',
55  1 => 'beta',
56  2 => 'stable',
57  3 => 'experimental',
58  4 => 'test',
59  5 => 'obsolete',
60  6 => 'excludeFromUpdates',
61  7 => 'deprecated',
62  999 => 'n/a'
63  ];
64 
68  protected ‪$objectManager;
69 
73  protected ‪$extensionKey = '';
74 
78  protected ‪$version = '';
79 
83  protected ‪$integerVersion = 0;
84 
88  protected ‪$title = '';
89 
93  protected ‪$description = '';
94 
98  protected ‪$state = 0;
99 
103  protected ‪$category = 0;
104 
108  protected ‪$lastUpdated;
109 
113  protected ‪$updateComment = '';
114 
118  protected ‪$authorName = '';
119 
123  protected ‪$authorEmail = '';
124 
128  protected ‪$currentVersion = false;
129 
133  protected ‪$md5hash = '';
134 
138  protected ‪$reviewState;
139 
144 
148  protected ‪$serializedDependencies = '';
149 
153  protected ‪$dependencies;
154 
159  protected ‪$position = 0;
160 
164  public function ‪injectObjectManager(\‪TYPO3\CMS\‪Extbase\Object\ObjectManager ‪$objectManager)
165  {
166  $this->objectManager = ‪$objectManager;
167  }
168 
172  public function ‪setAuthorEmail(‪$authorEmail)
173  {
174  $this->authorEmail = ‪$authorEmail;
175  }
176 
180  public function ‪getAuthorEmail()
181  {
182  return ‪$this->authorEmail;
183  }
184 
188  public function ‪setAuthorName(‪$authorName)
189  {
190  $this->authorName = ‪$authorName;
191  }
192 
196  public function ‪getAuthorName()
197  {
198  return ‪$this->authorName;
199  }
200 
204  public function ‪setCategory(‪$category)
205  {
206  $this->category = ‪$category;
207  }
208 
212  public function ‪getCategory()
213  {
214  return ‪$this->category;
215  }
216 
222  public function ‪getCategoryString()
223  {
224  $categoryString = '';
225  if (isset(self::$defaultCategories[$this->‪getCategory()])) {
226  $categoryString = self::$defaultCategories[$this->‪getCategory()];
227  }
228  return $categoryString;
229  }
230 
239  {
240  $categoryIndex = 4;
241  if (\‪TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger(‪$category)) {
242  $categoryIndex = (int)‪$category;
243  if ($categoryIndex < 0 || $categoryIndex > 10) {
244  $categoryIndex = 4;
245  }
246  } elseif (is_string(‪$category)) {
247  $categoryIndex = array_search(‪$category, self::$defaultCategories);
248  if ($categoryIndex === false) {
249  $categoryIndex = 4;
250  }
251  }
252  return $categoryIndex;
253  }
254 
258  public function ‪setDescription(‪$description)
259  {
260  $this->description = ‪$description;
261  }
262 
266  public function ‪getDescription()
267  {
268  return ‪$this->description;
269  }
270 
274  public function ‪setExtensionKey(‪$extensionKey)
275  {
276  $this->extensionKey = ‪$extensionKey;
277  }
278 
282  public function ‪getExtensionKey()
283  {
284  return ‪$this->extensionKey;
285  }
286 
290  public function ‪setLastUpdated(\DateTime ‪$lastUpdated)
291  {
292  $this->lastUpdated = ‪$lastUpdated;
293  }
294 
298  public function ‪getLastUpdated()
299  {
300  return ‪$this->lastUpdated;
301  }
302 
306  public function ‪setState(‪$state)
307  {
308  $this->state = ‪$state;
309  }
310 
314  public function ‪getState()
315  {
316  return ‪$this->state;
317  }
318 
324  public function ‪getStateString()
325  {
326  $stateString = '';
327  if (isset(self::$defaultStates[$this->‪getState()])) {
328  $stateString = self::$defaultStates[$this->‪getState()];
329  }
330  return $stateString;
331  }
332 
340  public function ‪getDefaultState(‪$state = null)
341  {
342  $defaultState = '';
343  if (‪$state === null) {
344  $defaultState = ‪self::$defaultStates;
345  } else {
346  if (is_string(‪$state)) {
347  $stateIndex = array_search(strtolower(‪$state), self::$defaultStates);
348  if ($stateIndex === false) {
349  // default state
350  $stateIndex = 999;
351  }
352  $defaultState = $stateIndex;
353  } else {
354  if (is_int(‪$state) && ‪$state >= 0) {
355  if (array_key_exists(‪$state, self::$defaultStates)) {
356  $stateTitle = self::$defaultStates[‪$state];
357  } else {
358  // default state
359  $stateTitle = 'n/a';
360  }
361  $defaultState = $stateTitle;
362  }
363  }
364  }
365  return $defaultState;
366  }
367 
371  public function ‪setTitle(‪$title)
372  {
373  $this->title = ‪$title;
374  }
375 
379  public function ‪getTitle()
380  {
381  return ‪$this->title;
382  }
383 
387  public function ‪setUpdateComment(‪$updateComment)
388  {
389  $this->updateComment = ‪$updateComment;
390  }
391 
395  public function ‪getUpdateComment()
396  {
398  }
399 
403  public function ‪setVersion(‪$version)
404  {
405  $this->version = ‪$version;
406  }
407 
411  public function ‪getVersion()
412  {
413  return ‪$this->version;
414  }
415 
420  {
421  $this->currentVersion = ‪$currentVersion;
422  }
423 
427  public function ‪getCurrentVersion()
428  {
430  }
431 
435  public function ‪setMd5hash(‪$md5hash)
436  {
437  $this->md5hash = ‪$md5hash;
438  }
439 
443  public function ‪getMd5hash()
444  {
445  return ‪$this->md5hash;
446  }
447 
454  public static function ‪returnInstallPaths()
455  {
456  $installPaths = [
457  'System' => ‪Environment::getFrameworkBasePath() . '/',
458  'Global' => ‪Environment::getBackendPath() . '/ext/',
459  'Local' => ‪Environment::getExtensionsPath() . '/'
460  ];
461  return $installPaths;
462  }
463 
470  public static function ‪returnAllowedInstallPaths()
471  {
472  $installPaths = ‪self::returnInstallPaths();
473  if (empty(‪$GLOBALS['TYPO3_CONF_VARS']['EXT']['allowGlobalInstall'])) {
474  unset($installPaths['Global']);
475  }
476  if (empty(‪$GLOBALS['TYPO3_CONF_VARS']['EXT']['allowLocalInstall'])) {
477  unset($installPaths['Local']);
478  }
479  return $installPaths;
480  }
481 
488  public static function ‪returnAllowedInstallTypes()
489  {
490  $installPaths = ‪self::returnAllowedInstallPaths();
491  return array_keys($installPaths);
492  }
493 
498  {
499  $this->serializedDependencies = ‪$dependencies;
500  }
501 
505  public function ‪getSerializedDependencies()
506  {
508  }
509 
514  {
515  $this->dependencies = ‪$dependencies;
516  }
517 
521  public function ‪getDependencies()
522  {
523  if (!is_object($this->dependencies)) {
525  $extensionModelUtility = $this->objectManager->get(\‪TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility::class);
526  $this->‪setDependencies($extensionModelUtility->convertDependenciesToObjects($this->getSerializedDependencies()));
527  }
528  return ‪$this->dependencies;
529  }
530 
534  public function ‪addDependency(\‪TYPO3\CMS\Extensionmanager\Domain\Model\‪Dependency $dependency)
535  {
536  $this->dependencies->attach($dependency);
537  }
538 
543  {
544  $this->integerVersion = ‪$integerVersion;
545  }
546 
550  public function ‪getIntegerVersion()
551  {
553  }
554 
558  public function ‪setReviewState(‪$reviewState)
559  {
560  $this->reviewState = ‪$reviewState;
561  }
562 
566  public function ‪getReviewState()
567  {
568  return ‪$this->reviewState;
569  }
570 
574  public function ‪setPosition(‪$position)
575  {
576  $this->position = ‪$position;
577  }
578 
582  public function ‪getPosition()
583  {
584  return ‪$this->position;
585  }
586 
591  {
592  $this->alldownloadcounter = ‪$alldownloadcounter;
593  }
594 
598  public function ‪getAlldownloadcounter()
599  {
601  }
602 }
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getDependencies
‪SplObjectStorage getDependencies()
Definition: Extension.php:500
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setIntegerVersion
‪setIntegerVersion($integerVersion)
Definition: Extension.php:521
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\returnAllowedInstallPaths
‪static array returnAllowedInstallPaths()
Definition: Extension.php:449
‪TYPO3\CMS\Extensionmanager\Domain\Model\Dependency
Definition: Dependency.php:22
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$defaultCategories
‪static array $defaultCategories
Definition: Extension.php:34
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\addDependency
‪addDependency(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency)
Definition: Extension.php:513
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$position
‪int $position
Definition: Extension.php:138
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getPosition
‪int getPosition()
Definition: Extension.php:561
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getIntegerVersion
‪int getIntegerVersion()
Definition: Extension.php:529
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setVersion
‪setVersion($version)
Definition: Extension.php:382
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setDependencies
‪setDependencies($dependencies)
Definition: Extension.php:492
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getDescription
‪string getDescription()
Definition: Extension.php:245
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension
Definition: Extension.php:24
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$updateComment
‪string $updateComment
Definition: Extension.php:101
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$integerVersion
‪int $integerVersion
Definition: Extension.php:77
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\DISTRIBUTION_CATEGORY
‪const DISTRIBUTION_CATEGORY
Definition: Extension.php:28
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getState
‪int getState()
Definition: Extension.php:293
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getCurrentVersion
‪bool getCurrentVersion()
Definition: Extension.php:406
‪TYPO3
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$description
‪string $description
Definition: Extension.php:85
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getReviewState
‪int getReviewState()
Definition: Extension.php:545
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$lastUpdated
‪DateTime $lastUpdated
Definition: Extension.php:97
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setMd5hash
‪setMd5hash($md5hash)
Definition: Extension.php:414
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setAlldownloadcounter
‪setAlldownloadcounter($alldownloadcounter)
Definition: Extension.php:569
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\injectObjectManager
‪injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager)
Definition: Extension.php:143
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setCategory
‪setCategory($category)
Definition: Extension.php:183
‪TYPO3\CMS\Extbase\DomainObject\AbstractEntity
Definition: AbstractEntity.php:22
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$authorEmail
‪string $authorEmail
Definition: Extension.php:109
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setState
‪setState($state)
Definition: Extension.php:285
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$dependencies
‪SplObjectStorage<\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency > $dependencies
Definition: Extension.php:133
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setCurrentVersion
‪setCurrentVersion($currentVersion)
Definition: Extension.php:398
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getLastUpdated
‪DateTime getLastUpdated()
Definition: Extension.php:277
‪TYPO3\CMS\Core\Core\Environment\getFrameworkBasePath
‪static string getFrameworkBasePath()
Definition: Environment.php:234
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getCategory
‪int getCategory()
Definition: Extension.php:191
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getDefaultState
‪mixed getDefaultState($state=null)
Definition: Extension.php:319
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getCategoryIndexFromStringOrNumber
‪int getCategoryIndexFromStringOrNumber($category)
Definition: Extension.php:217
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setTitle
‪setTitle($title)
Definition: Extension.php:350
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getMd5hash
‪string getMd5hash()
Definition: Extension.php:422
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$category
‪int $category
Definition: Extension.php:93
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setDescription
‪setDescription($description)
Definition: Extension.php:237
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$defaultStates
‪static array $defaultStates
Definition: Extension.php:51
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$state
‪int $state
Definition: Extension.php:89
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$reviewState
‪int $reviewState
Definition: Extension.php:121
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$objectManager
‪TYPO3 CMS Extbase Object ObjectManager $objectManager
Definition: Extension.php:65
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getUpdateComment
‪string getUpdateComment()
Definition: Extension.php:374
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getVersion
‪string getVersion()
Definition: Extension.php:390
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getExtensionKey
‪string getExtensionKey()
Definition: Extension.php:261
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$version
‪string $version
Definition: Extension.php:73
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$currentVersion
‪bool $currentVersion
Definition: Extension.php:113
‪TYPO3\CMS\Core\Core\Environment\getBackendPath
‪static string getBackendPath()
Definition: Environment.php:223
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$alldownloadcounter
‪int $alldownloadcounter
Definition: Extension.php:125
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$title
‪string $title
Definition: Extension.php:81
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$serializedDependencies
‪string $serializedDependencies
Definition: Extension.php:129
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setUpdateComment
‪setUpdateComment($updateComment)
Definition: Extension.php:366
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setLastUpdated
‪setLastUpdated(\DateTime $lastUpdated)
Definition: Extension.php:269
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getAuthorName
‪string getAuthorName()
Definition: Extension.php:175
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$extensionKey
‪string $extensionKey
Definition: Extension.php:69
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getAuthorEmail
‪string getAuthorEmail()
Definition: Extension.php:159
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getSerializedDependencies
‪string getSerializedDependencies()
Definition: Extension.php:484
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setReviewState
‪setReviewState($reviewState)
Definition: Extension.php:537
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setPosition
‪setPosition($position)
Definition: Extension.php:553
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getTitle
‪string getTitle()
Definition: Extension.php:358
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Extensionmanager\Domain\Model
Definition: Dependency.php:2
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setSerializedDependencies
‪setSerializedDependencies($dependencies)
Definition: Extension.php:476
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getAlldownloadcounter
‪int getAlldownloadcounter()
Definition: Extension.php:577
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setAuthorEmail
‪setAuthorEmail($authorEmail)
Definition: Extension.php:151
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getStateString
‪string getStateString()
Definition: Extension.php:303
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setAuthorName
‪setAuthorName($authorName)
Definition: Extension.php:167
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setExtensionKey
‪setExtensionKey($extensionKey)
Definition: Extension.php:253
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$md5hash
‪string $md5hash
Definition: Extension.php:117
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\returnInstallPaths
‪static array returnInstallPaths()
Definition: Extension.php:433
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$authorName
‪string $authorName
Definition: Extension.php:105
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\returnAllowedInstallTypes
‪static array returnAllowedInstallTypes()
Definition: Extension.php:467
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getCategoryString
‪string getCategoryString()
Definition: Extension.php:201
‪TYPO3\CMS\Core\Core\Environment\getExtensionsPath
‪static string getExtensionsPath()
Definition: Environment.php:245