From 3ca46352fe05e1c1ecae0303ad6c28f2d99412b1 Mon Sep 17 00:00:00 2001 From: Benni Mack Date: Wed, 14 Feb 2018 00:34:26 +0100 Subject: [PATCH] [TASK] Remove overkill extension classes in about module When the about module (EXT:about) was refactored into Extbase, a Repository and Domain Model for Extensions was added to render title, key and authors of an extension. For modules this was done directly in the controller, which is 100% sufficient in this one-time case, instead of doing it the Extbase(tm) persistence way. This way, all data is fetched the same way in the about module. The two domain model / repository classes are removed, and due to the fact that they are not part of the API, a RST file is not added. Resolves: #83890 Releases: master Change-Id: I1169336452d7497ea0ed2e1a99553c164ec78612 Reviewed-on: https://review.typo3.org/55710 Tested-by: TYPO3com Reviewed-by: Georg Ringer Tested-by: Georg Ringer Reviewed-by: Markus Klein Tested-by: Markus Klein --- .../Classes/Controller/AboutController.php | 40 +++++---- .../about/Classes/Domain/Model/Extension.php | 86 ------------------- .../Domain/Repository/ExtensionRepository.php | 46 ---------- 3 files changed, 25 insertions(+), 147 deletions(-) delete mode 100644 typo3/sysext/about/Classes/Domain/Model/Extension.php delete mode 100644 typo3/sysext/about/Classes/Domain/Repository/ExtensionRepository.php diff --git a/typo3/sysext/about/Classes/Controller/AboutController.php b/typo3/sysext/about/Classes/Controller/AboutController.php index 3c23f3ba48ee..d0b863c19a7f 100644 --- a/typo3/sysext/about/Classes/Controller/AboutController.php +++ b/typo3/sysext/about/Classes/Controller/AboutController.php @@ -14,10 +14,10 @@ * The TYPO3 project - inspiring people to share! */ -use TYPO3\CMS\About\Domain\Repository\ExtensionRepository; use TYPO3\CMS\Backend\Module\ModuleLoader; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\BackendTemplateView; +use TYPO3\CMS\Core\Package\PackageManager; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; @@ -32,19 +32,6 @@ class AboutController extends ActionController */ protected $defaultViewObjectName = BackendTemplateView::class; - /** - * @var ExtensionRepository - */ - protected $extensionRepository; - - /** - * @param ExtensionRepository $extensionRepository - */ - public function injectExtensionRepository(ExtensionRepository $extensionRepository) - { - $this->extensionRepository = $extensionRepository; - } - /** * Set up the doc header properly here * @@ -76,7 +63,7 @@ public function indexAction() 'copyrightYear' => TYPO3_copyright_year, 'donationUrl' => TYPO3_URL_DONATE, 'currentVersion' => TYPO3_version, - 'loadedExtensions' => $this->extensionRepository->findAllLoaded(), + 'loadedExtensions' => $this->getLoadedExtensions(), 'copyRightNotice' => BackendUtility::TYPO3_copyRightNotice(), 'warnings' => $warnings, 'modules' => $this->getModulesData() @@ -132,4 +119,27 @@ protected function getSubModuleData(ModuleLoader $loadedModules, $moduleName) } return $subModulesData; } + + /** + * Fetches a list of all active (loaded) extensions in the current system + * + * @return array + */ + protected function getLoadedExtensions(): array + { + $extensions = []; + $packageManager = GeneralUtility::makeInstance(PackageManager::class); + foreach ($packageManager->getActivePackages() as $package) { + // Skip system extensions (= type: typo3-cms-framework) + if ($package->getValueFromComposerManifest('type') !== 'typo3-cms-extension') { + continue; + } + $extensions[] = [ + 'key' => $package->getPackageKey(), + 'title' => $package->getPackageMetaData()->getDescription(), + 'authors' => $package->getValueFromComposerManifest('authors') + ]; + } + return $extensions; + } } diff --git a/typo3/sysext/about/Classes/Domain/Model/Extension.php b/typo3/sysext/about/Classes/Domain/Model/Extension.php deleted file mode 100644 index 6d9ca3ed657a..000000000000 --- a/typo3/sysext/about/Classes/Domain/Model/Extension.php +++ /dev/null @@ -1,86 +0,0 @@ -authors = $authors; - } - - /** - * @return array - */ - public function getAuthors() - { - return $this->authors; - } - - /** - * @param string $key - */ - public function setKey($key) - { - $this->key = $key; - } - - /** - * @return string - */ - public function getKey() - { - return $this->key; - } - - /** - * @param string $title - */ - public function setTitle($title) - { - $this->title = $title; - } - - /** - * @return string - */ - public function getTitle() - { - return $this->title; - } -} diff --git a/typo3/sysext/about/Classes/Domain/Repository/ExtensionRepository.php b/typo3/sysext/about/Classes/Domain/Repository/ExtensionRepository.php deleted file mode 100644 index 78f074fcbcc8..000000000000 --- a/typo3/sysext/about/Classes/Domain/Repository/ExtensionRepository.php +++ /dev/null @@ -1,46 +0,0 @@ - - */ - public function findAllLoaded() - { - $loadedExtensions = $this->objectManager->get(ObjectStorage::class); - $packageManager = $this->objectManager->get(PackageManager::class); - foreach ($packageManager->getActivePackages() as $package) { - if ($package->getValueFromComposerManifest('type') === 'typo3-cms-extension') { - $extension = $this->objectManager->get(Extension::class); - $extension->setKey($package->getPackageKey()); - $extension->setTitle($package->getPackageMetaData()->getDescription()); - $extension->setAuthors($package->getValueFromComposerManifest('authors')); - $loadedExtensions->attach($extension); - } - } - return $loadedExtensions; - } -}