‪TYPO3CMS  10.4
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 
24 
29 {
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 
54  protected function ‪getDatabaseRows(int $pid): array
55  {
56  $context = GeneralUtility::makeInstance(Context::class);
57  $workspaceId = $context->getPropertyFromAspect('workspace', 'id');
58  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
59  ->getQueryBuilderForTable('pages');
60  $queryBuilder->getRestrictions()
61  ->removeAll()
62  ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
63  ->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, (int)$workspaceId));
64 
65  $rows = $queryBuilder->select('*')
66  ->from('pages')
67  ->where($queryBuilder->expr()->eq(
68  ‪$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
69  $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)
70  ))
71  ->execute()
72  ->fetchAll();
73 
74  return $rows;
75  }
76 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows\addData
‪array addData(array $result)
Definition: DatabasePageLanguageOverlayRows.php:36
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows
Definition: DatabasePageLanguageOverlayRows.php:29
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪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:46
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows\getDatabaseRows
‪array getDatabaseRows(int $pid)
Definition: DatabasePageLanguageOverlayRows.php:54
‪TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction
Definition: WorkspaceRestriction.php:39