‪TYPO3CMS  10.4
Extension.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 
23 
29 {
34 
40  protected static ‪$defaultCategories = [
41  0 => 'be',
42  1 => 'module',
43  2 => 'fe',
44  3 => 'plugin',
45  4 => 'misc',
46  5 => 'services',
47  6 => 'templates',
48  8 => 'doc',
49  9 => 'example',
50  self::DISTRIBUTION_CATEGORY => 'distribution'
51  ];
52 
58  protected static ‪$defaultStates = [
59  0 => 'alpha',
60  1 => 'beta',
61  2 => 'stable',
62  3 => 'experimental',
63  4 => 'test',
64  5 => 'obsolete',
65  6 => 'excludeFromUpdates',
66  7 => 'deprecated',
67  999 => 'n/a'
68  ];
69 
73  protected ‪$objectManager;
74 
78  protected ‪$extensionKey = '';
79 
83  protected ‪$version = '';
84 
88  protected ‪$integerVersion = 0;
89 
93  protected ‪$title = '';
94 
98  protected ‪$description = '';
99 
103  protected ‪$state = 0;
104 
108  protected ‪$category = 0;
109 
113  protected ‪$lastUpdated;
114 
118  protected ‪$updateComment = '';
119 
123  protected ‪$authorName = '';
124 
128  protected ‪$authorEmail = '';
129 
133  protected ‪$currentVersion = false;
134 
138  protected ‪$md5hash = '';
139 
143  protected ‪$reviewState;
144 
148  protected ‪$alldownloadcounter;
149 
153  protected ‪$serializedDependencies = '';
154 
158  protected ‪$dependencies;
159 
163  protected ‪$documentationLink = '';
164 
169  protected ‪$position = 0;
170 
175  {
176  $this->objectManager = ‪$objectManager;
177  }
178 
182  public function ‪setAuthorEmail(‪$authorEmail)
183  {
184  $this->authorEmail = ‪$authorEmail;
185  }
186 
190  public function ‪getAuthorEmail()
191  {
193  }
194 
198  public function ‪setAuthorName(‪$authorName)
199  {
200  $this->authorName = ‪$authorName;
201  }
202 
206  public function ‪getAuthorName()
207  {
208  return ‪$this->authorName;
209  }
210 
214  public function ‪setCategory(‪$category)
215  {
216  $this->category = ‪$category;
217  }
218 
222  public function ‪getCategory()
223  {
224  return ‪$this->category;
225  }
226 
232  public function ‪getCategoryString()
233  {
234  $categoryString = '';
235  if (isset(self::$defaultCategories[$this->‪getCategory()])) {
236  $categoryString = self::$defaultCategories[$this->‪getCategory()];
237  }
238  return $categoryString;
239  }
240 
249  {
250  $categoryIndex = 4;
252  $categoryIndex = (int)‪$category;
253  if ($categoryIndex < 0 || $categoryIndex > 10) {
254  $categoryIndex = 4;
255  }
256  } elseif (is_string(‪$category)) {
257  $categoryIndex = array_search(‪$category, self::$defaultCategories);
258  if ($categoryIndex === false) {
259  $categoryIndex = 4;
260  }
261  }
262  return $categoryIndex;
263  }
264 
268  public function ‪setDescription(‪$description)
269  {
270  $this->description = ‪$description;
271  }
272 
276  public function ‪getDescription()
277  {
279  }
280 
284  public function ‪setExtensionKey(‪$extensionKey)
285  {
286  $this->extensionKey = ‪$extensionKey;
287  }
288 
292  public function ‪getExtensionKey()
293  {
295  }
296 
300  public function ‪setLastUpdated(\DateTime ‪$lastUpdated)
301  {
302  $this->lastUpdated = ‪$lastUpdated;
303  }
304 
308  public function ‪getLastUpdated()
309  {
310  return ‪$this->lastUpdated;
311  }
312 
316  public function ‪setState(‪$state)
317  {
318  $this->state = ‪$state;
319  }
320 
324  public function ‪getState()
325  {
326  return ‪$this->state;
327  }
328 
334  public function ‪getStateString()
335  {
336  $stateString = '';
337  if (isset(self::$defaultStates[$this->‪getState()])) {
338  $stateString = self::$defaultStates[$this->‪getState()];
339  }
340  return $stateString;
341  }
342 
350  public function ‪getDefaultState(‪$state = null)
351  {
352  $defaultState = '';
353  if (‪$state === null) {
354  $defaultState = ‪self::$defaultStates;
355  } else {
356  if (is_string(‪$state)) {
357  $stateIndex = array_search(strtolower(‪$state), self::$defaultStates);
358  if ($stateIndex === false) {
359  // default state
360  $stateIndex = 999;
361  }
362  $defaultState = $stateIndex;
363  } else {
364  if (is_int(‪$state) && ‪$state >= 0) {
365  if (array_key_exists(‪$state, self::$defaultStates)) {
366  $stateTitle = self::$defaultStates[‪$state];
367  } else {
368  // default state
369  $stateTitle = 'n/a';
370  }
371  $defaultState = $stateTitle;
372  }
373  }
374  }
375  return $defaultState;
376  }
377 
381  public function ‪setTitle(‪$title)
382  {
383  $this->title = ‪$title;
384  }
385 
389  public function ‪getTitle()
390  {
392  }
393 
397  public function ‪setUpdateComment(‪$updateComment)
398  {
399  $this->updateComment = ‪$updateComment;
400  }
401 
405  public function ‪getUpdateComment()
406  {
408  }
409 
413  public function ‪setVersion(‪$version)
414  {
415  $this->version = ‪$version;
416  }
417 
421  public function ‪getVersion()
422  {
424  }
425 
430  {
431  $this->currentVersion = ‪$currentVersion;
432  }
433 
437  public function ‪getCurrentVersion()
438  {
440  }
441 
445  public function ‪setMd5hash(‪$md5hash)
446  {
447  $this->md5hash = ‪$md5hash;
448  }
449 
453  public function ‪getMd5hash()
454  {
455  return ‪$this->md5hash;
456  }
457 
464  public static function ‪returnInstallPaths()
465  {
466  $installPaths = [
467  'System' => ‪Environment::getFrameworkBasePath() . '/',
468  'Global' => ‪Environment::getBackendPath() . '/ext/',
469  'Local' => ‪Environment::getExtensionsPath() . '/'
470  ];
471  return $installPaths;
472  }
473 
480  public static function ‪returnAllowedInstallPaths()
481  {
482  $installPaths = ‪self::returnInstallPaths();
483  if (empty(‪$GLOBALS['TYPO3_CONF_VARS']['EXT']['allowGlobalInstall'])) {
484  unset($installPaths['Global']);
485  }
486  if (empty(‪$GLOBALS['TYPO3_CONF_VARS']['EXT']['allowLocalInstall'])) {
487  unset($installPaths['Local']);
488  }
489  return $installPaths;
490  }
491 
498  public static function ‪returnAllowedInstallTypes()
499  {
500  $installPaths = ‪self::returnAllowedInstallPaths();
501  return array_keys($installPaths);
502  }
503 
508  {
509  $this->serializedDependencies = ‪$dependencies;
510  }
511 
515  public function ‪getSerializedDependencies()
516  {
518  }
519 
523  public function ‪setDependencies(‪$dependencies)
524  {
525  $this->dependencies = ‪$dependencies;
526  }
527 
531  public function ‪getDependencies()
532  {
533  if (!is_object($this->dependencies)) {
534  $extensionModelUtility = $this->objectManager->get(ExtensionModelUtility::class);
535  $this->‪setDependencies($extensionModelUtility->convertDependenciesToObjects($this->getSerializedDependencies()));
536  }
538  }
539 
543  public function ‪addDependency(‪Dependency $dependency)
544  {
545  $this->dependencies->attach($dependency);
546  }
547 
552  {
553  $this->integerVersion = ‪$integerVersion;
554  }
555 
559  public function ‪getIntegerVersion()
560  {
562  }
563 
567  public function ‪setReviewState(‪$reviewState)
568  {
569  $this->reviewState = ‪$reviewState;
570  }
571 
575  public function ‪getReviewState()
576  {
578  }
579 
583  public function ‪setPosition(‪$position)
584  {
585  $this->position = ‪$position;
586  }
587 
591  public function ‪getPosition()
592  {
594  }
595 
600  {
601  $this->alldownloadcounter = ‪$alldownloadcounter;
602  }
603 
607  public function ‪getAlldownloadcounter()
608  {
610  }
611 
615  public function ‪getDocumentationLink(): string
616  {
618  }
619 
623  public function ‪setDocumentationLink(string ‪$documentationLink): void
624  {
625  $this->documentationLink = ‪$documentationLink;
626  }
627 }
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getDependencies
‪SplObjectStorage getDependencies()
Definition: Extension.php:509
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setIntegerVersion
‪setIntegerVersion($integerVersion)
Definition: Extension.php:529
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\returnAllowedInstallPaths
‪static array returnAllowedInstallPaths()
Definition: Extension.php:458
‪TYPO3\CMS\Extensionmanager\Domain\Model\Dependency
Definition: Dependency.php:26
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$defaultCategories
‪static array $defaultCategories
Definition: Extension.php:39
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$position
‪int $position
Definition: Extension.php:147
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getPosition
‪int getPosition()
Definition: Extension.php:569
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger($var)
Definition: MathUtility.php:74
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getIntegerVersion
‪int getIntegerVersion()
Definition: Extension.php:537
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setVersion
‪setVersion($version)
Definition: Extension.php:391
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setDependencies
‪setDependencies($dependencies)
Definition: Extension.php:501
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getDescription
‪string getDescription()
Definition: Extension.php:254
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension
Definition: Extension.php:29
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$updateComment
‪string $updateComment
Definition: Extension.php:106
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$integerVersion
‪int $integerVersion
Definition: Extension.php:82
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\DISTRIBUTION_CATEGORY
‪const DISTRIBUTION_CATEGORY
Definition: Extension.php:33
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getState
‪int getState()
Definition: Extension.php:302
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getCurrentVersion
‪bool getCurrentVersion()
Definition: Extension.php:415
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$description
‪string $description
Definition: Extension.php:90
‪TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility
Definition: ExtensionModelUtility.php:28
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$documentationLink
‪string $documentationLink
Definition: Extension.php:142
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getReviewState
‪int getReviewState()
Definition: Extension.php:553
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$lastUpdated
‪DateTime $lastUpdated
Definition: Extension.php:102
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$objectManager
‪ObjectManager $objectManager
Definition: Extension.php:70
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setMd5hash
‪setMd5hash($md5hash)
Definition: Extension.php:423
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setAlldownloadcounter
‪setAlldownloadcounter($alldownloadcounter)
Definition: Extension.php:577
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setCategory
‪setCategory($category)
Definition: Extension.php:192
‪TYPO3\CMS\Extbase\DomainObject\AbstractEntity
Definition: AbstractEntity.php:23
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$authorEmail
‪string $authorEmail
Definition: Extension.php:114
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setState
‪setState($state)
Definition: Extension.php:294
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$dependencies
‪SplObjectStorage<\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency > $dependencies
Definition: Extension.php:138
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setCurrentVersion
‪setCurrentVersion($currentVersion)
Definition: Extension.php:407
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getLastUpdated
‪DateTime getLastUpdated()
Definition: Extension.php:286
‪TYPO3\CMS\Core\Core\Environment\getFrameworkBasePath
‪static string getFrameworkBasePath()
Definition: Environment.php:261
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getCategory
‪int getCategory()
Definition: Extension.php:200
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getDefaultState
‪mixed getDefaultState($state=null)
Definition: Extension.php:328
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getCategoryIndexFromStringOrNumber
‪int getCategoryIndexFromStringOrNumber($category)
Definition: Extension.php:226
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setTitle
‪setTitle($title)
Definition: Extension.php:359
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getMd5hash
‪string getMd5hash()
Definition: Extension.php:431
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$category
‪int $category
Definition: Extension.php:98
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setDescription
‪setDescription($description)
Definition: Extension.php:246
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$defaultStates
‪static array $defaultStates
Definition: Extension.php:56
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$state
‪int $state
Definition: Extension.php:94
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$reviewState
‪int $reviewState
Definition: Extension.php:126
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getUpdateComment
‪string getUpdateComment()
Definition: Extension.php:383
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getDocumentationLink
‪string getDocumentationLink()
Definition: Extension.php:593
‪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\Extension\$version
‪string $version
Definition: Extension.php:78
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$currentVersion
‪bool $currentVersion
Definition: Extension.php:118
‪TYPO3\CMS\Core\Core\Environment\getBackendPath
‪static string getBackendPath()
Definition: Environment.php:250
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$alldownloadcounter
‪int $alldownloadcounter
Definition: Extension.php:130
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$title
‪string $title
Definition: Extension.php:86
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$serializedDependencies
‪string $serializedDependencies
Definition: Extension.php:134
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setUpdateComment
‪setUpdateComment($updateComment)
Definition: Extension.php:375
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setLastUpdated
‪setLastUpdated(\DateTime $lastUpdated)
Definition: Extension.php:278
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getAuthorName
‪string getAuthorName()
Definition: Extension.php:184
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$extensionKey
‪string $extensionKey
Definition: Extension.php:74
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\addDependency
‪addDependency(Dependency $dependency)
Definition: Extension.php:521
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\injectObjectManager
‪injectObjectManager(ObjectManager $objectManager)
Definition: Extension.php:152
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getAuthorEmail
‪string getAuthorEmail()
Definition: Extension.php:168
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getSerializedDependencies
‪string getSerializedDependencies()
Definition: Extension.php:493
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setReviewState
‪setReviewState($reviewState)
Definition: Extension.php:545
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setDocumentationLink
‪setDocumentationLink(string $documentationLink)
Definition: Extension.php:601
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setPosition
‪setPosition($position)
Definition: Extension.php:561
‪$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:367
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Extensionmanager\Domain\Model
Definition: Dependency.php:16
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setSerializedDependencies
‪setSerializedDependencies($dependencies)
Definition: Extension.php:485
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:22
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getAlldownloadcounter
‪int getAlldownloadcounter()
Definition: Extension.php:585
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setAuthorEmail
‪setAuthorEmail($authorEmail)
Definition: Extension.php:160
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getStateString
‪string getStateString()
Definition: Extension.php:312
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setAuthorName
‪setAuthorName($authorName)
Definition: Extension.php:176
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setExtensionKey
‪setExtensionKey($extensionKey)
Definition: Extension.php:262
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$md5hash
‪string $md5hash
Definition: Extension.php:122
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\returnInstallPaths
‪static array returnInstallPaths()
Definition: Extension.php:442
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:28
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\$authorName
‪string $authorName
Definition: Extension.php:110
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\returnAllowedInstallTypes
‪static array returnAllowedInstallTypes()
Definition: Extension.php:476
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\getCategoryString
‪string getCategoryString()
Definition: Extension.php:210
‪TYPO3\CMS\Core\Core\Environment\getExtensionsPath
‪static string getExtensionsPath()
Definition: Environment.php:271