1 | <?php |
||
10 | trait DocumentTrait |
||
11 | { |
||
12 | /** |
||
13 | * Parse the document title parts. |
||
14 | * |
||
15 | * @return string[] |
||
16 | */ |
||
17 | protected function documentTitleParts() |
||
24 | |||
25 | /** |
||
26 | * Retrieve the document title separator. |
||
27 | * |
||
28 | * @return string |
||
29 | */ |
||
30 | protected function documentTitleSeparator() |
||
34 | |||
35 | /** |
||
36 | * Parse the document title separator. |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | protected function parseDocumentTitleSeparator() |
||
49 | |||
50 | /** |
||
51 | * Parse the document title. |
||
52 | * |
||
53 | * @param array $parts The document title parts. |
||
54 | * @return string The concatenated title. |
||
55 | */ |
||
56 | protected function parseDocumentTitle(array $parts) |
||
64 | |||
65 | /** |
||
66 | * Parse the document title segments. |
||
67 | * |
||
68 | * Iterates over each value in $parts passing them to |
||
69 | * {@see DocumentTrait::filterDocumentTitlePart}. |
||
70 | * If the method returns TRUE, the current value from $parts |
||
71 | * is concatenated into the title. |
||
72 | * |
||
73 | * @param array $parts The document title parts. |
||
74 | * @return array The parsed and filtered segments. |
||
75 | */ |
||
76 | protected function parseDocumentTitleParts(array $parts) |
||
94 | |||
95 | /** |
||
96 | * Parse the document title part. |
||
97 | * |
||
98 | * If you want to exclude the site name ("site") from the document title |
||
99 | * if it is present in other parts, you can use the following snippet: |
||
100 | * |
||
101 | * ```php |
||
102 | * if ($key === 'site') { |
||
103 | * foreach ($parts as $k => $v) { |
||
104 | * if ($k !== $key && strpos($v, $value) !== false) { |
||
105 | * return null; |
||
106 | * } |
||
107 | * } |
||
108 | * } |
||
109 | * ``` |
||
110 | * |
||
111 | * @param string $value The value of the current iteration. |
||
112 | * @param string $key The key/index of the current iteration. |
||
113 | * @param array $parts The document title parts. |
||
114 | * @return mixed The mutated value of the current iteration. |
||
115 | * If $value is equal to FALSE (converted to boolean; excluding "0"), it is excluded from the document title. |
||
116 | * If the method returns TRUE, the original $value is included into the document title. |
||
117 | */ |
||
118 | protected function parseDocumentTitlePart($value, $key, array $parts) |
||
122 | |||
123 | /** |
||
124 | * Retrieve the document title. |
||
125 | * |
||
126 | * @throws InvalidArgumentException If the document title structure is invalid. |
||
127 | * @return string |
||
128 | */ |
||
129 | final public function documentTitle() |
||
140 | |||
141 | /** |
||
142 | * Retrieve the site name. |
||
143 | * |
||
144 | * @return string|null |
||
145 | */ |
||
146 | abstract public function siteName(); |
||
147 | |||
148 | /** |
||
149 | * Retrieve the title of the page (from the context). |
||
150 | * |
||
151 | * @return string|null |
||
152 | */ |
||
153 | abstract public function title(); |
||
154 | |||
155 | /** |
||
156 | * Retrieve the current object relative to the context. |
||
157 | * |
||
158 | * @return \Charcoal\Model\ModelInterface |
||
159 | */ |
||
160 | abstract public function contextObject(); |
||
161 | } |
||
162 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.