[BUGFIX] Fix several typos in php comments
[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 use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19 /**
20 * Combined record class
21 */
22 class CombinedRecord
23 {
24 /**
25 * @var string
26 */
27 protected $table;
28
29 /**
30 * @var DatabaseRecord
31 */
32 protected $versionRecord;
33
34 /**
35 * @var DatabaseRecord
36 */
37 protected $liveRecord;
38
39 /**
40 * Creates combined record object just by live-id and version-id of database record rows.
41 *
42 * @param string $table Name of the database table
43 * @param int $liveId Id of the database live-record row
44 * @param int $versionId Id of the database version-record row
45 * @return CombinedRecord
46 */
47 public static function create($table, $liveId, $versionId)
48 {
49 $liveRecord = DatabaseRecord::create($table, $liveId);
50 $versionRecord = DatabaseRecord::create($table, $versionId);
51 return GeneralUtility::makeInstance(CombinedRecord::class, $table, $liveRecord, $versionRecord);
52 }
53
54 /**
55 * Creates combined record object by relevant database live-record and version-record rows.
56 *
57 * @param string $table Name of the database table
58 * @param array $liveRow The relevant database live-record row
59 * @param array $versionRow The relevant database version-record row
60 * @return CombinedRecord
61 */
62 public static function createFromArrays($table, array $liveRow, array $versionRow)
63 {
64 $liveRecord = DatabaseRecord::createFromArray($table, $liveRow);
65 $versionRecord = DatabaseRecord::createFromArray($table, $versionRow);
66 return GeneralUtility::makeInstance(CombinedRecord::class, $table, $liveRecord, $versionRecord);
67 }
68
69 /**
70 * Creates this object.
71 *
72 * @param string $table
73 * @param DatabaseRecord $liveRecord
74 * @param DatabaseRecord $versionRecord
75 */
76 public function __construct($table, DatabaseRecord $liveRecord, DatabaseRecord $versionRecord)
77 {
78 $this->setTable($table);
79 $this->setLiveRecord($liveRecord);
80 $this->setVersionRecord($versionRecord);
81 }
82
83 /**
84 * Gets the name of the database table.
85 *
86 * @return string
87 */
88 public function getTable()
89 {
90 return $this->table;
91 }
92
93 /**
94 * Sets the name of the database table.
95 *
96 * @param string $table
97 */
98 public function setTable($table)
99 {
100 $this->table = $table;
101 }
102
103 /**
104 * Gets the live-record object.
105 *
106 * @return DatabaseRecord
107 */
108 public function getLiveRecord()
109 {
110 return $this->liveRecord;
111 }
112
113 /**
114 * Sets the live-record object.
115 *
116 * @param DatabaseRecord $liveRecord
117 */
118 public function setLiveRecord(DatabaseRecord $liveRecord)
119 {
120 $this->liveRecord = $liveRecord;
121 }
122
123 /**
124 * Gets the version-record object.
125 *
126 * @return DatabaseRecord
127 */
128 public function getVersionRecord()
129 {
130 return $this->versionRecord;
131 }
132
133 /**
134 * Sets the version-record object.
135 *
136 * @param DatabaseRecord $versionRecord
137 */
138 public function setVersionRecord(DatabaseRecord $versionRecord)
139 {
140 $this->versionRecord = $versionRecord;
141 }
142
143 /**
144 * Gets the id of the live-record.
145 *
146 * @return int
147 */
148 public function getLiveId()
149 {
150 return $this->getLiveRecord()->getUid();
151 }
152
153 /**
154 * Gets the id of version-record.
155 *
156 * @return int
157 */
158 public function getVersiondId()
159 {
160 return $this->getVersionRecord()->getUid();
161 }
162 }