TYPO3 CMS  TYPO3_8-7
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 
49  public function run($controllerName, $actionName, array $arguments = [])
50  {
51  if (!$this->expectOutput($arguments)) {
52  return '';
53  }
54  $arguments['controller'] = ucfirst(trim($controllerName));
55  $arguments['action'] = lcfirst(trim($actionName));
56  $this->overrideGetArguments($arguments);
58  $extbaseBootstrap = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class);
59  $content = $extbaseBootstrap->run('', $this->extbaseConfiguration);
60  $this->revertGetArguments();
61  return $content;
62  }
63 
72  protected function expectOutput(array $arguments = [])
73  {
74  // no pids set
75  if (!isset($arguments['pids']) || empty($arguments['pids']) || empty($GLOBALS['BE_USER']->user['uid'])) {
76  return false;
77  }
78  $cleanedPageIds = GeneralUtility::intExplode(',', $arguments['pids'], true);
79  if (empty($cleanedPageIds)) {
80  return false;
81  }
82  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_note');
83  $count = $queryBuilder
84  ->count('uid')
85  ->from('sys_note')
86  ->where(
87  $queryBuilder->expr()->in(
88  'pid',
89  $queryBuilder->createNamedParameter($cleanedPageIds, Connection::PARAM_INT_ARRAY)
90  )
91  )
92  ->execute()
93  ->fetchColumn();
94  return (bool)$count;
95  }
96 
106  protected function overrideGetArguments(array $arguments)
107  {
108  $this->currentGetArguments = $_GET;
109  $_GET['tx_sysnote_note'] = $arguments;
110  }
111 
115  protected function revertGetArguments()
116  {
117  if (is_array($this->currentGetArguments)) {
119  }
120  }
121 }
static intExplode($delimiter, $string, $removeEmptyValues=false, $limit=0)
static makeInstance($className,... $constructorArguments)
overrideGetArguments(array $arguments)
Definition: Bootstrap.php:106
expectOutput(array $arguments=[])
Definition: Bootstrap.php:72
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']