TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AbstractExportTestCase.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Impexp\Tests\Functional\Export;
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 
21 
26 {
30  protected $coreExtensionsToLoad = ['impexp'];
31 
35  protected $export;
36 
43  protected function setUp()
44  {
45  parent::setUp();
46 
47  $this->setUpBackendUserFromFixture(1);
48 
49  \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
50 
51  $this->export = GeneralUtility::makeInstance(\TYPO3\CMS\Impexp\Export::class);
52  $this->export->init(0, 'export');
53  }
54 
63  protected function setPageTree($pidToStart, $depth = 1)
64  {
65  $permsClause = $GLOBALS['BE_USER']->getPagePermsClause(1);
66 
68  $tree = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\PageTreeView::class);
69  $tree->init('AND ' . $permsClause);
70  $tree->tree[] = ['row' => $pidToStart];
71  $tree->buffer_idH = [];
72  if ($depth > 0) {
73  $tree->getTree($pidToStart, $depth, '');
74  }
75 
76  $idH[$pidToStart]['uid'] = $pidToStart;
77  if (!empty($tree->buffer_idH)) {
78  $idH[$pidToStart]['subrow'] = $tree->buffer_idH;
79  }
80 
81  $this->export->setPageTree($idH);
82  }
83 
91  protected function addRecordsForPid($pid, array $tables)
92  {
93  foreach ($GLOBALS['TCA'] as $table => $value) {
94  if ($table != 'pages' && (in_array($table, $tables) || in_array('_ALL', $tables))) {
95  if ($GLOBALS['BE_USER']->check('tables_select', $table) && !$GLOBALS['TCA'][$table]['ctrl']['is_static']) {
96  $orderBy = $GLOBALS['TCA'][$table]['ctrl']['sortby'] ?: $GLOBALS['TCA'][$table]['ctrl']['default_sortby'];
97 
98  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
99  ->getQueryBuilderForTable($table);
100 
101  $queryBuilder->getRestrictions()
102  ->removeAll()
103  ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
104 
105  $queryBuilder
106  ->select('*')
107  ->from($table)
108  ->where(
109  $queryBuilder->expr()->eq(
110  'pid',
111  $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)
112  )
113  );
114 
115  foreach (QueryHelper::parseOrderBy((string)$orderBy) as $orderPair) {
116  list($fieldName, $order) = $orderPair;
117  $queryBuilder->addOrderBy($fieldName, $order);
118  }
119 
120  $result = $queryBuilder->execute();
121  while ($row = $result->fetch()) {
122  $this->export->export_addRecord($table, $row);
123  }
124  }
125  }
126  }
127  }
128 }
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)