[TASK] Cleanup Extension Manager code 60/43560/2
authorNicole Cordes <typo3@cordes.co>
Fri, 25 Sep 2015 08:23:02 +0000 (10:23 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Fri, 25 Sep 2015 08:43:19 +0000 (10:43 +0200)
A new unnecessary function was introduced with
https://review.typo3.org/42283/. To have a cleaner code we should stick
to the functionality we already have and don't do think twice.

Resolves: #70101
Releases: master
Change-Id: I591ceb7a4e42b191aacb89add850fe996660d1e0
Reviewed-on: http://review.typo3.org/43560
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/extensionmanager/Classes/Controller/ListController.php
typo3/sysext/extensionmanager/Classes/Utility/DependencyUtility.php

index acf30ea..33da59d 100644 (file)
@@ -200,18 +200,15 @@ class ListController extends AbstractController {
                        }
 
                        $officialDistributions = $this->extensionRepository->findAllOfficialDistributions();
-                       if (!$showUnsuitableDistributions) {
-                               $suitableOfficialDistributions = $this->dependencyUtility->getExtensionsSuitableForTypo3Version($officialDistributions->toArray());
-                               $this->view->assign('officialDistributions', $suitableOfficialDistributions);
-                       } else {
-                               $this->view->assign('officialDistributions', $officialDistributions);
-                       }
-
                        $communityDistributions = $this->extensionRepository->findAllCommunityDistributions();
+
                        if (!$showUnsuitableDistributions) {
-                               $suitableCommunityDistributions = $this->dependencyUtility->getExtensionsSuitableForTypo3Version($communityDistributions->toArray());
+                               $suitableOfficialDistributions = $this->dependencyUtility->getExtensionsSuitableForTypo3Version($officialDistributions);
+                               $this->view->assign('officialDistributions', $suitableOfficialDistributions);
+                               $suitableCommunityDistributions = $this->dependencyUtility->getExtensionsSuitableForTypo3Version($communityDistributions);
                                $this->view->assign('communityDistributions', $suitableCommunityDistributions);
                        } else {
+                               $this->view->assign('officialDistributions', $officialDistributions);
                                $this->view->assign('communityDistributions', $communityDistributions);
                        }
                }
index a9aeec5..3c2ad5f 100644 (file)
@@ -558,34 +558,27 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
        /**
         * Get extensions (out of a given list) that are suitable for the current TYPO3 version
         *
-        * @param array $extensions List of extensions to check
+        * @param \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array $extensions List of extensions to check
         * @return array List of extensions suitable for current TYPO3 version
         */
-       public function getExtensionsSuitableForTypo3Version(array $extensions) {
+       public function getExtensionsSuitableForTypo3Version($extensions) {
                $suitableExtensions = array();
                /** @var Extension $extension */
                foreach ($extensions as $extension) {
                        /** @var Dependency $dependency */
                        foreach ($extension->getDependencies() as $dependency) {
-                               if ($dependency->getIdentifier() === 'typo3' && $this->isDependencySatisfiedByTypo3Version($dependency)) {
-                                       array_push($suitableExtensions, $extension);
+                               if ($dependency->getIdentifier() === 'typo3') {
+                                       try {
+                                               if ($this->checkTypo3Dependency($dependency)) {
+                                                       array_push($suitableExtensions, $extension);
+                                               }
+                                       } catch (Exception\UnresolvedTypo3DependencyException $e) {
+                                       }
+                                       break;
                                }
                        }
                }
                return $suitableExtensions;
        }
 
-       /**
-        * Checks if given dependency is satisfied by current TYPO3 version
-        *
-        * @param Dependency $dependency
-        * @return bool
-        */
-       protected function isDependencySatisfiedByTypo3Version(Dependency $dependency) {
-               $numericTypo3Version = VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getNumericTypo3Version());
-               $numericLowestVersion = VersionNumberUtility::convertVersionNumberToInteger($dependency->getLowestVersion());
-               $numericHighestVersion = VersionNumberUtility::convertVersionNumberToInteger($dependency->getHighestVersion());
-               return MathUtility::isIntegerInRange($numericTypo3Version, $numericLowestVersion, $numericHighestVersion);
-       }
-
 }