diff --git a/Controller/RestController.php b/Controller/RestController.php
index ba7cc04..f07b7e6 100755
--- a/Controller/RestController.php
+++ b/Controller/RestController.php
@@ -86,17 +86,24 @@ protected function getModelBySubject(Request $request, $subject)
}
/**
- * Handle document PUT (update)
+ * Handle arbitrary methods with the RestHandler.
+ *
+ * Except for the PUT operation to update a document, operations are
+ * registered as workflows.
*
* @param Request $request
- * @param string $subject URL of the subject, ie: cms/simple/news/news-name
+ * @param string $subject URL of the subject, ie: /cms/simple/news/news-name
*
* @return Response
*
* @throws AccessDeniedException If the action is not allowed by the access
* checker.
+ *
+ * @see RestService::run
+ *
+ * @since 1.2
*/
- public function putDocumentAction(Request $request, $subject)
+ public function updateDocumentAction(Request $request, $subject)
{
if (!$this->accessChecker->check($request)) {
throw new AccessDeniedException();
@@ -105,7 +112,7 @@ public function putDocumentAction(Request $request, $subject)
$model = $this->getModelBySubject($request, $subject);
$type = $this->typeFactory->getTypeByObject($model);
- $result = $this->restHandler->run($request->request->all(), $type, null, RestService::HTTP_PUT);
+ $result = $this->restHandler->run($request->request->all(), $type, null, strtolower($request->getMethod()));
$view = View::create($result)->setFormat('json');
return $this->viewHandler->handle($view, $request);
@@ -138,33 +145,23 @@ public function postDocumentAction(Request $request)
return $this->viewHandler->handle($view, $request);
}
- return Response::create('The document could not be created', 500);
+ return Response::create('The document was not created', 500);
}
/**
- * Handle document deletion.
- *
- * @param Request $request
- * @param string $subject URL of the subject, ie: cms/simple/news/news-name
- *
- * @return Response
- *
- * @throws AccessDeniedException If the action is not allowed by the access
- * checker.
+ * @deprecated Use updateDocumentAction
*/
- public function deleteDocumentAction(Request $request, $subject)
+ public function putDocumentAction(Request $request, $subject)
{
- if (!$this->accessChecker->check($request)) {
- throw new AccessDeniedException();
- }
-
- $model = $this->getModelBySubject($request, $subject);
- $type = $this->typeFactory->getTypeByObject($model);
-
- $result = $this->restHandler->run($request->request->all(), $type, $subject, RestService::HTTP_DELETE);
- $view = View::create($result)->setFormat('json');
+ return self::updateDocumentAction($request, $subject);
+ }
- return $this->viewHandler->handle($view, $request);
+ /**
+ * @deprecated Use updateDocumentAction
+ */
+ public function deleteDocumentAction(Request $request, $subject)
+ {
+ return self::updateDocumentAction($request, $subject);
}
/**
diff --git a/Resources/config/routing/rest.xml b/Resources/config/routing/rest.xml
index f2980a4..30b05d1 100644
--- a/Resources/config/routing/rest.xml
+++ b/Resources/config/routing/rest.xml
@@ -4,24 +4,16 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
-
- cmf_create.rest.controller:putDocumentAction
- json
- .+
- PUT
-
-
cmf_create.rest.controller:postDocumentAction
json
POST
-
- cmf_create.rest.controller:deleteDocumentAction
+
+ cmf_create.rest.controller:updateDocumentAction
json
.+
- DELETE