Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Revert "Merge branch 'TomHAnderson-hotfix/deleteList'"
Browse files Browse the repository at this point in the history
This reverts commit 2750340, reversing
changes made to b952b35.

This reverts #7255 under master, as it introduced a BC break against
`Zend\Mvc\Controller\AbstractRestController`.
  • Loading branch information
weierophinney committed Mar 12, 2015
1 parent 97f67e0 commit ca307f4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
6 changes: 2 additions & 4 deletions library/Zend/Mvc/Controller/AbstractRestfulController.php
Expand Up @@ -116,7 +116,7 @@ public function delete($id)
*
* @return mixed
*/
public function deleteList($data)
public function deleteList()
{
$this->response->setStatusCode(405);

Expand Down Expand Up @@ -347,16 +347,14 @@ public function onDispatch(MvcEvent $e)
// DELETE
case 'delete':
$id = $this->getIdentifier($routeMatch, $request);
$data = $this->processBodyContent($request);

if ($id !== false) {
$action = 'delete';
$return = $this->delete($id);
break;
}

$action = 'deleteList';
$return = $this->deleteList($data);
$return = $this->deleteList();
break;
// GET
case 'get':
Expand Down
14 changes: 2 additions & 12 deletions tests/ZendTest/Mvc/Controller/RestfulControllerTest.php
Expand Up @@ -137,19 +137,9 @@ public function testDispatchInvokesDeleteMethodWhenNoActionPresentAndDeleteInvok

public function testDispatchInvokesDeleteListMethodWhenNoActionPresentAndDeleteInvokedWithoutIdentifier()
{
$entities = array(
array('id' => uniqid(), 'name' => __FUNCTION__),
array('id' => uniqid(), 'name' => __FUNCTION__),
array('id' => uniqid(), 'name' => __FUNCTION__),
);

$this->controller->entity = $entities;

$string = http_build_query($entities);
$this->request->setMethod('DELETE')
->setContent($string);
$this->request->setMethod('DELETE');
$result = $this->controller->dispatch($this->request, $this->response);
$this->assertEmpty($this->controller->entity);
$this->assertSame($this->response, $result);
$this->assertEquals(204, $result->getStatusCode());
$this->assertTrue($result->getHeaders()->has('X-Deleted'));
$this->assertEquals('deleteList', $this->routeMatch->getParam('action'));
Expand Down
Expand Up @@ -49,23 +49,11 @@ public function delete($id)
*
* @return \Zend\Http\Response
*/
public function deleteList($data)
public function deleteList()
{
if (is_array($this->entity)) {
foreach ($data as $row) {
foreach ($this->entity as $index => $entity) {
if ($row['id'] == $entity['id']) {
unset($this->entity[$index]);
break;
}
}
}
}

$response = $this->getResponse();
$response->setStatusCode(204);
$response->getHeaders()->addHeaderLine('X-Deleted', 'true');

return $response;
}

Expand Down

0 comments on commit ca307f4

Please sign in to comment.