Extbase:
authorBastian Waidelich <bastian@typo3.org>
Fri, 8 May 2009 10:46:23 +0000 (10:46 +0000)
committerBastian Waidelich <bastian@typo3.org>
Fri, 8 May 2009 10:46:23 +0000 (10:46 +0000)
 * improved URIFor-helper after discussion with Jochen: pageUid is required now, fallback to current page is done in link view helpers. Replaced parameter $prefixedExtensionKey by the two parameters $extensionName & $pluginName. Added $pageType parameter.
  The current signature of URIFor is:
  public function URIFor(
   $pageUid,
   $actionName = NULL,
   $arguments = array(),
   $controllerName = NULL,
   $extensionName = NULL,
   $pluginName = NULL,
   array $options = array(),
   $pageType = 0
  )
 * modified typolinkURI-helper accordingly: $pageUid is required. If $options['no_cache'] is set, cHash is disabled. $options['additionalParams'] can now be set in order to add custom arguments to the query that won't be prefixed.
 * removed obsolete Classes/Persistence/Tests directory from repository

typo3/sysext/extbase/Classes/MVC/View/Helper/URIHelper.php
typo3/sysext/extbase/Classes/Persistence/Tests/Base_testcase.php [deleted file]
typo3/sysext/extbase/Classes/Persistence/Tests/Repository_testcase.php [deleted file]

index f93dcec..49c9edd 100644 (file)
@@ -39,27 +39,33 @@ class Tx_Extbase_MVC_View_Helper_URIHelper extends Tx_Extbase_MVC_View_Helper_Ab
        /**
         * Creates an URI by making use of the typolink mechanism.
         *
+        * @param integer $pageUid uid of the target page
         * @param string $actionName Name of the action to be called
         * @param array $arguments Additional query parameters, will be "namespaced"
         * @param string $controllerName Name of the target controller
-        * @param string $prefixedExtensionKey Name of the target extension prefixed like "tx_myextension". If not set, current extension key is used
-        * @param integer $pageUid uid of the target page. If not set, the current page uid is used
+        * @param string $extensionName Name of the target extension, without underscores. If NULL current ExtensionName is used.
+        * @param string $pluginName Name of the target plugin.  If NULL current PluginName is used.
         * @param array $options Further options (usually options of the typolink configuration)
+        * @param integer $pageType type of the target page. See typolink.parameter
         * @return string the typolink URI
         */
-       public function URIFor($actionName = NULL, $arguments = array(), $controllerName = NULL, $prefixedExtensionKey = NULL, $pageUid = NULL, array $options = array()) {
+       public function URIFor($pageUid, $actionName = NULL, $arguments = array(), $controllerName = NULL, $extensionName = NULL, $pluginName = NULL, array $options = array(), $pageType = 0) {
                if ($actionName !== NULL) {
                        $arguments['action'] = $actionName;
                }
                if ($controllerName !== NULL) {
                        $arguments['controller'] = $controllerName;
                }
-               if ($prefixedExtensionKey === NULL) {
-                       $prefixedExtensionKey = 'tx_' . strtolower($this->request->getControllerExtensionName()) . '_' . strtolower($this->request->getPluginKey());
+               if ($extensionName === NULL) {
+                       $extensionName = $this->request->getControllerExtensionName();
+               }
+               if ($pluginName === NULL) {
+                       $pluginName = $this->request->getPluginKey();
                }
-               $prefixedArguments = (count($arguments) > 0) ? array($prefixedExtensionKey => $arguments) : array();
-               
-               return $this->typolinkURI($pageUid, $prefixedArguments, $options);
+               $argumentPrefix = strtolower('tx_' . $extensionName . '_' . $pluginName);
+               $prefixedArguments = (count($arguments) > 0) ? array($argumentPrefix => $arguments) : array();
+
+               return $this->typolinkURI($pageUid, $prefixedArguments, $options, $pageType);
        }
 
        /**
@@ -68,14 +74,26 @@ class Tx_Extbase_MVC_View_Helper_URIHelper extends Tx_Extbase_MVC_View_Helper_Ab
         * @param integer $pageUid uid of the target page. If not set, the current page uid is used
         * @param array $arguments query parameters
         * @param array $options Further options (usually options of the typolink configuration)
+        * @param integer $pageType type of the target page. See typolink.parameter
         * @return The URI
         */
-       public function typolinkURI($pageUid = NULL, array $arguments = array(), array $options = array()) {
+       public function typolinkURI($pageUid, array $arguments = array(), array $options = array(), $pageType = 0) {
                $typolinkConfiguration = array();
-               $typolinkConfiguration['parameter'] = $pageUid !== NULL ? $pageUid : $GLOBALS['TSFE']->id;
+               $typolinkConfiguration['parameter'] = $pageUid;
+               if ($pageType !== 0) {
+                       $typolinkConfiguration['parameter'] .= ',' . $pageType;
+               }
+               $typolinkConfiguration['additionalParams'] = '';
                if (count($arguments) > 0) {
                        $typolinkConfiguration['additionalParams'] .= '&' . http_build_query($arguments);
-                       $typolinkConfiguration['useCacheHash'] = 1;
+                       if (!isset($options['no_cache'])) {
+                               $typolinkConfiguration['useCacheHash'] = 1;
+                       }
+               }
+               if (isset($options['additionalParams'])) {
+                       $typolinkConfiguration['additionalParams'] .= $this->contentObject->stdWrap($options['additionalParams'], isset($options['additionalParams.']) ? $options['additionalParams.'] : array());
+                       unset($options['additionalParams']);
+                       unset($options['additionalParams.']);
                }
                $typolinkConfiguration = t3lib_div::array_merge_recursive_overrule($typolinkConfiguration, $options);
                return $this->contentObject->typoLink_URL($typolinkConfiguration);
diff --git a/typo3/sysext/extbase/Classes/Persistence/Tests/Base_testcase.php b/typo3/sysext/extbase/Classes/Persistence/Tests/Base_testcase.php
deleted file mode 100644 (file)
index 18803b5..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
-*  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!
-***************************************************************/
-
-require_once(t3lib_extMgm::extPath('extbase', 'class.tx_extbase_dispatcher.php'));
-
-/**
- * Base testcase for the extbase extension. Currently it only registers the autoloader.
- */
-abstract class Tx_Extbase_Base_testcase extends tx_phpunit_testcase {
-       public function __construct() {
-               parent::__construct();
-               $dispatcher = t3lib_div::makeInstance('Tx_Extbase_Dispatcher');
-               spl_autoload_register(array($dispatcher, 'autoLoadClasses'));
-       }
-}
-?>
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
-*  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!
-***************************************************************/
-
-require_once(t3lib_extMgm::extPath('extbase', 'class.tx_extbase_dispatcher.php'));
-
-/**
- * Base testcase for the extbase extension. Currently it only registers the autoloader.
- */
-abstract class Tx_Extbase_Base_testcase extends tx_phpunit_testcase {
-       public function __construct() {
-               parent::__construct();
-               $dispatcher = t3lib_div::makeInstance('Tx_Extbase_Dispatcher');
-               spl_autoload_register(array($dispatcher, 'autoLoadClasses'));
-       }
-}
-?>
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
-*  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!
-***************************************************************/
-
-require_once(t3lib_extMgm::extPath('extbase', 'class.tx_extbase_dispatcher.php'));
-
-/**
- * Base testcase for the extbase extension. Currently it only registers the autoloader.
- */
-abstract class Tx_Extbase_Base_testcase extends tx_phpunit_testcase {
-       public function __construct() {
-               parent::__construct();
-               $dispatcher = t3lib_div::makeInstance('Tx_Extbase_Dispatcher');
-               spl_autoload_register(array($dispatcher, 'autoLoadClasses'));
-       }
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Persistence/Tests/Repository_testcase.php b/typo3/sysext/extbase/Classes/Persistence/Tests/Repository_testcase.php
deleted file mode 100644 (file)
index 92422b4..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
-*  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!
-***************************************************************/
-
-require_once('Base_testcase.php');
-
-class Tx_Extbase_Persistence_Repository_testcase extends Tx_Extbase_Base_testcase {
-
-       public function __construct() {
-               require_once(t3lib_extMgm::extPath('blog_example') . 'Classes/Domain/BlogRepository.php');
-       }
-
-       public function setUp() {
-               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
-               $GLOBALS['TSFE']->expects($this->any())
-                       ->method('includeTCA')
-                       ->will($this->returnValue(NULL));
-               
-               $GLOBALS['TYPO3_DB'] = $this->getMock('tslib_DB', array('fullQuoteStr'));
-       }
-
-       public function test_FindByConditionWithPlaceholders() {
-               $repository = new Tx_BlogExample_Domain_Model_BlogRepository();
-               $repository->dataMapper = $this->getMock('Tx_Extbase_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
-               $repository->dataMapper->expects($this->once())
-                       ->method('fetch')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'), $this->equalTo('(name LIKE "foo" OR name LIKE "bar") AND (hidden = 0)'));
-               
-               $GLOBALS['TYPO3_DB']->expects($this->at(0))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('foo'))
-                       ->will($this->returnValue('"foo"'));
-
-               $GLOBALS['TYPO3_DB']->expects($this->at(1))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('bar'))
-                       ->will($this->returnValue('"bar"'));
-
-               $GLOBALS['TYPO3_DB']->expects($this->at(2))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('0'))
-                       ->will($this->returnValue('0'));
-               
-               $repository->find(array(
-                       array('name LIKE ? OR name LIKE ?', 'foo', 'bar'),
-                       array('hidden = ?', FALSE)
-                       ));
-       }
-
-       public function test_FindByConditionWithExample() {
-               $repository = new Tx_BlogExample_Domain_Model_BlogRepository();
-               $repository->dataMapper = $this->getMock('Tx_Extbase_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
-               $repository->dataMapper->expects($this->once())
-                       ->method('fetch')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'), $this->equalTo('(blog_name = "foo") AND (hidden = 0)'));
-               
-               $GLOBALS['TYPO3_DB']->expects($this->at(0))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('foo'))
-                       ->will($this->returnValue('"foo"'));
-
-               $GLOBALS['TYPO3_DB']->expects($this->at(1))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('0'))
-                       ->will($this->returnValue('0'));
-               
-               $repository->find(array(
-                       'blogName' => 'foo',
-                       'hidden' => FALSE
-               ));
-       }
-       
-       public function test_MagicFindByPropertyUsesGenericFind() {
-               $repository = $this->getMock('Tx_BlogExample_Domain_Model_BlogRepository', array('find'), array('Tx_BlogExample_Domain_Model_Blog'));
-               $repository->expects($this->once())
-                       ->method('find')
-                       ->with($this->equalTo(array('name' => 'foo')))
-                       ->will($this->returnValue(array()));
-               
-               $repository->findByName('foo');
-       }
-}
-?>
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
-*  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!
-***************************************************************/
-
-require_once('Base_testcase.php');
-
-class Tx_Extbase_Persistence_Repository_testcase extends Tx_Extbase_Base_testcase {
-
-       public function __construct() {
-               require_once(t3lib_extMgm::extPath('blog_example') . 'Classes/Domain/BlogRepository.php');
-       }
-
-       public function setUp() {
-               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
-               $GLOBALS['TSFE']->expects($this->any())
-                       ->method('includeTCA')
-                       ->will($this->returnValue(NULL));
-               
-               $GLOBALS['TYPO3_DB'] = $this->getMock('tslib_DB', array('fullQuoteStr'));
-       }
-
-       public function test_FindByConditionWithPlaceholders() {
-               $repository = new Tx_BlogExample_Domain_Model_BlogRepository();
-               $repository->dataMapper = $this->getMock('Tx_Extbase_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
-               $repository->dataMapper->expects($this->once())
-                       ->method('fetch')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'), $this->equalTo('(name LIKE "foo" OR name LIKE "bar") AND (hidden = 0)'));
-               
-               $GLOBALS['TYPO3_DB']->expects($this->at(0))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('foo'))
-                       ->will($this->returnValue('"foo"'));
-
-               $GLOBALS['TYPO3_DB']->expects($this->at(1))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('bar'))
-                       ->will($this->returnValue('"bar"'));
-
-               $GLOBALS['TYPO3_DB']->expects($this->at(2))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('0'))
-                       ->will($this->returnValue('0'));
-               
-               $repository->find(array(
-                       array('name LIKE ? OR name LIKE ?', 'foo', 'bar'),
-                       array('hidden = ?', FALSE)
-                       ));
-       }
-
-       public function test_FindByConditionWithExample() {
-               $repository = new Tx_BlogExample_Domain_Model_BlogRepository();
-               $repository->dataMapper = $this->getMock('Tx_Extbase_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
-               $repository->dataMapper->expects($this->once())
-                       ->method('fetch')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'), $this->equalTo('(blog_name = "foo") AND (hidden = 0)'));
-               
-               $GLOBALS['TYPO3_DB']->expects($this->at(0))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('foo'))
-                       ->will($this->returnValue('"foo"'));
-
-               $GLOBALS['TYPO3_DB']->expects($this->at(1))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('0'))
-                       ->will($this->returnValue('0'));
-               
-               $repository->find(array(
-                       'blogName' => 'foo',
-                       'hidden' => FALSE
-               ));
-       }
-       
-       public function test_MagicFindByPropertyUsesGenericFind() {
-               $repository = $this->getMock('Tx_BlogExample_Domain_Model_BlogRepository', array('find'), array('Tx_BlogExample_Domain_Model_Blog'));
-               $repository->expects($this->once())
-                       ->method('find')
-                       ->with($this->equalTo(array('name' => 'foo')))
-                       ->will($this->returnValue(array()));
-               
-               $repository->findByName('foo');
-       }
-}
-?>
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
-*  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!
-***************************************************************/
-
-require_once('Base_testcase.php');
-
-class Tx_Extbase_Persistence_Repository_testcase extends Tx_Extbase_Base_testcase {
-
-       public function __construct() {
-               require_once(t3lib_extMgm::extPath('blog_example') . 'Classes/Domain/BlogRepository.php');
-       }
-
-       public function setUp() {
-               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
-               $GLOBALS['TSFE']->expects($this->any())
-                       ->method('includeTCA')
-                       ->will($this->returnValue(NULL));
-               
-               $GLOBALS['TYPO3_DB'] = $this->getMock('tslib_DB', array('fullQuoteStr'));
-       }
-
-       public function test_FindByConditionWithPlaceholders() {
-               $repository = new Tx_BlogExample_Domain_Model_BlogRepository();
-               $repository->dataMapper = $this->getMock('Tx_Extbase_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
-               $repository->dataMapper->expects($this->once())
-                       ->method('fetch')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'), $this->equalTo('(name LIKE "foo" OR name LIKE "bar") AND (hidden = 0)'));
-               
-               $GLOBALS['TYPO3_DB']->expects($this->at(0))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('foo'))
-                       ->will($this->returnValue('"foo"'));
-
-               $GLOBALS['TYPO3_DB']->expects($this->at(1))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('bar'))
-                       ->will($this->returnValue('"bar"'));
-
-               $GLOBALS['TYPO3_DB']->expects($this->at(2))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('0'))
-                       ->will($this->returnValue('0'));
-               
-               $repository->find(array(
-                       array('name LIKE ? OR name LIKE ?', 'foo', 'bar'),
-                       array('hidden = ?', FALSE)
-                       ));
-       }
-
-       public function test_FindByConditionWithExample() {
-               $repository = new Tx_BlogExample_Domain_Model_BlogRepository();
-               $repository->dataMapper = $this->getMock('Tx_Extbase_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
-               $repository->dataMapper->expects($this->once())
-                       ->method('fetch')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'), $this->equalTo('(blog_name = "foo") AND (hidden = 0)'));
-               
-               $GLOBALS['TYPO3_DB']->expects($this->at(0))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('foo'))
-                       ->will($this->returnValue('"foo"'));
-
-               $GLOBALS['TYPO3_DB']->expects($this->at(1))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('0'))
-                       ->will($this->returnValue('0'));
-               
-               $repository->find(array(
-                       'blogName' => 'foo',
-                       'hidden' => FALSE
-               ));
-       }
-       
-       public function test_MagicFindByPropertyUsesGenericFind() {
-               $repository = $this->getMock('Tx_BlogExample_Domain_Model_BlogRepository', array('find'), array('Tx_BlogExample_Domain_Model_Blog'));
-               $repository->expects($this->once())
-                       ->method('find')
-                       ->with($this->equalTo(array('name' => 'foo')))
-                       ->will($this->returnValue(array()));
-               
-               $repository->findByName('foo');
-       }
-}
-?>
\ No newline at end of file