TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
extensionmanager/Classes/Domain/Model/Extension.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Domain\Model;
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 
21 {
26 
32  protected static $defaultCategories = [
33  0 => 'be',
34  1 => 'module',
35  2 => 'fe',
36  3 => 'plugin',
37  4 => 'misc',
38  5 => 'services',
39  6 => 'templates',
40  8 => 'doc',
41  9 => 'example',
42  self::DISTRIBUTION_CATEGORY => 'distribution'
43  ];
44 
50  protected static $defaultStates = [
51  0 => 'alpha',
52  1 => 'beta',
53  2 => 'stable',
54  3 => 'experimental',
55  4 => 'test',
56  5 => 'obsolete',
57  6 => 'excludeFromUpdates',
58  999 => 'n/a'
59  ];
60 
64  protected $objectManager;
65 
69  protected $extensionKey = '';
70 
74  protected $version = '';
75 
79  protected $integerVersion = 0;
80 
84  protected $title = '';
85 
89  protected $description = '';
90 
94  protected $state = 0;
95 
99  protected $category = 0;
100 
104  protected $lastUpdated;
105 
109  protected $updateComment = '';
110 
114  protected $authorName = '';
115 
119  protected $authorEmail = '';
120 
124  protected $currentVersion = false;
125 
129  protected $md5hash = '';
130 
134  protected $reviewState;
135 
140 
144  protected $serializedDependencies = '';
145 
149  protected $dependencies = null;
150 
155  protected $position = 0;
156 
160  public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager)
161  {
162  $this->objectManager = $objectManager;
163  }
164 
169  public function setAuthorEmail($authorEmail)
170  {
171  $this->authorEmail = $authorEmail;
172  }
173 
177  public function getAuthorEmail()
178  {
179  return $this->authorEmail;
180  }
181 
186  public function setAuthorName($authorName)
187  {
188  $this->authorName = $authorName;
189  }
190 
194  public function getAuthorName()
195  {
196  return $this->authorName;
197  }
198 
203  public function setCategory($category)
204  {
205  $this->category = $category;
206  }
207 
211  public function getCategory()
212  {
213  return $this->category;
214  }
215 
221  public function getCategoryString()
222  {
223  $categoryString = '';
224  if (isset(self::$defaultCategories[$this->getCategory()])) {
225  $categoryString = self::$defaultCategories[$this->getCategory()];
226  }
227  return $categoryString;
228  }
229 
238  {
239  $categoryIndex = 4;
240  if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($category)) {
241  $categoryIndex = (int)$category;
242  if ($categoryIndex < 0 || $categoryIndex > 10) {
243  $categoryIndex = 4;
244  }
245  } elseif (is_string($category)) {
246  $categoryIndex = array_search($category, self::$defaultCategories);
247  if ($categoryIndex === false) {
248  $categoryIndex = 4;
249  }
250  }
251  return $categoryIndex;
252  }
253 
258  public function setDescription($description)
259  {
260  $this->description = $description;
261  }
262 
266  public function getDescription()
267  {
268  return $this->description;
269  }
270 
276  {
277  $this->extensionKey = $extensionKey;
278  }
279 
283  public function getExtensionKey()
284  {
285  return $this->extensionKey;
286  }
287 
292  public function setLastUpdated(\DateTime $lastUpdated)
293  {
294  $this->lastUpdated = $lastUpdated;
295  }
296 
300  public function getLastUpdated()
301  {
302  return $this->lastUpdated;
303  }
304 
309  public function setState($state)
310  {
311  $this->state = $state;
312  }
313 
317  public function getState()
318  {
319  return $this->state;
320  }
321 
327  public function getStateString()
328  {
329  $stateString = '';
330  if (isset(self::$defaultStates[$this->getState()])) {
331  $stateString = self::$defaultStates[$this->getState()];
332  }
333  return $stateString;
334  }
335 
343  public function getDefaultState($state = null)
344  {
345  $defaultState = '';
346  if (is_null($state)) {
347  $defaultState = self::$defaultStates;
348  } else {
349  if (is_string($state)) {
350  $stateIndex = array_search(strtolower($state), self::$defaultStates);
351  if ($stateIndex === false) {
352  // default state
353  $stateIndex = 999;
354  }
355  $defaultState = $stateIndex;
356  } else {
357  if (is_int($state) && $state >= 0) {
358  if (array_key_exists($state, self::$defaultStates)) {
359  $stateTitle = self::$defaultStates[$state];
360  } else {
361  // default state
362  $stateTitle = 'n/a';
363  }
364  $defaultState = $stateTitle;
365  }
366  }
367  }
368  return $defaultState;
369  }
370 
375  public function setTitle($title)
376  {
377  $this->title = $title;
378  }
379 
383  public function getTitle()
384  {
385  return $this->title;
386  }
387 
393  {
394  $this->updateComment = $updateComment;
395  }
396 
400  public function getUpdateComment()
401  {
402  return $this->updateComment;
403  }
404 
409  public function setVersion($version)
410  {
411  $this->version = $version;
412  }
413 
417  public function getVersion()
418  {
419  return $this->version;
420  }
421 
427  {
428  $this->currentVersion = $currentVersion;
429  }
430 
434  public function getCurrentVersion()
435  {
436  return $this->currentVersion;
437  }
438 
443  public function setMd5hash($md5hash)
444  {
445  $this->md5hash = $md5hash;
446  }
447 
451  public function getMd5hash()
452  {
453  return $this->md5hash;
454  }
455 
462  public static function returnInstallPaths()
463  {
464  $installPaths = [
465  'System' => PATH_typo3 . 'sysext/',
466  'Global' => PATH_typo3 . 'ext/',
467  'Local' => PATH_typo3conf . 'ext/'
468  ];
469  return $installPaths;
470  }
471 
478  public static function returnAllowedInstallPaths()
479  {
480  $installPaths = self::returnInstallPaths();
481  if (empty($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowSystemInstall'])) {
482  unset($installPaths['System']);
483  }
484  if (empty($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowGlobalInstall'])) {
485  unset($installPaths['Global']);
486  }
487  if (empty($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowLocalInstall'])) {
488  unset($installPaths['Local']);
489  }
490  return $installPaths;
491  }
492 
499  public static function returnAllowedInstallTypes()
500  {
501  $installPaths = self::returnAllowedInstallPaths();
502  return array_keys($installPaths);
503  }
504 
510  {
511  $this->serializedDependencies = $dependencies;
512  }
513 
517  public function getSerializedDependencies()
518  {
520  }
521 
527  {
528  $this->dependencies = $dependencies;
529  }
530 
534  public function getDependencies()
535  {
536  if (!is_object($this->dependencies)) {
538  $extensionModelUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility::class);
539  $this->setDependencies($extensionModelUtility->convertDependenciesToObjects($this->getSerializedDependencies()));
540  }
541  return $this->dependencies;
542  }
543 
548  public function addDependency(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency)
549  {
550  $this->dependencies->attach($dependency);
551  }
552 
558  {
559  $this->integerVersion = $integerVersion;
560  }
561 
565  public function getIntegerVersion()
566  {
567  return $this->integerVersion;
568  }
569 
574  public function setReviewState($reviewState)
575  {
576  $this->reviewState = $reviewState;
577  }
578 
582  public function getReviewState()
583  {
584  return $this->reviewState;
585  }
586 
591  public function setPosition($position)
592  {
593  $this->position = $position;
594  }
595 
599  public function getPosition()
600  {
601  return $this->position;
602  }
603 
608  {
609  $this->alldownloadcounter = $alldownloadcounter;
610  }
611 
615  public function getAlldownloadcounter()
616  {
618  }
619 }
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
addDependency(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency)
injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager)