TYPO3 CMS  TYPO3_7-6
Bootstrap.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
24 class Bootstrap
25 {
30  protected $extbaseConfiguration = [
31  'vendorName' => 'TYPO3\\CMS',
32  'extensionName' => 'SysNote',
33  'pluginName' => 'Note',
34  ];
35 
40 
45 
50  {
51  $this->databaseConnection = $databaseConnection ?: $GLOBALS['TYPO3_DB'];
52  }
53 
62  public function run($controllerName, $actionName, array $arguments = [])
63  {
64  if (!$this->expectOutput($arguments)) {
65  return '';
66  }
67  $arguments['controller'] = ucfirst(trim($controllerName));
68  $arguments['action'] = lcfirst(trim($actionName));
69  $this->overrideGetArguments($arguments);
71  $extbaseBootstrap = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class);
72  $content = $extbaseBootstrap->run('', $this->extbaseConfiguration);
73  $this->revertGetArguments();
74  return $content;
75  }
76 
85  protected function expectOutput(array $arguments = [])
86  {
87  // no pids set
88  if (!isset($arguments['pids']) || empty($arguments['pids']) || empty($GLOBALS['BE_USER']->user['uid'])) {
89  return false;
90  }
91  $pidList = $this->databaseConnection->cleanIntList($arguments['pids']);
92  if (empty($pidList)) {
93  return false;
94  }
95  // check if there are records
96  return $this->databaseConnection->exec_SELECTcountRows('*', 'sys_note', 'pid IN (' . $pidList . ')' . BackendUtility::deleteClause('sys_note')) > 0;
97  }
98 
109  protected function overrideGetArguments(array $arguments)
110  {
111  $this->currentGetArguments = $_GET;
112  $_GET['tx_sysnote_note'] = $arguments;
113  }
114 
120  protected function revertGetArguments()
121  {
122  if (is_array($this->currentGetArguments)) {
124  }
125  }
126 }
__construct(DatabaseConnection $databaseConnection=null)
Definition: Bootstrap.php:49
overrideGetArguments(array $arguments)
Definition: Bootstrap.php:109
expectOutput(array $arguments=[])
Definition: Bootstrap.php:85
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static deleteClause($table, $tableAlias='')