1 | <?php |
||
17 | trait RevisionableTrait |
||
18 | { |
||
19 | /** |
||
20 | * @var boolean $revisionEnabled |
||
21 | */ |
||
22 | protected $revisionEnabled = true; |
||
23 | |||
24 | /** |
||
25 | * The class name of the object revision model. |
||
26 | * |
||
27 | * Must be a fully-qualified PHP namespace and an implementation of |
||
28 | * {@see \Charcoal\Object\ObjectRevisionInterface}. Used by the model factory. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $objectRevisionClass = ObjectRevision::class; |
||
33 | |||
34 | /** |
||
35 | * @param boolean $enabled The (revision) enabled flag. |
||
36 | * @return RevisionableInterface Chainable |
||
37 | */ |
||
38 | public function setRevisionEnabled($enabled) |
||
43 | |||
44 | /** |
||
45 | * @return boolean |
||
46 | */ |
||
47 | public function getRevisionEnabled() |
||
48 | { |
||
49 | return $this->revisionEnabled; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Create a revision object. |
||
54 | * |
||
55 | * @return ObjectRevisionInterface |
||
56 | */ |
||
57 | public function createRevisionObject() |
||
63 | |||
64 | /** |
||
65 | * Set the class name of the object revision model. |
||
66 | * |
||
67 | * @param string $className The class name of the object revision model. |
||
68 | * @throws InvalidArgumentException If the class name is not a string. |
||
69 | * @return AbstractPropertyDisplay Chainable |
||
70 | */ |
||
71 | protected function setObjectRevisionClass($className) |
||
82 | |||
83 | /** |
||
84 | * Retrieve the class name of the object revision model. |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getObjectRevisionClass() |
||
92 | |||
93 | /** |
||
94 | * Alias of {@see self::getObjectRevisionClass()}. |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | public function objectRevisionClass() |
||
102 | |||
103 | /** |
||
104 | * @see \Charcoal\Object\ObjectRevision::create_fromObject() |
||
105 | * @return ObjectRevision |
||
106 | */ |
||
107 | public function generateRevision() |
||
118 | |||
119 | /** |
||
120 | * @see \Charcoal\Object\ObejctRevision::lastObjectRevision |
||
121 | * @return ObjectRevision |
||
122 | */ |
||
123 | public function latestRevision() |
||
130 | |||
131 | /** |
||
132 | * @see \Charcoal\Object\ObejctRevision::objectRevisionNum |
||
133 | * @param integer $revNum The revision number. |
||
134 | * @return ObjectRevision |
||
135 | */ |
||
136 | public function revisionNum($revNum) |
||
143 | |||
144 | /** |
||
145 | * Retrieves all revisions for the current objet |
||
146 | * |
||
147 | * @param callable $callback Optional object callback. |
||
148 | * @return array |
||
149 | */ |
||
150 | public function allRevisions(callable $callback = null) |
||
167 | |||
168 | /** |
||
169 | * @param integer $revNum The revision number to revert to. |
||
170 | * @throws InvalidArgumentException If revision number is invalid. |
||
171 | * @return boolean Success / Failure. |
||
172 | */ |
||
173 | public function revertToRevision($revNum) |
||
196 | |||
197 | /** |
||
198 | * Retrieve the object model factory. |
||
199 | * |
||
200 | * @return \Charcoal\Factory\FactoryInterface |
||
201 | */ |
||
202 | abstract public function modelFactory(); |
||
203 | |||
204 | /** |
||
205 | * @return \Charcoal\Model\MetadataInterface |
||
206 | */ |
||
207 | abstract public function metadata(); |
||
208 | } |
||
209 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: