TYPO3 CMS  TYPO3_6-2
ExtensionModelUtility.php
Go to the documentation of this file.
1 <?php
3 
23 
28  protected $objectManager;
29 
36  public function mapExtensionArrayToModel(array $extensionArray) {
38  $extension = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
39  $extension->setExtensionKey($extensionArray['key']);
40  if (isset($extensionArray['version'])) {
41  $extension->setVersion($extensionArray['version']);
42  }
43  if (isset($extensionArray['constraints'])) {
44  $extension->setDependencies($this->convertDependenciesToObjects(serialize($extensionArray['constraints'])));
45  }
46  return $extension;
47  }
48 
55  public function convertDependenciesToObjects($dependencies) {
56  $dependenciesObject = new \SplObjectStorage();
57  $unserializedDependencies = unserialize($dependencies);
58  if (!is_array($unserializedDependencies)) {
59  return $dependenciesObject;
60  }
61  foreach ($unserializedDependencies as $dependencyType => $dependencyValues) {
62  // Dependencies might be given as empty string, e.g. conflicts => ''
63  if (!is_array($dependencyValues)) {
64  continue;
65  }
66  foreach ($dependencyValues as $dependency => $versions) {
67  if ($dependencyType && $dependency) {
69  $lowest = $versionNumbers[0];
70  if (count($versionNumbers) === 2) {
71  $highest = $versionNumbers[1];
72  } else {
73  $highest = '';
74  }
76  $dependencyObject = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency');
77  $dependencyObject->setType($dependencyType);
78  $dependencyObject->setIdentifier($dependency);
79  $dependencyObject->setLowestVersion($lowest);
80  $dependencyObject->setHighestVersion($highest);
81  $dependenciesObject->attach($dependencyObject);
82  unset($dependencyObject);
83  }
84  }
85  }
86  return $dependenciesObject;
87  }
88 }
static convertVersionsStringToVersionNumbers($versionsString)