‪TYPO3CMS  ‪main
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 {
36  public function ‪addData(array $result)
37  {
38  if ($result['effectivePid'] === 0) {
39  // No overlays for records on pid 0 and not for new pages below root
40  return $result;
41  }
42 
43  $result['pageLanguageOverlayRows'] = $this->‪getDatabaseRows((int)$result['effectivePid']);
44 
45  return $result;
46  }
47 
51  protected function ‪getDatabaseRows(int $pid): array
52  {
53  $context = GeneralUtility::makeInstance(Context::class);
54  $workspaceId = $context->getPropertyFromAspect('workspace', 'id');
55  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
56  ->getQueryBuilderForTable('pages');
57  $queryBuilder->getRestrictions()
58  ->removeAll()
59  ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
60  ->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, (int)$workspaceId));
61 
62  $rows = $queryBuilder->select('*')
63  ->from('pages')
64  ->where($queryBuilder->expr()->eq(
65  ‪$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
66  $queryBuilder->createNamedParameter($pid, ‪Connection::PARAM_INT)
67  ))
68  ->executeQuery()
69  ->fetchAllAssociative();
70 
71  return $rows;
72  }
73 }
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:52
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows\addData
‪array addData(array $result)
Definition: DatabasePageLanguageOverlayRows.php:36
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:54
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows
Definition: DatabasePageLanguageOverlayRows.php:30
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows\getDatabaseRows
‪getDatabaseRows(int $pid)
Definition: DatabasePageLanguageOverlayRows.php:51
‪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:41
‪$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:52
‪TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction
Definition: WorkspaceRestriction.php:39