‪TYPO3CMS  11.5
DatabasePageLanguageOverlayRows.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
25 
30 {
37  public function ‪addData(array $result)
38  {
39  if ($result['effectivePid'] === 0) {
40  // No overlays for records on pid 0 and not for new pages below root
41  return $result;
42  }
43 
44  $result['pageLanguageOverlayRows'] = $this->‪getDatabaseRows((int)$result['effectivePid']);
45 
46  return $result;
47  }
48 
55  protected function ‪getDatabaseRows(int $pid): array
56  {
57  $context = GeneralUtility::makeInstance(Context::class);
58  $workspaceId = $context->getPropertyFromAspect('workspace', 'id');
59  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
60  ->getQueryBuilderForTable('pages');
61  $queryBuilder->getRestrictions()
62  ->removeAll()
63  ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
64  ->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, (int)$workspaceId));
65 
66  $rows = $queryBuilder->select('*')
67  ->from('pages')
68  ->where($queryBuilder->expr()->eq(
69  ‪$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
70  $queryBuilder->createNamedParameter($pid, ‪Connection::PARAM_INT)
71  ))
72  ->executeQuery()
73  ->fetchAllAssociative();
74 
75  return $rows;
76  }
77 }
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:49
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows\addData
‪array addData(array $result)
Definition: DatabasePageLanguageOverlayRows.php:37
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows
Definition: DatabasePageLanguageOverlayRows.php:30
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:38
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
Definition: DeletedRestriction.php:28
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows\getDatabaseRows
‪array getDatabaseRows(int $pid)
Definition: DatabasePageLanguageOverlayRows.php:55
‪TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction
Definition: WorkspaceRestriction.php:40