@@ -86,17 +86,24 @@ protected function getModelBySubject(Request $request, $subject)
8686 }
8787
8888 /**
89- * Handle document PUT (update)
89+ * Handle arbitrary methods with the RestHandler.
90+ *
91+ * Except for the PUT operation to update a document, operations are
92+ * registered as workflows.
9093 *
9194 * @param Request $request
92- * @param string $subject URL of the subject, ie: cms/simple/news/news-name
95+ * @param string $subject URL of the subject, ie: / cms/simple/news/news-name
9396 *
9497 * @return Response
9598 *
9699 * @throws AccessDeniedException If the action is not allowed by the access
97100 * checker.
101+ *
102+ * @see RestService::run
103+ *
104+ * @since 1.2
98105 */
99- public function putDocumentAction (Request $ request , $ subject )
106+ public function updateDocumentAction (Request $ request , $ subject )
100107 {
101108 if (!$ this ->accessChecker ->check ($ request )) {
102109 throw new AccessDeniedException ();
@@ -105,7 +112,7 @@ public function putDocumentAction(Request $request, $subject)
105112 $ model = $ this ->getModelBySubject ($ request , $ subject );
106113 $ type = $ this ->typeFactory ->getTypeByObject ($ model );
107114
108- $ result = $ this ->restHandler ->run ($ request ->request ->all (), $ type , null , RestService:: HTTP_PUT );
115+ $ result = $ this ->restHandler ->run ($ request ->request ->all (), $ type , null , strtolower ( $ request -> getMethod ()) );
109116 $ view = View::create ($ result )->setFormat ('json ' );
110117
111118 return $ this ->viewHandler ->handle ($ view , $ request );
@@ -138,33 +145,23 @@ public function postDocumentAction(Request $request)
138145 return $ this ->viewHandler ->handle ($ view , $ request );
139146 }
140147
141- return Response::create ('The document could not be created ' , 500 );
148+ return Response::create ('The document was not created ' , 500 );
142149 }
143150
144151 /**
145- * Handle document deletion.
146- *
147- * @param Request $request
148- * @param string $subject URL of the subject, ie: cms/simple/news/news-name
149- *
150- * @return Response
151- *
152- * @throws AccessDeniedException If the action is not allowed by the access
153- * checker.
152+ * @deprecated Use updateDocumentAction
154153 */
155- public function deleteDocumentAction (Request $ request , $ subject )
154+ public function putDocumentAction (Request $ request , $ subject )
156155 {
157- if (!$ this ->accessChecker ->check ($ request )) {
158- throw new AccessDeniedException ();
159- }
160-
161- $ model = $ this ->getModelBySubject ($ request , $ subject );
162- $ type = $ this ->typeFactory ->getTypeByObject ($ model );
163-
164- $ result = $ this ->restHandler ->run ($ request ->request ->all (), $ type , $ subject , RestService::HTTP_DELETE );
165- $ view = View::create ($ result )->setFormat ('json ' );
156+ return self ::updateDocumentAction ($ request , $ subject );
157+ }
166158
167- return $ this ->viewHandler ->handle ($ view , $ request );
159+ /**
160+ * @deprecated Use updateDocumentAction
161+ */
162+ public function deleteDocumentAction (Request $ request , $ subject )
163+ {
164+ return self ::updateDocumentAction ($ request , $ subject );
168165 }
169166
170167 /**
0 commit comments