[+TASK] Extbase: Move most of the static extension utility methods to a service
authorBastian Waidelich <bastian@typo3.org>
Tue, 22 Mar 2011 19:16:56 +0000 (20:16 +0100)
committerBastian Waidelich <bastian@typo3.org>
Mon, 6 Jun 2011 18:11:07 +0000 (20:11 +0200)
Change-Id: If7759c825126e1fbf78f034a7b9181348dbfee1a
Related: #13864

typo3/sysext/extbase/Classes/MVC/Web/RequestBuilder.php
typo3/sysext/extbase/Classes/MVC/Web/Routing/UriBuilder.php
typo3/sysext/extbase/Classes/Service/ExtensionService.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Utility/Extension.php
typo3/sysext/extbase/Tests/Unit/MVC/Web/RequestBuilderTest.php
typo3/sysext/extbase/Tests/Unit/MVC/Web/Routing/UriBuilderTest.php
typo3/sysext/extbase/Tests/Unit/Service/ExtensionServiceTest.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Utility/ExtensionTest.php

index af8e623..9623123 100644 (file)
@@ -82,6 +82,11 @@ class Tx_Extbase_MVC_Web_RequestBuilder implements t3lib_Singleton {
        protected $configurationManager;
 
        /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected $extensionService;
+
+       /**
         * @param Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager
         */
        public function injectConfigurationManager(Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager) {
@@ -99,6 +104,14 @@ class Tx_Extbase_MVC_Web_RequestBuilder implements t3lib_Singleton {
        }
 
        /**
+        * @param Tx_Extbase_Service_ExtensionService $extensionService
+        * @return void
+        */
+       public function injectExtensionService(Tx_Extbase_Service_ExtensionService $extensionService) {
+               $this->extensionService = $extensionService;
+       }
+
+       /**
         * @return void
         */
        protected function loadDefaultValues() {
@@ -128,7 +141,7 @@ class Tx_Extbase_MVC_Web_RequestBuilder implements t3lib_Singleton {
         */
        public function build() {
                $this->loadDefaultValues();
-               $pluginNamespace = Tx_Extbase_Utility_Extension::getPluginNamespace($this->extensionName, $this->pluginName);
+               $pluginNamespace = $this->extensionService->getPluginNamespace($this->extensionName, $this->pluginName);
                $parameters = t3lib_div::_GPmerged($pluginNamespace);
 
                if (is_string($parameters['controller']) && array_key_exists($parameters['controller'], $this->allowedControllerActions)) {
index 3daf718..244c2b8 100644 (file)
@@ -28,6 +28,11 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder {
        protected $configurationManager;
 
        /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected $extensionService;
+
+       /**
         * An instance of tslib_cObj
         *
         * @var tslib_cObj
@@ -114,6 +119,14 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder {
        }
 
        /**
+        * @param Tx_Extbase_Service_ExtensionService $extensionService
+        * @return void
+        */
+       public function injectExtensionService(Tx_Extbase_Service_ExtensionService $extensionService) {
+               $this->extensionService = $extensionService;
+       }
+
+       /**
         * Life-cycle method that is called by the DI container as soon as this object is completely built
         *
         * @return void
@@ -448,13 +461,13 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder {
                        $extensionName = $this->request->getControllerExtensionName();
                }
                if ($pluginName === NULL && TYPO3_MODE === 'FE') {
-                       $pluginName = Tx_Extbase_Utility_Extension::getPluginNameByAction($extensionName, $controllerArguments['controller'], $controllerArguments['action']);
+                       $pluginName = $this->extensionService->getPluginNameByAction($extensionName, $controllerArguments['controller'], $controllerArguments['action']);
                }
                if ($pluginName === NULL) {
                        $pluginName = $this->request->getPluginName();
                }
                if ($this->targetPageUid === NULL && TYPO3_MODE === 'FE') {
-                       $this->targetPageUid = Tx_Extbase_Utility_Extension::getTargetPidByPlugin($extensionName, $pluginName);
+                       $this->targetPageUid = $this->extensionService->getTargetPidByPlugin($extensionName, $pluginName);
                }
                if ($this->format !== '') {
                        $controllerArguments['format'] = $this->format;
@@ -462,7 +475,7 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder {
                if ($this->argumentPrefix !== NULL) {
                        $prefixedControllerArguments = array($this->argumentPrefix => $controllerArguments);
                } else {
-                       $pluginNamespace = Tx_Extbase_Utility_Extension::getPluginNamespace($extensionName, $pluginName);
+                       $pluginNamespace = $this->extensionService->getPluginNamespace($extensionName, $pluginName);
                        $prefixedControllerArguments = array($pluginNamespace => $controllerArguments);
                }
                $this->arguments = t3lib_div::array_merge_recursive_overrule($this->arguments, $prefixedControllerArguments);
diff --git a/typo3/sysext/extbase/Classes/Service/ExtensionService.php b/typo3/sysext/extbase/Classes/Service/ExtensionService.php
new file mode 100644 (file)
index 0000000..49493e5
--- /dev/null
@@ -0,0 +1,181 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2011 Extbase Team
+*  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!
+***************************************************************/
+
+/**
+ * Utilities to process FlexForms
+ *
+ * @package Extbase
+ * @subpackage Service
+ */
+class Tx_Extbase_Service_ExtensionService implements t3lib_Singleton {
+
+       const PLUGIN_TYPE_PLUGIN = 'list_type';
+       const PLUGIN_TYPE_CONTENT_ELEMENT = 'CType';
+
+       /**
+        * @var Tx_Extbase_Object_ObjectManagerInterface
+        */
+       protected $objectManager;
+
+       /**
+        * @var Tx_Extbase_Configuration_ConfigurationManagerInterface
+        */
+       protected $configurationManager;
+
+       /**
+        * @param Tx_Extbase_Object_ManagerInterface $objectManager
+        * @return void
+        */
+       public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) {
+               $this->objectManager = $objectManager;
+       }
+
+       /**
+        * @param Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager
+        * @return void
+        */
+       public function injectConfigurationManager(Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager) {
+               $this->configurationManager = $configurationManager;
+       }
+
+       /**
+        * Determines the plugin namespace of the specified plugin (defaults to "tx_[extensionname]_[pluginname]")
+        * If plugin.tx_$pluginSignature.view.pluginNamespace is set, this value is returned
+        * If pluginNamespace is not specified "tx_[extensionname]_[pluginname]" is returned.
+        *
+        * @param string $extensionName name of the extension to retrieve the namespace for
+        * @param string $pluginName name of the plugin to retrieve the namespace for
+        * @return string plugin namespace
+        */
+       public function getPluginNamespace($extensionName, $pluginName) {
+               $pluginSignature = strtolower($extensionName . '_' . $pluginName);
+               $defaultPluginNamespace = 'tx_' . $pluginSignature;
+               $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
+               if (!isset($frameworkConfiguration['view']['pluginNamespace']) || empty($frameworkConfiguration['view']['pluginNamespace'])) {
+                       return $defaultPluginNamespace;
+               }
+               return $frameworkConfiguration['view']['pluginNamespace'];
+       }
+
+       /**
+        * Iterates through the global TypoScript configuration and returns the name of the plugin
+        * that matches specified extensionName, controllerName and actionName.
+        * If no matching plugin was found, NULL is returned.
+        * If more than one plugin matches and the current plugin is not configured to handle the action,
+        * an Exception will be thrown
+        *
+        * @param string $extensionName name of the target extension (UpperCamelCase)
+        * @param string $controllerName name of the target controller (UpperCamelCase)
+        * @param string $actionName name of the target action (lowerCamelCase)
+        * @return string name of the target plugin (UpperCamelCase) or NULL if no matching plugin configuration was found
+        */
+       public function getPluginNameByAction($extensionName, $controllerName, $actionName) {
+               $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
+                       // check, whether the current plugin is configured to handle the action
+               if ($extensionName === $frameworkConfiguration['extensionName']) {
+                       if (isset($frameworkConfiguration['controllerConfiguration'][$controllerName])
+                               && in_array($actionName, $frameworkConfiguration['controllerConfiguration'][$controllerName]['actions'])) {
+                               return $frameworkConfiguration['pluginName'];
+                       }
+               }
+               if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'])) {
+                       return NULL;
+               }
+               $pluginNames = array();
+               foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'] as $pluginName => $pluginConfiguration) {
+                       if (!is_array($pluginConfiguration['controllers'])) {
+                               continue;
+                       }
+                       foreach($pluginConfiguration['controllers'] as $pluginControllerName => $pluginControllerActions) {
+                               if (strtolower($pluginControllerName) !== strtolower($controllerName)) {
+                                       continue;
+                               }
+                               if (in_array($actionName, $pluginControllerActions['actions'])) {
+                                       $pluginNames[] = $pluginName;
+                               }
+                       }
+               }
+               if (count($pluginNames) > 1) {
+                       throw new Tx_Extbase_Exception('There is more than one plugin that can handle this request (Extension: "' . $extensionName . '", Controller: "' . $controllerName . '", action: "' . $actionName . '"). Please specify "pluginName" argument' , 1280825466);
+               }
+               return count($pluginNames) > 0 ? $pluginNames[0] : NULL;
+       }
+
+       /**
+        * Checks if the given action is cacheable or not.
+        *
+        * @param string $extensionName Name of the target extension, without underscores
+        * @param string $pluginName Name of the target plugin
+        * @param string $controllerName Name of the target controller
+        * @param string $actionName Name of the action to be called
+        * @return boolean TRUE if the specified plugin action is cacheable, otherwise FALSE
+        */
+       public function isActionCacheable($extensionName, $pluginName, $controllerName, $actionName) {
+               $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
+
+               if (isset($frameworkConfiguration['controllerConfiguration'][$controllerName])
+                       && is_array($frameworkConfiguration['controllerConfiguration'][$controllerName])
+                       && is_array($frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions'])
+                       && in_array($actionName, $frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions'])) {
+                               return FALSE;
+               }
+               return TRUE;
+       }
+
+       /**
+        * Determines the target page of the specified plugin.
+        * If plugin.tx_$pluginSignature.view.defaultPid is set, this value is used as target page id
+        * If defaultPid is set to "auto", a the target pid is determined by loading the tt_content record that contains this plugin
+        * If the page could not be determined, NULL is returned
+        * If defaultPid is "auto" and more than one page contains the specified plugin, an Exception is thrown
+        *
+        * @param string $extensionName name of the extension to retrieve the target PID for
+        * @param string $pluginName name of the plugin to retrieve the target PID for
+        * @return integer uid of the target page or NULL if target page could not be determined
+        */
+       public function getTargetPidByPlugin($extensionName, $pluginName) {
+               $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
+               if (!isset($frameworkConfiguration['view']['defaultPid']) || empty($frameworkConfiguration['view']['defaultPid'])) {
+                       return NULL;
+               }
+               $pluginSignature = strtolower($extensionName . '_' . $pluginName);
+               if ($frameworkConfiguration['view']['defaultPid'] === 'auto') {
+                       $pages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                               'pid',
+                               'tt_content',
+                               'list_type=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($pluginSignature, 'tt_content') . ' AND CType="list"' . $GLOBALS['TSFE']->sys_page->enableFields('tt_content'),
+                               '',
+                               '',
+                               2
+                       );
+                       if (count($pages) > 1) {
+                               throw new Tx_Extbase_Exception('There is more than one "' . $pluginSignature . '" plugin in the current page tree. Please remove one plugin or set the TypoScript configuration "plugin.tx_' . $pluginSignature . '.view.defaultPid" to a fixed page id' , 1280773643);
+                       }
+                       return count($pages) > 0 ? $pages[0]['pid'] : NULL;
+               }
+               return (integer)$frameworkConfiguration['view']['defaultPid'];
+       }
+
+}
+?>
\ No newline at end of file
index 54d1c41..a6568c4 100644 (file)
@@ -28,7 +28,6 @@
  *
  * @package Extbase
  * @subpackage Utility
- * @version $ID:$
  */
 class Tx_Extbase_Utility_Extension {
 
@@ -36,6 +35,23 @@ class Tx_Extbase_Utility_Extension {
        const PLUGIN_TYPE_CONTENT_ELEMENT = 'CType';
 
        /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected static $extensionService = NULL;
+
+       /**
+        * @return void
+        */
+       static protected function getExtensionService() {
+               if (self::$extensionService === NULL) {
+                       require_once t3lib_extMgm::extPath('extbase', 'Classes/Service/ExtensionService.php');
+                       $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
+                       self::$extensionService = $objectManager->get('Tx_Extbase_Service_ExtensionService');
+               }
+               return self::$extensionService;
+       }
+
+       /**
         * Add auto-generated TypoScript to configure the Extbase Dispatcher.
         *
         * When adding a frontend plugin you will have to add both an entry to the TCA definition
@@ -211,7 +227,7 @@ tt_content.' . $pluginSignature . ' {
                );
 
                if ((strlen($mainModuleName) > 0) && !array_key_exists($mainModuleName, $GLOBALS['TBE_MODULES'])) {
-                       $mainModuleName = $extensionName . self::convertLowerUnderscoreToUpperCamelCase($mainModuleName);
+                       $mainModuleName = $extensionName . t3lib_div::underscoredToUpperCamelCase($mainModuleName);
                } else {
                        $mainModuleName = (strlen($mainModuleName) > 0) ? $mainModuleName : 'web';
                }
@@ -226,7 +242,7 @@ tt_content.' . $pluginSignature . ' {
                $moduleSignature = $mainModuleName;
 
                if ((strlen($subModuleName) > 0)) {
-                       $subModuleName = $extensionName . self::convertLowerUnderscoreToUpperCamelCase($subModuleName);
+                       $subModuleName = $extensionName . t3lib_div::underscoredToUpperCamelCase($subModuleName);
                        $moduleSignature .= '_' . $subModuleName;
                }
 
@@ -259,6 +275,7 @@ tt_content.' . $pluginSignature . ' {
         * @deprecated since Extbase 1.3.0; will be removed in Extbase 1.5.0
         */
        static public function convertCamelCaseToLowerCaseUnderscored($string) {
+               t3lib_div::logDeprecatedFunction();
                return t3lib_div::camelCaseToLowerCaseUnderscored($string);
        }
 
@@ -272,6 +289,7 @@ tt_content.' . $pluginSignature . ' {
         * @deprecated since Extbase 1.3.0; will be removed in Extbase 1.5.0
         */
        static public function convertUnderscoredToLowerCamelCase($string) {
+               t3lib_div::logDeprecatedFunction();
                return t3lib_div::underscoredToLowerCamelCase($string);
        }
 
@@ -285,6 +303,7 @@ tt_content.' . $pluginSignature . ' {
         * @deprecated since Extbase 1.3.0; will be removed in Extbase 1.5.0
         */
        static public function convertLowerUnderscoreToUpperCamelCase($string) {
+               t3lib_div::logDeprecatedFunction();
                return t3lib_div::underscoredToUpperCamelCase($string);
        }
 
@@ -295,8 +314,10 @@ tt_content.' . $pluginSignature . ' {
         * @param       string  $extensionPath  full path of the extension
         * @param   array   $additionalAutoloadClasses additional classes to be added to the autoloader. The key must be the classname all-lowercase, the value must be the entry to be inserted
         * @return      string  HTML string which should be outputted
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0
         */
        static public function createAutoloadRegistryForExtension($extensionKey, $extensionPath, $additionalAutoloadClasses = array()) {
+               t3lib_div::logDeprecatedFunction();
                $classNameToFileMapping = array();
                $extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', $extensionKey)));
                $errors = self::buildAutoloadRegistryForSinglePath($classNameToFileMapping, $extensionPath . 'Classes/', '.*tslib.*', '$extensionClassesPath . \'|\'');
@@ -328,6 +349,7 @@ tt_content.' . $pluginSignature . ' {
         * @param       array   $classNameToFileMapping class name to file mapping
         * @param       string  $globalPrefix   Global prefix which is prepended to all code.
         * @return      string  The full PHP string
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0
         */
        protected function generateAutoloadPHPFileData($classNameToFileMapping, $globalPrefix = '') {
                $output = '<?php' . PHP_EOL;
@@ -352,6 +374,7 @@ tt_content.' . $pluginSignature . ' {
         * @param       string  $excludeRegularExpression       Exclude regular expression, to exclude certain files from being processed
         * @param       string  $valueWrap      Wrap for the file name
         * @return void
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0
         */
        static protected function buildAutoloadRegistryForSinglePath(&$classNameToFileMapping, $path, $excludeRegularExpression = '', $valueWrap = '\'|\'') {
 //             if (file_exists($path . 'Classes/')) {
@@ -373,6 +396,7 @@ tt_content.' . $pluginSignature . ' {
         *
         * @param       string  $filePath       File path (absolute)
         * @return      array   Class names
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0
         */
        static protected function extractClassNames($filePath) {
                $fileContent = php_strip_whitespace($filePath);
@@ -420,6 +444,7 @@ tt_content.' . $pluginSignature . ' {
         * @param       array   $wantedToken    the tokens to be found
         * @param       array   $intermediateTokens     optional: list of tokens that are allowed to skip when looking for the wanted token
         * @return      mixed
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0
         */
        static protected function findToken(array &$tokenList, array $wantedTokens, array $intermediateTokens = array()) {
                $skipAllTokens = count($intermediateTokens) ? false : true;
@@ -454,17 +479,12 @@ tt_content.' . $pluginSignature . ' {
         * @param string $extensionName name of the extension to retrieve the namespace for
         * @param string $pluginName name of the plugin to retrieve the namespace for
         * @return string plugin namespace
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0 - Use Tx_Extbase_Service_ExtensionService instead
         */
        static public function getPluginNamespace($extensionName, $pluginName) {
-               $pluginSignature = strtolower($extensionName . '_' . $pluginName);
-               $defaultPluginNamespace = 'tx_' . $pluginSignature;
-               $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
-               $configurationManager = $objectManager->get('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $frameworkConfiguration = $configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
-               if (!isset($frameworkConfiguration['view']['pluginNamespace']) || empty($frameworkConfiguration['view']['pluginNamespace'])) {
-                       return $defaultPluginNamespace;
-               }
-               return $frameworkConfiguration['view']['pluginNamespace'];
+               t3lib_div::logDeprecatedFunction();
+               $extensionService = self::getExtensionService();
+               return $extensionService->getPluginNamespace($extensionName, $pluginName);
        }
 
        /**
@@ -478,39 +498,12 @@ tt_content.' . $pluginSignature . ' {
         * @param string $controllerName name of the target controller (UpperCamelCase)
         * @param string $actionName name of the target action (lowerCamelCase)
         * @return string name of the target plugin (UpperCamelCase) or NULL if no matching plugin configuration was found
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0 - Use Tx_Extbase_Service_ExtensionService instead
         */
        static public function getPluginNameByAction($extensionName, $controllerName, $actionName) {
-               $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
-               $configurationManager = $objectManager->get('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $frameworkConfiguration = $configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
-                       // check, whether the current plugin is configured to handle the action
-               if ($extensionName === $frameworkConfiguration['extensionName']) {
-                       if (isset($frameworkConfiguration['controllerConfiguration'][$controllerName])
-                               && in_array($actionName, $frameworkConfiguration['controllerConfiguration'][$controllerName]['actions'])) {
-                               return $frameworkConfiguration['pluginName'];
-                       }
-               }
-               if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'])) {
-                       return NULL;
-               }
-               $pluginNames = array();
-               foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'] as $pluginName => $pluginConfiguration) {
-                       if (!is_array($pluginConfiguration['controllers'])) {
-                               continue;
-                       }
-                       foreach($pluginConfiguration['controllers'] as $pluginControllerName => $pluginControllerActions) {
-                               if (strtolower($pluginControllerName) !== strtolower($controllerName)) {
-                                       continue;
-                               }
-                               if (in_array($actionName, $pluginControllerActions['actions'])) {
-                                       $pluginNames[] = $pluginName;
-                               }
-                       }
-               }
-               if (count($pluginNames) > 1) {
-                       throw new Tx_Extbase_Exception('There is more than one plugin that can handle this request (Extension: "' . $extensionName . '", Controller: "' . $controllerName . '", action: "' . $actionName . '"). Please specify "pluginName" argument' , 1280825466);
-               }
-               return count($pluginNames) > 0 ? $pluginNames[0] : NULL;
+               t3lib_div::logDeprecatedFunction();
+               $extensionService = self::getExtensionService();
+               return $extensionService->getPluginNameByAction($extensionName, $controllerName, $actionName);
        }
 
        /**
@@ -521,19 +514,12 @@ tt_content.' . $pluginSignature . ' {
         * @param string $controllerName Name of the target controller
         * @param string $actionName Name of the action to be called
         * @return boolean TRUE if the specified plugin action is cacheable, otherwise FALSE
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0 - Use Tx_Extbase_Service_ExtensionService instead
         */
        static public function isActionCacheable($extensionName, $pluginName, $controllerName, $actionName) {
-               $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
-               $configurationManager = $objectManager->get('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $frameworkConfiguration = $configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
-
-               if (isset($frameworkConfiguration['controllerConfiguration'][$controllerName])
-                       && is_array($frameworkConfiguration['controllerConfiguration'][$controllerName])
-                       && is_array($frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions'])
-                       && in_array($actionName, $frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions'])) {
-                               return FALSE;
-               }
-               return TRUE;
+               t3lib_div::logDeprecatedFunction();
+               $extensionService = self::getExtensionService();
+               return $extensionService->isActionCacheable($extensionName, $pluginName, $controllerName, $actionName);
        }
 
        /**
@@ -546,30 +532,12 @@ tt_content.' . $pluginSignature . ' {
         * @param string $extensionName name of the extension to retrieve the target PID for
         * @param string $pluginName name of the plugin to retrieve the target PID for
         * @return integer uid of the target page or NULL if target page could not be determined
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0 - Use Tx_Extbase_Service_ExtensionService instead
         */
        static public function getTargetPidByPlugin($extensionName, $pluginName) {
-               $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
-               $configurationManager = $objectManager->get('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $frameworkConfiguration = $configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
-               if (!isset($frameworkConfiguration['view']['defaultPid']) || empty($frameworkConfiguration['view']['defaultPid'])) {
-                       return NULL;
-               }
-               $pluginSignature = strtolower($extensionName . '_' . $pluginName);
-               if ($frameworkConfiguration['view']['defaultPid'] === 'auto') {
-                       $pages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                               'pid',
-                               'tt_content',
-                               'list_type=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($pluginSignature, 'tt_content') . ' AND CType="list"' . $GLOBALS['TSFE']->sys_page->enableFields('tt_content'),
-                               '',
-                               '',
-                               2
-                       );
-                       if (count($pages) > 1) {
-                               throw new Tx_Extbase_Exception('There is more than one "' . $pluginSignature . '" plugin in the current page tree. Please remove one plugin or set the TypoScript configuration "plugin.tx_' . $pluginSignature . '.view.defaultPid" to a fixed page id' , 1280773643);
-                       }
-                       return count($pages) > 0 ? $pages[0]['pid'] : NULL;
-               }
-               return (integer)$frameworkConfiguration['view']['defaultPid'];
+               t3lib_div::logDeprecatedFunction();
+               $extensionService = self::getExtensionService();
+               return $extensionService->getTargetPidByPlugin($extensionName, $pluginName);
        }
 }
 
index 6527883..3e839dc 100644 (file)
@@ -48,6 +48,11 @@ class Tx_Extbase_Tests_Unit_MVC_Web_RequestBuilderTest extends Tx_Extbase_Tests_
        protected $mockObjectManager;
 
        /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected $mockExtensionService;
+
+       /**
         * @var Tx_Extbase_MVC_Web_Request
         */
        protected $mockRequest;
@@ -90,6 +95,7 @@ class Tx_Extbase_Tests_Unit_MVC_Web_RequestBuilderTest extends Tx_Extbase_Tests_
                $this->mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
                $this->mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request');
                $this->mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManagerInterface');
+               $this->mockExtensionService = $this->getMock('Tx_Extbase_Service_ExtensionService');
 
                $this->getBackup = $_GET;
                $this->postBackup = $_POST;
@@ -105,6 +111,10 @@ class Tx_Extbase_Tests_Unit_MVC_Web_RequestBuilderTest extends Tx_Extbase_Tests_
 
                $this->mockObjectManager->expects($this->any())->method('create')->with('Tx_Extbase_MVC_Web_Request')->will($this->returnValue($this->mockRequest));
                $this->requestBuilder->injectObjectManager($this->mockObjectManager);
+
+               $pluginNamespace = 'tx_' . strtolower($this->configuration['extensionName'] . '_' . $this->configuration['pluginName']);
+               $this->mockExtensionService->expects($this->any())->method('getPluginNamespace')->will($this->returnValue($pluginNamespace));
+               $this->requestBuilder->injectExtensionService($this->mockExtensionService);
        }
 
        public function tearDown() {
@@ -211,6 +221,7 @@ class Tx_Extbase_Tests_Unit_MVC_Web_RequestBuilderTest extends Tx_Extbase_Tests_
                $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
                $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
                $this->requestBuilder->injectConfigurationManager($mockConfigurationManager);
+               $this->requestBuilder->injectExtensionService($this->mockExtensionService);
                $this->requestBuilder->build();
        }
 
@@ -222,6 +233,7 @@ class Tx_Extbase_Tests_Unit_MVC_Web_RequestBuilderTest extends Tx_Extbase_Tests_
                unset($this->configuration['controllerConfiguration']);
                $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
                $this->requestBuilder->injectConfigurationManager($this->mockConfigurationManager);
+               $this->requestBuilder->injectExtensionService($this->mockExtensionService);
                $this->requestBuilder->build();
        }
 
@@ -233,6 +245,7 @@ class Tx_Extbase_Tests_Unit_MVC_Web_RequestBuilderTest extends Tx_Extbase_Tests_
                $this->configuration['controllerConfiguration']['TheFirstController'] = array();
                $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
                $this->requestBuilder->injectConfigurationManager($this->mockConfigurationManager);
+               $this->requestBuilder->injectExtensionService($this->mockExtensionService);
                $this->requestBuilder->build();
        }
 
index ee27f56..422b965 100644 (file)
@@ -50,6 +50,11 @@ class Tx_Extbase_Tests_Unit_MVC_Web_Routing_UriBuilderTest extends Tx_Extbase_Te
        protected $mockRequest;
 
        /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected $mockExtensionService;
+
+       /**
         * @var Tx_Extbase_MVC_Web_Routing_UriBuilder
         */
        protected $uriBuilder;
@@ -62,10 +67,13 @@ class Tx_Extbase_Tests_Unit_MVC_Web_Routing_UriBuilderTest extends Tx_Extbase_Te
 
                $this->mockContentObject = $this->getMock('tslib_cObj');
                $this->mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request');
+               $this->mockExtensionService = $this->getMock('Tx_Extbase_Service_ExtensionService');
 
                $this->uriBuilder = $this->getAccessibleMock('Tx_Extbase_MVC_Web_Routing_UriBuilder', array('build'));
                $this->uriBuilder->setRequest($this->mockRequest);
                $this->uriBuilder->_set('contentObject', $this->mockContentObject);
+
+               $this->uriBuilder->injectExtensionService($this->mockExtensionService);
        }
 
        public function tearDown() {
@@ -110,6 +118,7 @@ class Tx_Extbase_Tests_Unit_MVC_Web_Routing_UriBuilderTest extends Tx_Extbase_Te
         * @test
         */
        public function uriForPrefixesArgumentsWithExtensionAndPluginNameAndSetsControllerArgument() {
+               $this->mockExtensionService->expects($this->once())->method('getPluginNamespace')->will($this->returnValue('tx_someextension_someplugin'));
                $expectedArguments = array('tx_someextension_someplugin' => array('foo' => 'bar', 'baz' => array('extbase' => 'fluid'), 'controller' => 'SomeController'));
                $GLOBALS['TSFE'] = NULL;
                $this->uriBuilder->uriFor(NULL, array('foo' => 'bar', 'baz' => array('extbase' => 'fluid')), 'SomeController', 'SomeExtension', 'SomePlugin');
@@ -120,6 +129,7 @@ class Tx_Extbase_Tests_Unit_MVC_Web_Routing_UriBuilderTest extends Tx_Extbase_Te
         * @test
         */
        public function uriForRecursivelyMergesAndOverrulesControllerArgumentsWithArguments() {
+               $this->mockExtensionService->expects($this->once())->method('getPluginNamespace')->will($this->returnValue('tx_someextension_someplugin'));
                $arguments = array('tx_someextension_someplugin' => array('foo' => 'bar'), 'additionalParam' => 'additionalValue');
                $controllerArguments = array('foo' => 'overruled', 'baz' => array('extbase' => 'fluid'));
                $expectedArguments = array('tx_someextension_someplugin' => array('foo' => 'overruled', 'baz' => array('extbase' => 'fluid'), 'controller' => 'SomeController'), 'additionalParam' => 'additionalValue');
@@ -133,6 +143,7 @@ class Tx_Extbase_Tests_Unit_MVC_Web_Routing_UriBuilderTest extends Tx_Extbase_Te
         * @test
         */
        public function uriForOnlySetsActionArgumentIfSpecified() {
+               $this->mockExtensionService->expects($this->once())->method('getPluginNamespace')->will($this->returnValue('tx_someextension_someplugin'));
                $expectedArguments = array('tx_someextension_someplugin' => array('controller' => 'SomeController'));
 
                $this->uriBuilder->uriFor(NULL, array(), 'SomeController', 'SomeExtension', 'SomePlugin');
@@ -143,6 +154,7 @@ class Tx_Extbase_Tests_Unit_MVC_Web_Routing_UriBuilderTest extends Tx_Extbase_Te
         * @test
         */
        public function uriForSetsControllerFromRequestIfControllerIsNotSet() {
+               $this->mockExtensionService->expects($this->once())->method('getPluginNamespace')->will($this->returnValue('tx_someextension_someplugin'));
                $this->mockRequest->expects($this->once())->method('getControllerName')->will($this->returnValue('SomeControllerFromRequest'));
 
                $expectedArguments = array('tx_someextension_someplugin' => array('controller' => 'SomeControllerFromRequest'));
@@ -155,6 +167,7 @@ class Tx_Extbase_Tests_Unit_MVC_Web_Routing_UriBuilderTest extends Tx_Extbase_Te
         * @test
         */
        public function uriForSetsExtensionNameFromRequestIfExtensionNameIsNotSet() {
+               $this->mockExtensionService->expects($this->any())->method('getPluginNamespace')->will($this->returnValue('tx_someextensionnamefromrequest_someplugin'));
                $this->mockRequest->expects($this->once())->method('getControllerExtensionName')->will($this->returnValue('SomeExtensionNameFromRequest'));
 
                $expectedArguments = array('tx_someextensionnamefromrequest_someplugin' => array('controller' => 'SomeController'));
@@ -167,6 +180,7 @@ class Tx_Extbase_Tests_Unit_MVC_Web_Routing_UriBuilderTest extends Tx_Extbase_Te
         * @test
         */
        public function uriForSetsPluginNameFromRequestIfPluginNameIsNotSet() {
+               $this->mockExtensionService->expects($this->once())->method('getPluginNamespace')->will($this->returnValue('tx_someextension_somepluginnamefromrequest'));
                $this->mockRequest->expects($this->once())->method('getPluginName')->will($this->returnValue('SomePluginNameFromRequest'));
 
                $expectedArguments = array('tx_someextension_somepluginnamefromrequest' => array('controller' => 'SomeController'));
@@ -179,23 +193,9 @@ class Tx_Extbase_Tests_Unit_MVC_Web_Routing_UriBuilderTest extends Tx_Extbase_Te
         * @test
         */
        public function uriForDoesNotDisableCacheHashForNonCacheableActions() {
-               $mockConfiguration = array(
-                       'controllerConfiguration' => array(
-                               'SomeController' => array(
-                                       'nonCacheableActions' => array('someNonCacheableAction')
-                               )
-                       )
-               );
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($mockConfiguration));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->any())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
+               $this->mockExtensionService->expects($this->any())->method('isActionCacheable')->will($this->returnValue(FALSE));
                $this->uriBuilder->uriFor('someNonCacheableAction', array(), 'SomeController', 'SomeExtension');
                $this->assertTrue($this->uriBuilder->getUseCacheHash());
-
-               t3lib_div::purgeInstances();
        }
 
        /**
diff --git a/typo3/sysext/extbase/Tests/Unit/Service/ExtensionServiceTest.php b/typo3/sysext/extbase/Tests/Unit/Service/ExtensionServiceTest.php
new file mode 100644 (file)
index 0000000..52b53c1
--- /dev/null
@@ -0,0 +1,300 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2011 Extbase Team
+*  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!
+***************************************************************/
+
+
+/**
+ * Testcase for class Tx_Extbase_Service_ExtensionService
+ *
+ * @package Extbase
+ * @subpackage extbase
+ */
+
+class Tx_Extbase_Tests_Unit_Service_ExtensionServiceTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
+
+       /**
+        * Contains backup of $TYPO3_CONF_VARS
+        * @var array
+        */
+       protected $typo3ConfVars = array();
+
+       /**
+        * @var t3lib_DB
+        */
+       protected $typo3DbBackup;
+
+       /**
+        * @var t3lib_fe contains a backup of the current $GLOBALS['TSFE']
+        */
+       protected $tsfeBackup;
+
+       /**
+        * @var Tx_Extbase_Configuration_ConfigurationManagerInterface
+        */
+       protected $mockConfigurationManager;
+
+       /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected $extensionService;
+
+       public function setUp() {
+               $this->typo3ConfVars = $GLOBALS['TYPO3_CONF_VARS'];
+               $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
+               $GLOBALS['TYPO3_DB'] = $this->getMock('t3lib_DB', array('fullQuoteStr', 'exec_SELECTgetRows'));
+               $this->extensionService = new Tx_Extbase_Service_ExtensionService();
+
+               $this->mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
+               $this->extensionService->injectConfigurationManager($this->mockConfigurationManager);
+
+               $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'] = array(
+                       'ExtensionName' => array(
+                               'plugins' => array(
+                                       'SomePlugin' => array(
+                                               'controllers' => array(
+                                                       'ControllerName' => array(
+                                                               'actions' => array('index', 'otherAction')
+                                                       ),
+                                               ),
+                                       ),
+                                       'ThirdPlugin' => array(
+                                               'controllers' => array(
+                                                       'ControllerName' => array(
+                                                               'actions' => array('otherAction', 'thirdAction')
+                                                       ),
+                                               ),
+                                       ),
+                               ),
+                       ),
+                       'SomeOtherExtensionName' => array(
+                               'plugins' => array(
+                                       'SecondPlugin' => array(
+                                               'controllers' => array(
+                                                       'ControllerName' => array(
+                                                               'actions' => array('index', 'otherAction')
+                                                       ),
+                                                       'SecondControllerName' => array(
+                                                               'actions' => array('someAction', 'someOtherAction'),
+                                                               'nonCacheableActions' => array('someOtherAction')
+                                                       )
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+       }
+
+       public function tearDown() {
+               $GLOBALS['TYPO3_CONF_VARS'] = $this->typo3ConfVars;
+               $GLOBALS['TSFE'] = $this->tsfeBackup;
+       }
+
+       /**
+        * DataProvider for getPluginNamespaceByPluginSignatureTests()
+        *
+        * @return array
+        */
+       public function getPluginNamespaceDataProvider() {
+               return array(
+                       array('SomeExtension', 'SomePlugin', 'tx_someextension_someplugin'),
+                       array('NonExistingExtension', 'SomePlugin', 'tx_nonexistingextension_someplugin'),
+                       array('Invalid', '', 'tx_invalid_'),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider getPluginNamespaceDataProvider
+        */
+       public function getPluginNamespaceTests($extensionName, $pluginName, $expectedResult) {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array()));
+
+               $actualResult = $this->extensionService->getPluginNamespace($extensionName, $pluginName);
+               $this->assertEquals($expectedResult, $actualResult, 'Failing for extension: "' . $extensionName . '", plugin: "' . $pluginName . '"');
+       }
+
+       /**
+        * @test
+        */
+       public function pluginNamespaceCanBeOverridden() {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->with(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'SomeExtension', 'SomePlugin')->will($this->returnValue(array('view' => array('pluginNamespace' => 'overridden_plugin_namespace'))));
+
+               $expectedResult = 'overridden_plugin_namespace';
+               $actualResult = $this->extensionService->getPluginNamespace('SomeExtension', 'SomePlugin');
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * DataProvider for getPluginNameByActionTests()
+        *
+        * @return array
+        */
+       public function getPluginNameByActionDataProvider() {
+               return array(
+                       array('ExtensionName', 'ControllerName', 'someNonExistingAction', NULL),
+                       array('ExtensionName', 'ControllerName', 'index', 'SomePlugin'),
+                       array('ExtensionName', 'ControllerName', 'thirdAction', 'ThirdPlugin'),
+                       array('eXtEnSiOnNaMe', 'cOnTrOlLeRnAmE', 'thirdAction', NULL),
+                       array('eXtEnSiOnNaMe', 'cOnTrOlLeRnAmE', 'ThIrDaCtIoN', NULL),
+                       array('SomeOtherExtensionName', 'ControllerName', 'otherAction', 'SecondPlugin'),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider getPluginNameByActionDataProvider
+        */
+       public function getPluginNameByActionTests($extensionName, $controllerName, $actionName, $expectedResult) {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->with(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK)->will($this->returnValue(array('view' => array('pluginNamespace' => 'overridden_plugin_namespace'))));
+               $actualResult = $this->extensionService->getPluginNameByAction($extensionName, $controllerName, $actionName);
+               $this->assertEquals($expectedResult, $actualResult, 'Failing for $extensionName: "' . $extensionName . '", $controllerName: "' . $controllerName . '", $actionName: "' . $actionName . '" - ');
+       }
+
+       /**
+        * @test
+        * @expectedException Tx_Extbase_Exception
+        */
+       public function getPluginNameByActionThrowsExceptionIfMoreThanOnePluginMatches() {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->with(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK)->will($this->returnValue(array('view' => array('pluginNamespace' => 'overridden_plugin_namespace'))));
+               $this->extensionService->getPluginNameByAction('ExtensionName', 'ControllerName', 'otherAction');
+       }
+
+       /**
+        * @test
+        */
+       public function getPluginNameByActionReturnsCurrentIfItCanHandleTheActionEvenIfMoreThanOnePluginMatches() {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->with(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK)->will($this->returnValue(array('extensionName' => 'CurrentExtension', 'pluginName' => 'CurrentPlugin', 'controllerConfiguration' => array('ControllerName' => array('actions' => array('otherAction'))))));
+
+               $actualResult = $this->extensionService->getPluginNameByAction('CurrentExtension', 'ControllerName', 'otherAction');
+               $expectedResult = 'CurrentPlugin';
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function isActionCacheableReturnsTrueByDefault() {
+               $mockConfiguration = array();
+               $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($mockConfiguration));
+
+               $actualResult = $this->extensionService->isActionCacheable('SomeExtension', 'SomePlugin', 'SomeController', 'someAction');
+               $this->assertTrue($actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function isActionCacheableReturnsFalseIfActionIsNotCacheable() {
+               $mockConfiguration = array(
+                       'controllerConfiguration' => array(
+                               'SomeController' => array(
+                                       'nonCacheableActions' => array('someAction')
+                               )
+                       )
+               );
+               $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($mockConfiguration));
+
+               $actualResult = $this->extensionService->isActionCacheable('SomeExtension', 'SomePlugin', 'SomeController', 'someAction');
+               $this->assertFalse($actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function getTargetPidByPluginSignatureReturnsNullIfConfigurationManagerIsNotInitialized() {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(NULL));
+
+               $this->assertNull($this->extensionService->getTargetPidByPlugin('ExtensionName', 'PluginName'));
+       }
+
+       /**
+        * @test
+        */
+       public function getTargetPidByPluginSignatureReturnsNullIfDefaultPidIsZero() {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('view' => array('defaultPid' => 0))));
+
+               $this->assertNull($this->extensionService->getTargetPidByPlugin('ExtensionName', 'PluginName'));
+       }
+
+       /**
+        * @test
+        */
+       public function getTargetPidByPluginSignatureReturnsTheConfiguredDefaultPid() {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('view' => array('defaultPid' => 123))));
+
+               $expectedResult = 123;
+               $actualResult = $this->extensionService->getTargetPidByPlugin('ExtensionName', 'SomePlugin');
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function getTargetPidByPluginSignatureDeterminesTheTargetPidIfDefaultPidIsAuto() {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('view' => array('defaultPid' => 'auto'))));
+
+               $pluginSignature = 'extensionname_someplugin';
+               $GLOBALS['TSFE']->sys_page = $this->getMock('t3lib_pageSelect', array('enableFields'));
+               $GLOBALS['TSFE']->sys_page->expects($this->once())->method('enableFields')->with('tt_content')->will($this->returnValue(' AND enable_fields'));
+               $GLOBALS['TYPO3_DB']->expects($this->once())->method('fullQuoteStr')->with($pluginSignature, 'tt_content')->will($this->returnValue('"pluginSignature"'));
+               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_SELECTgetRows')->with(
+                       'pid',
+                       'tt_content',
+                       'list_type="pluginSignature" AND CType="list" AND enable_fields',
+                       '',
+                       ''
+               )->will($this->returnValue(array(array('pid' => '321'))));
+               $expectedResult = 321;
+               $actualResult = $this->extensionService->getTargetPidByPlugin('ExtensionName', 'SomePlugin');
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function getTargetPidByPluginSignatureReturnsNullIfTargetPidCouldNotBeDetermined() {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('view' => array('defaultPid' => 'auto'))));
+
+               $GLOBALS['TSFE']->sys_page = $this->getMock('t3lib_pageSelect', array('enableFields'));
+               $GLOBALS['TSFE']->sys_page->expects($this->once())->method('enableFields')->will($this->returnValue(' AND enable_fields'));
+               $GLOBALS['TYPO3_DB']->expects($this->once())->method('fullQuoteStr')->will($this->returnValue('"pluginSignature"'));
+               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_SELECTgetRows')->will($this->returnValue(array()));
+               $this->assertNull($this->extensionService->getTargetPidByPlugin('ExtensionName', 'SomePlugin'));
+       }
+
+       /**
+        * @test
+        * @expectedException Tx_Extbase_Exception
+        */
+       public function getTargetPidByPluginSignatureThrowsExceptionIfMoreThanOneTargetPidsWereFound() {
+               $this->mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('view' => array('defaultPid' => 'auto'))));
+
+               $GLOBALS['TSFE']->sys_page = $this->getMock('t3lib_pageSelect', array('enableFields'));
+               $GLOBALS['TSFE']->sys_page->expects($this->once())->method('enableFields')->will($this->returnValue(' AND enable_fields'));
+               $GLOBALS['TYPO3_DB']->expects($this->once())->method('fullQuoteStr')->will($this->returnValue('"pluginSignature"'));
+               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_SELECTgetRows')->will($this->returnValue(array(array('pid' => 123), array('pid' => 124))));
+               $this->extensionService->getTargetPidByPlugin('ExtensionName', 'SomePlugin');
+       }
+
+}
+?>
\ No newline at end of file
index 4fb1cbc..b753a3e 100644 (file)
@@ -37,18 +37,12 @@ class Tx_Extbase_Tests_Unit_Utility_ExtensionTest extends tx_phpunit_testcase {
        protected $typo3ConfVars = array();
 
        /**
-        * @var t3lib_DB
-        */
-       protected $typo3DbBackup;
-
-       /**
-        * @var t3lib_fe contains a backup of the current $GLOBALS['TSFE']
+        * @var t3lib_fe contains a backup of the current $GLOBALS['TSFE']
         */
        protected $tsfeBackup;
 
        public function setUp() {
                $this->typo3ConfVars = $GLOBALS['TYPO3_CONF_VARS'];
-               $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
                $GLOBALS['TYPO3_DB'] = $this->getMock('t3lib_DB', array('fullQuoteStr', 'exec_SELECTgetRows'));
                $this->tsfeBackup = $GLOBALS['TSFE'];
                if (!isset($GLOBALS['TSFE']->tmpl)) {
@@ -83,47 +77,11 @@ class Tx_Extbase_Tests_Unit_Utility_ExtensionTest extends tx_phpunit_testcase {
                                'pluginName' => 'ThirdPlugin',
                        ),
                );
-               $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'] = array(
-                       'ExtensionName' => array(
-                               'plugins' => array(
-                                       'SomePlugin' => array(
-                                               'controllers' => array(
-                                                       'ControllerName' => array(
-                                                               'actions' => array('index', 'otherAction')
-                                                       ),
-                                               ),
-                                       ),
-                                       'ThirdPlugin' => array(
-                                               'controllers' => array(
-                                                       'ControllerName' => array(
-                                                               'actions' => array('otherAction', 'thirdAction')
-                                                       ),
-                                               ),
-                                       ),
-                               ),
-                       ),
-                       'SomeOtherExtensionName' => array(
-                               'plugins' => array(
-                                       'SecondPlugin' => array(
-                                               'controllers' => array(
-                                                       'ControllerName' => array(
-                                                               'actions' => array('index', 'otherAction')
-                                                       ),
-                                                       'SecondControllerName' => array(
-                                                               'actions' => array('someAction', 'someOtherAction'),
-                                                               'nonCacheableActions' => array('someOtherAction')
-                                                       )
-                                               ),
-                                       ),
-                               ),
-                       ),
-               );
        }
 
        public function tearDown() {
                $GLOBALS['TYPO3_CONF_VARS'] = $this->typo3ConfVars;
                $GLOBALS['TSFE'] = $this->tsfeBackup;
-               t3lib_div::purgeInstances();
        }
 
        /**
@@ -393,247 +351,6 @@ plugin.tx_myextension {
                $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
        }
 
-       /**
-        * DataProvider for getPluginNamespaceByPluginSignatureTests()
-        *
-        * @return array
-        */
-       public function getPluginNamespaceDataProvider() {
-               return array(
-                       array('SomeExtension', 'SomePlugin', 'tx_someextension_someplugin'),
-                       array('NonExistingExtension', 'SomePlugin', 'tx_nonexistingextension_someplugin'),
-                       array('Invalid', '', 'tx_invalid_'),
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider getPluginNamespaceDataProvider
-        */
-       public function getPluginNamespaceTests($extensionName, $pluginName, $expectedResult) {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array()));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $actualResult = Tx_Extbase_Utility_Extension::getPluginNamespace($extensionName, $pluginName);
-               $this->assertEquals($expectedResult, $actualResult, 'Failing for extension: "' . $extensionName . '", plugin: "' . $pluginName . '"');
-       }
-
-       /**
-        * @test
-        */
-       public function pluginNamespaceCanBeOverridden() {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->with(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'SomeExtension', 'SomePlugin')->will($this->returnValue(array('view' => array('pluginNamespace' => 'overridden_plugin_namespace'))));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $expectedResult = 'overridden_plugin_namespace';
-               $actualResult = Tx_Extbase_Utility_Extension::getPluginNamespace('SomeExtension', 'SomePlugin');
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * DataProvider for getPluginNameByActionTests()
-        *
-        * @return array
-        */
-       public function getPluginNameByActionDataProvider() {
-               return array(
-                       array('ExtensionName', 'ControllerName', 'someNonExistingAction', NULL),
-                       array('ExtensionName', 'ControllerName', 'index', 'SomePlugin'),
-                       array('ExtensionName', 'ControllerName', 'thirdAction', 'ThirdPlugin'),
-                       array('eXtEnSiOnNaMe', 'cOnTrOlLeRnAmE', 'thirdAction', NULL),
-                       array('eXtEnSiOnNaMe', 'cOnTrOlLeRnAmE', 'ThIrDaCtIoN', NULL),
-                       array('SomeOtherExtensionName', 'ControllerName', 'otherAction', 'SecondPlugin'),
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider getPluginNameByActionDataProvider
-        */
-       public function getPluginNameByActionTests($extensionName, $controllerName, $actionName, $expectedResult) {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->with(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK)->will($this->returnValue(array('view' => array('pluginNamespace' => 'overridden_plugin_namespace'))));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $actualResult = Tx_Extbase_Utility_Extension::getPluginNameByAction($extensionName, $controllerName, $actionName);
-               $this->assertEquals($expectedResult, $actualResult, 'Failing for $extensionName: "' . $extensionName . '", $controllerName: "' . $controllerName . '", $actionName: "' . $actionName . '" - ');
-       }
-
-       /**
-        * @test
-        * @expectedException Tx_Extbase_Exception
-        */
-       public function getPluginNameByActionThrowsExceptionIfMoreThanOnePluginMatches() {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->with(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK)->will($this->returnValue(array('view' => array('pluginNamespace' => 'overridden_plugin_namespace'))));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               Tx_Extbase_Utility_Extension::getPluginNameByAction('ExtensionName', 'ControllerName', 'otherAction');
-       }
-
-       /**
-        * @test
-        */
-       public function getPluginNameByActionReturnsCurrentIfItCanHandleTheActionEvenIfMoreThanOnePluginMatches() {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->with(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK)->will($this->returnValue(array('extensionName' => 'CurrentExtension', 'pluginName' => 'CurrentPlugin', 'controllerConfiguration' => array('ControllerName' => array('actions' => array('otherAction'))))));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $actualResult = Tx_Extbase_Utility_Extension::getPluginNameByAction('CurrentExtension', 'ControllerName', 'otherAction');
-               $expectedResult = 'CurrentPlugin';
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function isActionCacheableReturnsTrueByDefault() {
-               $mockConfiguration = array();
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($mockConfiguration));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->any())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $actualResult = Tx_Extbase_Utility_Extension::isActionCacheable('SomeExtension', 'SomePlugin', 'SomeController', 'someAction');
-               $this->assertTrue($actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function isActionCacheableReturnsFalseIfActionIsNotCacheable() {
-               $mockConfiguration = array(
-                       'controllerConfiguration' => array(
-                               'SomeController' => array(
-                                       'nonCacheableActions' => array('someAction')
-                               )
-                       )
-               );
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($mockConfiguration));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->any())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $actualResult = Tx_Extbase_Utility_Extension::isActionCacheable('SomeExtension', 'SomePlugin', 'SomeController', 'someAction');
-               $this->assertFalse($actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function getTargetPidByPluginSignatureReturnsNullIfConfigurationManagerIsNotInitialized() {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(NULL));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $this->assertNull(Tx_Extbase_Utility_Extension::getTargetPidByPlugin('ExtensionName', 'PluginName'));
-       }
-
-       /**
-        * @test
-        */
-       public function getTargetPidByPluginSignatureReturnsNullIfDefaultPidIsZero() {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('view' => array('defaultPid' => 0))));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $this->assertNull(Tx_Extbase_Utility_Extension::getTargetPidByPlugin('ExtensionName', 'PluginName'));
-       }
-
-       /**
-        * @test
-        */
-       public function getTargetPidByPluginSignatureReturnsTheConfiguredDefaultPid() {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('view' => array('defaultPid' => 123))));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $expectedResult = 123;
-               $actualResult = Tx_Extbase_Utility_Extension::getTargetPidByPlugin('ExtensionName', 'SomePlugin');
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function getTargetPidByPluginSignatureDeterminesTheTargetPidIfDefaultPidIsAuto() {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('view' => array('defaultPid' => 'auto'))));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $pluginSignature = 'extensionname_someplugin';
-               $GLOBALS['TSFE']->sys_page = $this->getMock('t3lib_pageSelect', array('enableFields'));
-               $GLOBALS['TSFE']->sys_page->expects($this->once())->method('enableFields')->with('tt_content')->will($this->returnValue(' AND enable_fields'));
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('fullQuoteStr')->with($pluginSignature, 'tt_content')->will($this->returnValue('"pluginSignature"'));
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_SELECTgetRows')->with(
-                       'pid',
-                       'tt_content',
-                       'list_type="pluginSignature" AND CType="list" AND enable_fields',
-                       '',
-                       ''
-               )->will($this->returnValue(array(array('pid' => '321'))));
-               $expectedResult = 321;
-               $actualResult = Tx_Extbase_Utility_Extension::getTargetPidByPlugin('ExtensionName', 'SomePlugin');
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function getTargetPidByPluginSignatureReturnsNullIfTargetPidCouldNotBeDetermined() {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('view' => array('defaultPid' => 'auto'))));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $GLOBALS['TSFE']->sys_page = $this->getMock('t3lib_pageSelect', array('enableFields'));
-               $GLOBALS['TSFE']->sys_page->expects($this->once())->method('enableFields')->will($this->returnValue(' AND enable_fields'));
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('fullQuoteStr')->will($this->returnValue('"pluginSignature"'));
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_SELECTgetRows')->will($this->returnValue(array()));
-               $this->assertNull(Tx_Extbase_Utility_Extension::getTargetPidByPlugin('ExtensionName', 'SomePlugin'));
-       }
-
-       /**
-        * @test
-        * @expectedException Tx_Extbase_Exception
-        */
-       public function getTargetPidByPluginSignatureThrowsExceptionIfMoreThanOneTargetPidsWereFound() {
-               $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface');
-               $mockConfigurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('view' => array('defaultPid' => 'auto'))));
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager');
-               $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager));
-               t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager);
-
-               $GLOBALS['TSFE']->sys_page = $this->getMock('t3lib_pageSelect', array('enableFields'));
-               $GLOBALS['TSFE']->sys_page->expects($this->once())->method('enableFields')->will($this->returnValue(' AND enable_fields'));
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('fullQuoteStr')->will($this->returnValue('"pluginSignature"'));
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_SELECTgetRows')->will($this->returnValue(array(array('pid' => 123), array('pid' => 124))));
-               Tx_Extbase_Utility_Extension::getTargetPidByPlugin('ExtensionName', 'SomePlugin');
-       }
-
 }
 
 ?>
\ No newline at end of file