[CLEANUP] The correct case must be used for standard PHP types in phpdoc
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Domain / Model / CombinedRecord.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Domain\Model;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Combined record class
19 */
20 class CombinedRecord
21 {
22 /**
23 * @var string
24 */
25 protected $table;
26
27 /**
28 * @var \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
29 */
30 protected $versionRecord;
31
32 /**
33 * @var \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
34 */
35 protected $liveRecord;
36
37 /**
38 * Creates combined record object just by live-id and version-id of database record rows.
39 *
40 * @param string $table Name of the database table
41 * @param int $liveId Id of the database live-record row
42 * @param int $versionId Id of the datbase version-record row
43 * @return \TYPO3\CMS\Workspaces\Domain\Model\CombinedRecord
44 */
45 public static function create($table, $liveId, $versionId)
46 {
47 $liveRecord = DatabaseRecord::create($table, $liveId);
48 $versionRecord = DatabaseRecord::create($table, $versionId);
49 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Domain\Model\CombinedRecord::class, $table, $liveRecord, $versionRecord);
50 }
51
52 /**
53 * Creates combined record object by relevant database live-record and version-record rows.
54 *
55 * @param string $table Name of the database table
56 * @param array $liveRow The relevant datbase live-record row
57 * @param array $versionRow The relevant database version-record row
58 * @return \TYPO3\CMS\Workspaces\Domain\Model\CombinedRecord
59 */
60 public static function createFromArrays($table, array $liveRow, array $versionRow)
61 {
62 $liveRecord = DatabaseRecord::createFromArray($table, $liveRow);
63 $versionRecord = DatabaseRecord::createFromArray($table, $versionRow);
64 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Domain\Model\CombinedRecord::class, $table, $liveRecord, $versionRecord);
65 }
66
67 /**
68 * Creates this object.
69 *
70 * @param string $table
71 * @param \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $liveRecord
72 * @param \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $versionRecord
73 */
74 public function __construct($table, DatabaseRecord $liveRecord, DatabaseRecord $versionRecord)
75 {
76 $this->setTable($table);
77 $this->setLiveRecord($liveRecord);
78 $this->setVersionRecord($versionRecord);
79 }
80
81 /**
82 * Gets the name of the database table.
83 *
84 * @return string
85 */
86 public function getTable()
87 {
88 return $this->table;
89 }
90
91 /**
92 * Sets the name of the database table.
93 *
94 * @param string $table
95 */
96 public function setTable($table)
97 {
98 $this->table = $table;
99 }
100
101 /**
102 * Gets the live-record object.
103 *
104 * @return \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
105 */
106 public function getLiveRecord()
107 {
108 return $this->liveRecord;
109 }
110
111 /**
112 * Sets the live-record object.
113 *
114 * @param \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $liveRecord
115 */
116 public function setLiveRecord(DatabaseRecord $liveRecord)
117 {
118 $this->liveRecord = $liveRecord;
119 }
120
121 /**
122 * Gets the version-record object.
123 *
124 * @return \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
125 */
126 public function getVersionRecord()
127 {
128 return $this->versionRecord;
129 }
130
131 /**
132 * Sets the version-record object.
133 *
134 * @param \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $versionRecord
135 */
136 public function setVersionRecord(DatabaseRecord $versionRecord)
137 {
138 $this->versionRecord = $versionRecord;
139 }
140
141 /**
142 * Gets the id of the live-record.
143 *
144 * @return int
145 */
146 public function getLiveId()
147 {
148 return $this->getLiveRecord()->getUid();
149 }
150
151 /**
152 * Gets the id of version-record.
153 *
154 * @return int
155 */
156 public function getVersiondId()
157 {
158 return $this->getVersionRecord()->getUid();
159 }
160 }