1 | <?php |
||
20 | trait BlogObject |
||
21 | { |
||
22 | /** |
||
23 | * @return DataList |
||
24 | */ |
||
25 | public function BlogPosts() |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | public function getCMSFields() |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | * @return ValidationResult |
||
56 | */ |
||
57 | public function validate() |
||
76 | |||
77 | /** |
||
78 | * Returns a relative link to this category. |
||
79 | * |
||
80 | * @return string |
||
81 | */ |
||
82 | public function getLink() |
||
90 | |||
91 | /** |
||
92 | * Inherits from the parent blog or can be overwritten using a DataExtension. |
||
93 | * |
||
94 | * @param null|Member $member |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | public function canView($member = null) |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function canCreate($member = null, $context = array()) |
||
124 | |||
125 | /** |
||
126 | * Inherits from the parent blog or can be overwritten using a DataExtension. |
||
127 | * |
||
128 | * @param null|Member $member |
||
129 | * |
||
130 | * @return bool |
||
131 | */ |
||
132 | public function canDelete($member = null) |
||
142 | |||
143 | /** |
||
144 | * Inherits from the parent blog or can be overwritten using a DataExtension. |
||
145 | * |
||
146 | * @param null|Member $member |
||
147 | * |
||
148 | * @return bool |
||
149 | */ |
||
150 | public function canEdit($member = null) |
||
160 | |||
161 | /** |
||
162 | * {@inheritdoc} |
||
163 | */ |
||
164 | protected function onBeforeWrite() |
||
171 | |||
172 | /** |
||
173 | * Generates a unique URLSegment from the title. |
||
174 | * |
||
175 | * @param int $increment |
||
176 | * |
||
177 | * @return string |
||
178 | */ |
||
179 | public function generateURLSegment($increment = 0) |
||
196 | |||
197 | /** |
||
198 | * Looks for objects o the same type and the same value by the given Field |
||
199 | * |
||
200 | * @param string $field E.g. URLSegment or Title |
||
201 | * @return DataList |
||
202 | */ |
||
203 | protected function getDuplicatesByField($field) |
||
219 | |||
220 | /** |
||
221 | * This returns the url segment for the listing page. |
||
222 | * eg. 'categories' in /my-blog/categories/category-url |
||
223 | * |
||
224 | * This is not editable at the moment, but a method is being used incase we want |
||
225 | * to make it editable in the future. We can use this method to provide logic |
||
226 | * without replacing multiple areas of the code base. We're also not being opinionated |
||
227 | * about how the segment should be obtained at the moment and allowing for the |
||
228 | * implementation to decide. |
||
229 | * |
||
230 | * @return string |
||
231 | */ |
||
232 | abstract protected function getListUrlSegment(); |
||
233 | |||
234 | /** |
||
235 | * Returns an error message for this object when it tries to write a duplicate. |
||
236 | * |
||
237 | * @return string |
||
238 | */ |
||
239 | abstract protected function getDuplicateError(); |
||
240 | } |
||
241 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.