From 879db2f396f0041c5b0eb201d2e12fde6e4f3b49 Mon Sep 17 00:00:00 2001 From: speedprogs_de Date: Thu, 1 Sep 2011 21:22:23 +0000 Subject: [PATCH] working state of the scheduler task with database processing git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@51626 735d13b6-9817-0410-8766-e36946ffe9aa --- Classes/Object/ObjectBuilder.php | 27 +++++--------- Classes/Provider/FileProvider.php | 2 +- Classes/Service/Mirror.php | 2 +- Classes/Service/Soap.php | 2 +- Classes/Task/UpdateExtensionListTask.php | 35 +++++++++++++++++-- .../TypoScript/Default/constants.txt | 8 ++--- 6 files changed, 47 insertions(+), 29 deletions(-) diff --git a/Classes/Object/ObjectBuilder.php b/Classes/Object/ObjectBuilder.php index b692788b..97ac1d68 100644 --- a/Classes/Object/ObjectBuilder.php +++ b/Classes/Object/ObjectBuilder.php @@ -33,26 +33,15 @@ */ protected $reflectionService; - /** - * @var Tx_Extbase_Persistence_IdentityMap - */ - protected $identityMap; - /** * @var array */ protected $classSchemata; - /** - * Injects the identity map - * - * @param Tx_Extbase_Persistence_IdentityMap $identityMap - * @return void + * @var array */ - public function injectIdentityMap(Tx_Extbase_Persistence_IdentityMap $identityMap) { - $this->identityMap = $identityMap; - } + protected $objects = array(); /** @@ -78,10 +67,10 @@ throw new Exception('No valid params given to create an object'); } - // Check identity map - $identifier = md5(json_encode($attributes)); - if ($this->identityMap->hasIdentifier($identifier, $className)) { - return $this->identityMap->getObjectByIdentifier($identifier, $className); + // Check internal cache first + $identifier = md5($className . json_encode($attributes)); + if (!empty($this->objects[$identifier])) { + return $this->objects[$identifier]; } // Build object @@ -100,8 +89,8 @@ } } - // Register object in identity map - $this->identityMap->registerObject($object, $identifier); + // Add object to internal cache + $this->objects[$identifier] = $object; return $object; } diff --git a/Classes/Provider/FileProvider.php b/Classes/Provider/FileProvider.php index 264207cb..15f4d851 100755 --- a/Classes/Provider/FileProvider.php +++ b/Classes/Provider/FileProvider.php @@ -271,7 +271,7 @@ $filename = PATH_site . $this->extensionRootPath . $filename; $content = t3lib_div::getURL($filename); if (empty($content)) { - throw new Exception('Can not fetch file "' . $filename . '"'); + throw new Exception('Could not fetch file "' . $filename . '"'); } // Check file hash diff --git a/Classes/Service/Mirror.php b/Classes/Service/Mirror.php index 1ef58253..4d6a5b21 100644 --- a/Classes/Service/Mirror.php +++ b/Classes/Service/Mirror.php @@ -26,7 +26,7 @@ /** * Service to handle mirrors */ - class Tx_TerFe2_Service_Mirror { + class Tx_TerFe2_Service_Mirror implements t3lib_Singleton { /** * @var integer diff --git a/Classes/Service/Soap.php b/Classes/Service/Soap.php index f9160067..73790479 100755 --- a/Classes/Service/Soap.php +++ b/Classes/Service/Soap.php @@ -26,7 +26,7 @@ /** * Service to handle soap requests */ - class Tx_TerFe2_Service_Soap { + class Tx_TerFe2_Service_Soap implements t3lib_Singleton { /** * @var SoapClient diff --git a/Classes/Task/UpdateExtensionListTask.php b/Classes/Task/UpdateExtensionListTask.php index 655c147e..1a8214e6 100644 --- a/Classes/Task/UpdateExtensionListTask.php +++ b/Classes/Task/UpdateExtensionListTask.php @@ -48,6 +48,11 @@ */ protected $settings; + /** + * @var Tx_Extbase_Configuration_ConfigurationManager + */ + protected $configurationManager; + /** * @var Tx_Extbase_Object_ObjectManager */ @@ -95,8 +100,9 @@ // Load configuration manager and set extension setup, // it is required to be loaded in object manager for persistence mapping - $configurationManager = $this->objectManager->get('Tx_Extbase_Configuration_ConfigurationManager'); - $configurationManager->setConfiguration(Tx_TerFe2_Utility_TypoScript::getSetup('plugin.tx_terfe2')); + $this->settings = Tx_TerFe2_Utility_TypoScript::getSetup('plugin.tx_terfe2'); + $this->configurationManager = $this->objectManager->get('Tx_Extbase_Configuration_ConfigurationManager'); + $this->configurationManager->setConfiguration($this->settings); // Load provider manager $this->providerManager = $this->objectManager->get('Tx_TerFe2_Provider_ProviderManager'); @@ -125,6 +131,11 @@ public function execute() { $this->initializeTask(); + // Check storage page + if (!$this->storagePageConfigured()) { + throw new Exception('Please configure "plugin.tx_terfe2.persistence.storagePid" in TypoScript setup'); + } + // Get information $lastRun = (int) $this->registry->get('lastRun'); $offset = (int) $this->registry->get('offset'); @@ -145,7 +156,7 @@ } } - // Set new values to registry + // Add new values to registry $offset = (!empty($extensions) ? $offset + $count : 0); $this->registry->add('lastRun', $GLOBALS['EXEC_TIME']); $this->registry->add('offset', $offset); @@ -219,6 +230,24 @@ } + /** + * Check whether a storage page is configured or not + * + * @return TRUE if a storage page was found + */ + protected function storagePageConfigured() { + $setup = Tx_TerFe2_Utility_TypoScript::getSetup('config.tx_extbase.persistence'); + $setup = Tx_Extbase_Utility_Arrays::arrayMergeRecursiveOverrule($setup, $this->settings['persistence.'], FALSE, FALSE); + if (!empty($setup['storagePid'])) { + return TRUE; + } + if (!empty($setup['classes.']['Tx_TerFe2_Domain_Model_Extension.']['newRecordStoragePid'])) { + return TRUE; + } + return FALSE; + } + + /** * Clear cache of given pages * diff --git a/Configuration/TypoScript/Default/constants.txt b/Configuration/TypoScript/Default/constants.txt index a627fd8f..4b7ac4b6 100644 --- a/Configuration/TypoScript/Default/constants.txt +++ b/Configuration/TypoScript/Default/constants.txt @@ -14,18 +14,18 @@ plugin.tx_terfe2 { } persistence { - # cat=TER Frontend/persistence/100; type=int+; label=General storage PID for the TER Frontend Index + # cat=TER Frontend/persistence/200; type=int+; label=General storage PID for the TER Frontend Index storagePid = 0 } view { - # cat=TER Frontend/view/200; type=string; label=Path to template root + # cat=TER Frontend/view/300; type=string; label=Path to template root templateRootPath = EXT:ter_fe2/Resources/Private/Templates/ - # cat=TER Frontend/view/210; type=string; label=Path to template partials + # cat=TER Frontend/view/310; type=string; label=Path to template partials partialRootPath = EXT:ter_fe2/Resources/Private/Partials/ - # cat=TER Frontend/view/220; type=string; label=Path to template layouts + # cat=TER Frontend/view/320; type=string; label=Path to template layouts layoutRootPath = EXT:ter_fe2/Resources/Private/Layouts/ } } \ No newline at end of file -- GitLab