From: Christian Kuhn Date: Sat, 3 Nov 2012 14:55:13 +0000 (+0100) Subject: [TASK] Re-implement update TER extension list task X-Git-Tag: TYPO3_6-0-0rc1~37 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/0d6d053cb445745d325b3a4400a917c811c14bf0 [TASK] Re-implement update TER extension list task The scheduler task to update the TER extension list on a regular basis was removed with the implementation of the new extension manager. The patch adds an updated version of it and takes care that existing registered tasks of this type still work. Change-Id: Ic770ed78f23413b589352c25998eaee7863ec64f Resolves: #39915 Releases: 6.0 Reviewed-on: http://review.typo3.org/16168 Reviewed-by: Felix Kopp Tested-by: Felix Kopp Reviewed-by: Wouter Wolters Tested-by: Wouter Wolters Reviewed-by: Anja Leichsenring Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn --- diff --git a/typo3/sysext/extensionmanager/Classes/Task/UpdateExtensionListTask.php b/typo3/sysext/extensionmanager/Classes/Task/UpdateExtensionListTask.php new file mode 100644 index 00000000000..b056efe39d4 --- /dev/null +++ b/typo3/sysext/extensionmanager/Classes/Task/UpdateExtensionListTask.php @@ -0,0 +1,60 @@ + + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Update extension list from TER task + * + * @author Christian Kuhn + */ +class UpdateExtensionListTask extends \TYPO3\CMS\Scheduler\Task { + + /** + * Public method, called by scheduler. + * + * @return boolean TRUE on success + */ + public function execute() { + // Throws exceptions if something went wrong + $this->updateExtensionlist(); + + return TRUE; + } + + /** + * Update extension list + * + * @TODO: Adapt to multiple repositories if the Helper can handle this + * @return void + */ + protected function updateExtensionlist() { + /** @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManager */ + $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); + /** @var $repositoryHelper \TYPO3\CMS\Extensionmanager\Utility\Repository\Helper */ + $repositoryHelper = $objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper'); + $repositoryHelper->updateExtList(); + } +} +?> \ No newline at end of file diff --git a/typo3/sysext/extensionmanager/Migrations/Code/ClassAliasMap.php b/typo3/sysext/extensionmanager/Migrations/Code/ClassAliasMap.php new file mode 100644 index 00000000000..5576eef8c41 --- /dev/null +++ b/typo3/sysext/extensionmanager/Migrations/Code/ClassAliasMap.php @@ -0,0 +1,5 @@ + 'TYPO3\\CMS\\Extensionmanager\\Task\\UpdateExtensionListTask', +); +?> \ No newline at end of file diff --git a/typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf b/typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf index 0efeff3bdb5..b98ff8f1c5c 100644 --- a/typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf +++ b/typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf @@ -229,6 +229,12 @@ Update Extension List + + Update extension list + + + Update TER extension list on a regular basis. Once a day is a good interval. + diff --git a/typo3/sysext/extensionmanager/Tests/Unit/Task/UpdateExtensionListTaskTest.php b/typo3/sysext/extensionmanager/Tests/Unit/Task/UpdateExtensionListTaskTest.php new file mode 100644 index 00000000000..4844e62ffa3 --- /dev/null +++ b/typo3/sysext/extensionmanager/Tests/Unit/Task/UpdateExtensionListTaskTest.php @@ -0,0 +1,75 @@ + + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Test case + * + * @author Christian Kuhn + */ +class UpdateExtensionListTaskTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { + + /** + * @var array A backup of registered singleton instances + */ + protected $singletonInstances = array(); + + /** + * Set up + */ + public function setUp() { + $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances(); + } + + /** + * Tear down + */ + public function tearDown() { + \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances); + } + + /** + * @test + */ + public function executeCallsUpdateExtListOfRepositoryHelper() { + $repositoryHelperMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper'); + $repositoryHelperMock + ->expects($this->once()) + ->method('updateExtList'); + + $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); + $objectManagerMock + ->expects($this->once()) + ->method('get') + ->with('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper') + ->will($this->returnValue($repositoryHelperMock)); + + \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', $objectManagerMock); + + $task = new \TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask(); + $task->execute(); + } +} +?> \ No newline at end of file diff --git a/typo3/sysext/extensionmanager/ext_localconf.php b/typo3/sysext/extensionmanager/ext_localconf.php index 948199de963..f2dc782b38d 100644 --- a/typo3/sysext/extensionmanager/ext_localconf.php +++ b/typo3/sysext/extensionmanager/ext_localconf.php @@ -2,4 +2,12 @@ if (!defined('TYPO3_MODE')) { die('Access denied.'); } + +// Register extension list update task +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['TYPO3\\CMS\\Extensionmanager\\Task\\UpdateExtensionListTask'] = array( + 'extension' => $_EXTKEY, + 'title' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang.xlf:task.updateExtensionListTask.name', + 'description' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang.xlf:task.updateExtensionListTask.description', + 'additionalFields' => '', +); ?> \ No newline at end of file