‪TYPO3CMS  ‪main
DatabaseParentPageRow.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 
20 
25 {
32  public function ‪addData(array $result)
33  {
34  // $parentPageRow end up NULL if a record added or edited on root node
35  $parentPageRow = null;
36  if ($result['command'] === 'new') {
37  if (‪MathUtility::canBeInterpretedAsInteger($result['vanillaUid'])) {
38  $vanillaUid = (int)$result['vanillaUid'];
39  if ($vanillaUid < 0) {
40  // vanillaUid points to a neighbor record in same table - get its record and its pid from there to find parent record
41  $neighborRow = $this->‪getRecordFromDatabase($result['tableName'], (int)abs($vanillaUid));
42  if (!empty($neighborRow['t3ver_oid'])) {
43  $neighborRow = $this->‪getRecordFromDatabase($result['tableName'], (int)$neighborRow['t3ver_oid']);
44  }
45  $result['neighborRow'] = $neighborRow;
46  // uid of page the record is located in
47  $neighborRowPid = (int)$neighborRow['pid'];
48  if ($neighborRowPid !== 0) {
49  // Fetch the parent page record only if it is not the '0' root
50  $parentPageRow = $this->‪getRecordFromDatabase('pages', $neighborRowPid);
51  }
52  } elseif ($vanillaUid > 0) {
53  // vanillaUid points to a page uid directly
54  $parentPageRow = $this->‪getRecordFromDatabase('pages', $vanillaUid);
55  }
56  }
57  } elseif ($result['databaseRow']['pid'] > 0) {
58  // On "edit", the row itself has been fetched already
59  $parentPageRow = $this->‪getRecordFromDatabase('pages', (int)$result['databaseRow']['pid']);
60  }
61  $result['parentPageRow'] = $parentPageRow;
62 
63  return $result;
64  }
65 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\AbstractDatabaseRecordProvider
Definition: AbstractDatabaseRecordProvider.php:31
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger(mixed $var)
Definition: MathUtility.php:69
‪TYPO3\CMS\Backend\Form\FormDataProvider\AbstractDatabaseRecordProvider\getRecordFromDatabase
‪array getRecordFromDatabase($tableName, $uid)
Definition: AbstractDatabaseRecordProvider.php:44
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:24
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow
Definition: DatabaseParentPageRow.php:25
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow\addData
‪array addData(array $result)
Definition: DatabaseParentPageRow.php:32