[TASK] Remove overkill extension classes in about module 10/55710/4
authorBenni Mack <benni@typo3.org>
Tue, 13 Feb 2018 23:34:26 +0000 (00:34 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Wed, 14 Feb 2018 11:42:28 +0000 (12:42 +0100)
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 <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/about/Classes/Controller/AboutController.php
typo3/sysext/about/Classes/Domain/Model/Extension.php [deleted file]
typo3/sysext/about/Classes/Domain/Repository/ExtensionRepository.php [deleted file]

index 3c23f3b..d0b863c 100644 (file)
@@ -14,10 +14,10 @@ namespace TYPO3\CMS\About\Controller;
  * 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;
@@ -33,19 +33,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
      *
      * @param ViewInterface $view
@@ -76,7 +63,7 @@ class AboutController extends ActionController
             '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 @@ class AboutController extends ActionController
         }
         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 (file)
index 6d9ca3e..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-namespace TYPO3\CMS\About\Domain\Model;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
-
-/**
- * An extension helper model to be used in ext:about context
- */
-class Extension extends AbstractEntity
-{
-    /**
-     * @var array
-     */
-    protected $authors = [];
-
-    /**
-     * @var string
-     */
-    protected $key = '';
-
-    /**
-     * @var string
-     */
-    protected $title = '';
-
-    /**
-     * @param array $authors
-     */
-    public function setAuthors($authors)
-    {
-        $this->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 (file)
index 78f074f..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-namespace TYPO3\CMS\About\Domain\Repository;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-use TYPO3\CMS\About\Domain\Model\Extension;
-use TYPO3\CMS\Core\Package\PackageManager;
-use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
-use TYPO3\CMS\Extbase\Persistence\Repository;
-
-/**
- * Repository for TYPO3\CMS\About\Domain\Model\Extension
- */
-class ExtensionRepository extends Repository
-{
-    /**
-     * Finds all loaded third-party extensions (no system extensions)
-     *
-     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\About\Domain\Model\Extension>
-     */
-    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;
-    }
-}