‪TYPO3CMS  10.4
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 
19 
24 {
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 ($result['vanillaUid'] < 0) {
38  // vanillaUid points to a neighbor record in same table - get its record and its pid from there to find parent record
39  $neighborRow = $this->‪getRecordFromDatabase($result['tableName'], (int)abs($result['vanillaUid']));
40  if (!empty($neighborRow['t3ver_oid'])) {
41  $neighborRow = $this->‪getRecordFromDatabase($result['tableName'], (int)$neighborRow['t3ver_oid']);
42  }
43  $result['neighborRow'] = $neighborRow;
44  // uid of page the record is located in
45  $neighborRowPid = (int)$neighborRow['pid'];
46  if ($neighborRowPid !== 0) {
47  // Fetch the parent page record only if it is not the '0' root
48  $parentPageRow = $this->‪getRecordFromDatabase('pages', $neighborRowPid);
49  }
50  } elseif ($result['vanillaUid'] > 0) {
51  // vanillaUid points to a page uid directly
52  $parentPageRow = $this->‪getRecordFromDatabase('pages', $result['vanillaUid']);
53  }
54  } else {
55  // On "edit", the row itself has been fetched already
56  if ($result['databaseRow']['pid'] > 0) {
57  $parentPageRow = $this->‪getRecordFromDatabase('pages', $result['databaseRow']['pid']);
58  }
59  }
60  $result['parentPageRow'] = $parentPageRow;
61 
62  return $result;
63  }
64 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\AbstractDatabaseRecordProvider
Definition: AbstractDatabaseRecordProvider.php:29
‪TYPO3\CMS\Backend\Form\FormDataProvider\AbstractDatabaseRecordProvider\getRecordFromDatabase
‪array getRecordFromDatabase($tableName, $uid)
Definition: AbstractDatabaseRecordProvider.php:42
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow
Definition: DatabaseParentPageRow.php:24
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow\addData
‪array addData(array $result)
Definition: DatabaseParentPageRow.php:32