[TASK] Re-work/simplify copyright header in PHP files - Part 8
[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 * Combined record class
18 *
19 * @author Oliver Hader <oliver.hader@typo3.org>
20 */
21 class CombinedRecord {
22
23 /**
24 * @var string
25 */
26 protected $table;
27
28 /**
29 * @var \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
30 */
31 protected $versionRecord;
32
33 /**
34 * @var \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
35 */
36 protected $liveRecord;
37
38 /**
39 * Creates combined record object just by live-id and version-id of database record rows.
40 *
41 * @param string $table Name of the database table
42 * @param integer $liveId Id of the database live-record row
43 * @param integer $versionId Id of the datbase version-record row
44 * @return \TYPO3\CMS\Workspaces\Domain\Model\CombinedRecord
45 */
46 static public function create($table, $liveId, $versionId) {
47 $liveRecord = \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord::create($table, $liveId);
48 $versionRecord = \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord::create($table, $versionId);
49 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Domain\\Model\\CombinedRecord', $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 static public function createFromArrays($table, array $liveRow, array $versionRow) {
61 $liveRecord = \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord::createFromArray($table, $liveRow);
62 $versionRecord = \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord::createFromArray($table, $versionRow);
63 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Domain\\Model\\CombinedRecord', $table, $liveRecord, $versionRecord);
64 }
65
66 /**
67 * Creates this object.
68 *
69 * @param string $table
70 * @param \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $liveRecord
71 * @param \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $versionRecord
72 */
73 public function __construct($table, \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $liveRecord, \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $versionRecord) {
74 $this->setTable($table);
75 $this->setLiveRecord($liveRecord);
76 $this->setVersionRecord($versionRecord);
77 }
78
79 /**
80 * Gets the name of the database table.
81 *
82 * @return string
83 */
84 public function getTable() {
85 return $this->table;
86 }
87
88 /**
89 * Sets the name of the database table.
90 *
91 * @param string $table
92 * @return void
93 */
94 public function setTable($table) {
95 $this->table = $table;
96 }
97
98 /**
99 * Gets the live-record object.
100 *
101 * @return \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
102 */
103 public function getLiveRecord() {
104 return $this->liveRecord;
105 }
106
107 /**
108 * Sets the live-record object.
109 *
110 * @param \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $liveRecord
111 * @return void
112 */
113 public function setLiveRecord(\TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $liveRecord) {
114 $this->liveRecord = $liveRecord;
115 }
116
117 /**
118 * Gets the version-record object.
119 *
120 * @return \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
121 */
122 public function getVersionRecord() {
123 return $this->versionRecord;
124 }
125
126 /**
127 * Sets the version-record object.
128 *
129 * @param \TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $versionRecord
130 * @return void
131 */
132 public function setVersionRecord(\TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord $versionRecord) {
133 $this->versionRecord = $versionRecord;
134 }
135
136 /**
137 * Gets the id of the live-record.
138 *
139 * @return integer
140 */
141 public function getLiveId() {
142 return $this->getLiveRecord()->getUid();
143 }
144
145 /**
146 * Gets the id of version-record.
147 *
148 * @return integer
149 */
150 public function getVersiondId() {
151 return $this->getVersionRecord()->getUid();
152 }
153
154 }