@@ -29,6 +29,7 @@ abstract class BaseNode implements NodeInterface
29
29
protected $ finalValidationClosures = array ();
30
30
protected $ allowOverwrite = true ;
31
31
protected $ required = false ;
32
+ protected $ deprecationMessage = null ;
32
33
protected $ equivalentValues = array ();
33
34
protected $ attributes = array ();
34
35
@@ -141,6 +142,19 @@ public function setRequired($boolean)
141
142
$ this ->required = (bool ) $ boolean ;
142
143
}
143
144
145
+ /**
146
+ * Sets this node as deprecated.
147
+ *
148
+ * You can use %node% and %path% placeholders in your message to display,
149
+ * respectively, the node name and its complete path.
150
+ *
151
+ * @param string|null $message Deprecated message
152
+ */
153
+ public function setDeprecated ($ message )
154
+ {
155
+ $ this ->deprecationMessage = $ message ;
156
+ }
157
+
144
158
/**
145
159
* Sets if this node can be overridden.
146
160
*
@@ -181,6 +195,29 @@ public function isRequired()
181
195
return $ this ->required ;
182
196
}
183
197
198
+ /**
199
+ * Checks if this node is deprecated.
200
+ *
201
+ * @return bool
202
+ */
203
+ public function isDeprecated ()
204
+ {
205
+ return null !== $ this ->deprecationMessage ;
206
+ }
207
+
208
+ /**
209
+ * Returns the deprecated message.
210
+ *
211
+ * @param string $node the configuration node name
212
+ * @param string $path the path of the node
213
+ *
214
+ * @return string
215
+ */
216
+ public function getDeprecationMessage ($ node , $ path )
217
+ {
218
+ return strtr ($ this ->deprecationMessage , array ('%node% ' => $ node , '%path% ' => $ path ));
219
+ }
220
+
184
221
/**
185
222
* Returns the name of this node.
186
223
*
0 commit comments