Advertisement
IchHabRecht

[TYPO3] Extbase eid bootstrap

Sep 10th, 2012
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /***************************************************************
  3.  *  Copyright notice
  4.  *
  5.  *  (c) 2011 Nicole Cordes <cordes@cps-it.de>, CPS-IT GmbH
  6.  *  All rights reserved
  7.  *
  8.  *  This script is part of the TYPO3 project. The TYPO3 project is
  9.  *  free software; you can redistribute it and/or modify
  10.  *  it under the terms of the GNU General Public License as published by
  11.  *  the Free Software Foundation; either version 3 of the License, or
  12.  *  (at your option) any later version.
  13.  *
  14.  *  The GNU General Public License can be found at
  15.  *  http://www.gnu.org/copyleft/gpl.html.
  16.  *
  17.  *  This script is distributed in the hope that it will be useful,
  18.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.  *  GNU General Public License for more details.
  21.  *
  22.  *  This copyright notice MUST APPEAR in all copies of the script!
  23.  ***************************************************************/
  24.  
  25. if (t3lib_div::_GP('field') != '') {
  26.  
  27.         // Initialise DB connection
  28.     tslib_eidtools::connectDB();
  29.  
  30.         // Get current page id and language
  31.     $pageId = (int)t3lib_div::_GP('pageid');
  32.     $language = (int)t3lib_div::_GP('L');
  33.  
  34.         // Get arguments for request
  35.     $arguments = t3lib_div::_GPmerged('tx_cpsfmp_companymainplugin');
  36.  
  37.         // Initialise TSFE object
  38.     $TSFE = t3lib_div::makeInstance('tslib_fe', $GLOBALS['TYPO3_CONF_VARS'], $pageId, 0, TRUE);
  39.     $TSFE->initFEuser();
  40.     $TSFE->initUserGroups();
  41.     $TSFE->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
  42.     $TSFE->rootLine = $TSFE->sys_page->getRootLine($pageId, '');
  43.     $TSFE->initTemplate();
  44.     $TSFE->getConfigArray();
  45.     $TSFE->includeTCA();
  46.     $TSFE->sys_language_uid = $TSFE->sys_language_content = $language;
  47.     $TSFE->newcObj();
  48.  
  49.         // Set configuration for bootstrap
  50.     $configuration = array(
  51.         'extensionName' => 'CpsFmp',
  52.         'pluginName' => 'CompanyMainPlugin',
  53.         'controllerName' => 'Company',
  54.     );
  55.     $bootstrap = t3lib_div::makeInstance('Tx_Extbase_Core_Bootstrap');
  56.     $bootstrap->cObj = $TSFE->cObj;
  57.     $bootstrap->initialize($configuration);
  58.  
  59.     $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
  60.  
  61.         // Build request
  62.     $request = $objectManager->create('Tx_Extbase_MVC_Web_Request');
  63.     $request->setControllerExtensionName($configuration['extensionName']);
  64.     $request->setPluginName($configuration['pluginName']);
  65.     $request->setControllerName($configuration['controllerName']);
  66.     $request->setControllerActionName('ajax');
  67.     $request->setArguments($arguments);
  68.  
  69.         // Get response
  70.     $response = $objectManager->create('Tx_Extbase_MVC_Web_Response');
  71.  
  72.         // Start dispatcher
  73.     $dispatcher = $objectManager->get('Tx_Extbase_MVC_Dispatcher');
  74.     $dispatcher->dispatch($request, $response);
  75.  
  76.     $response->sendHeaders();
  77.     echo $response->getContent();
  78.  
  79.     $objectManager->get('Tx_Extbase_Reflection_Service')->shutdown();
  80. }
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement