Skip to content

Instantly share code, notes, and snippets.

@IchHabRecht
Created August 21, 2013 20:33
Show Gist options
  • Save IchHabRecht/6299857 to your computer and use it in GitHub Desktop.
Save IchHabRecht/6299857 to your computer and use it in GitHub Desktop.
[TYPO3] Extbase eid bootstrap
<?php
/***************************************************************
* Copyright notice
*
* (c) 2011 Nicole Cordes <[email protected]>, CPS-IT GmbH
* 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 3 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!
***************************************************************/
if (t3lib_div::_GP('field') != '') {
// Initialise DB connection
tslib_eidtools::connectDB();
// Get current page id and language
$pageId = (int)t3lib_div::_GP('pageid');
$language = (int)t3lib_div::_GP('L');
// Get arguments for request
$arguments = t3lib_div::_GPmerged('tx_cpsfmp_companymainplugin');
// Initialise TSFE object
$TSFE = t3lib_div::makeInstance('tslib_fe', $GLOBALS['TYPO3_CONF_VARS'], $pageId, 0, TRUE);
$TSFE->initFEuser();
$TSFE->initUserGroups();
$TSFE->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
$TSFE->rootLine = $TSFE->sys_page->getRootLine($pageId, '');
$TSFE->initTemplate();
$TSFE->getConfigArray();
$TSFE->includeTCA();
$TSFE->sys_language_uid = $TSFE->sys_language_content = $language;
$TSFE->newcObj();
// Set configuration for bootstrap
$configuration = array(
'extensionName' => 'CpsFmp',
'pluginName' => 'CompanyMainPlugin',
'controllerName' => 'Company',
);
$bootstrap = t3lib_div::makeInstance('Tx_Extbase_Core_Bootstrap');
$bootstrap->cObj = $TSFE->cObj;
$bootstrap->initialize($configuration);
$objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
// Build request
$request = $objectManager->create('Tx_Extbase_MVC_Web_Request');
$request->setControllerExtensionName($configuration['extensionName']);
$request->setPluginName($configuration['pluginName']);
$request->setControllerName($configuration['controllerName']);
$request->setControllerActionName('ajax');
$request->setArguments($arguments);
// Get response
$response = $objectManager->create('Tx_Extbase_MVC_Web_Response');
// Start dispatcher
$dispatcher = $objectManager->get('Tx_Extbase_MVC_Dispatcher');
$dispatcher->dispatch($request, $response);
$response->sendHeaders();
echo $response->getContent();
$objectManager->get('Tx_Extbase_Reflection_Service')->shutdown();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment