Advertisement
timschoch

Multiple Extbase Plugins on same Page (PHP)

Nov 17th, 2011
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.35 KB | None | 0 0
  1. <?php
  2.  
  3. // @see http://pastebin.com/Gn08KMN0 for TypoScript Code
  4.  
  5. /*                                                                      *
  6.  *  COPYRIGHT NOTICE                                                    *
  7.  *                                                                      *
  8.  *  (c) 2011 Tim Schoch <[email protected]>                               *
  9.  *           GSTALTIG GMBH                                              *
  10.  *           All rights reserved                                        *
  11.  *                                                                      *
  12.  *  This script is part of the TYPO3 project. The TYPO3 project is      *
  13.  *  free software; you can redistribute it and/or modify                *
  14.  *  it under the terms of the GNU General Public License as published   *
  15.  *  by the Free Software Foundation; either version 2 of the License,   *
  16.  *  or (at your option) any later version.                              *
  17.  *                                                                      *
  18.  *  The GNU General Public License can be found at                      *
  19.  *  http://www.gnu.org/copyleft/gpl.html.                               *
  20.  *                                                                      *
  21.  *  This script is distributed in the hope that it will be useful,      *
  22.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of      *
  23.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
  24.  *  GNU General Public License for more details.                        *
  25.  *                                                                      *
  26.  *  This copyright notice MUST APPEAR in all copies of the script!      *
  27.  *                                                                      */
  28.  
  29. /**
  30.  * Extended RequestBuilder that allows the same Plugin to be placed on the page more then once
  31.  * if the switchableControllerActions are used to determine what actions can be displayed
  32.  *
  33.  * @package Gstbase
  34.  * @subpackage MVC\Web
  35.  */
  36. class Tx_Gstbase_MVC_Web_RequestBuilder extends Tx_Extbase_MVC_Web_RequestBuilder {
  37.  
  38.   /**
  39.    * Extends the default Method allowing the same Plugin to be placed on the page more then once
  40.    * if the switchableControllerActions are used to determine what actions can be displayed
  41.    *
  42.    * Original Description:
  43.    * Returns the current actionName extracted from given $parameters.
  44.    * If no action is specified, the defaultActionName will be returned.
  45.    * If that's not available or the specified action is not defined in the current plugin, an exception is thrown.
  46.    *
  47.    * @param $controllerName
  48.    * @param array $parameters
  49.    * @return string
  50.    * @throws t3lib_error_http_PageNotFoundException|Tx_Extbase_MVC_Exception|Tx_Extbase_MVC_Exception_InvalidActionName if the action could not be resolved
  51.    */
  52.    protected function resolveActionName($controllerName, array $parameters) {
  53.     try{
  54.       return parent::resolveActionName( $controllerName, $parameters );
  55.     }
  56.     catch( Exception $e ) {
  57.         // catch «not allowed by this plugin» Exception only
  58.       if( $e instanceof Tx_Extbase_MVC_Exception_InvalidActionName ) {
  59.         unset( $parameters['action'] );
  60.         return parent::resolveActionName( $controllerName, $parameters );
  61.       }
  62.         // forward other exceptions
  63.       else {
  64.         throw $e;
  65.       }
  66.     }
  67.   }
  68. }
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement