public function handleDelete($id) { if (($entity = $this->itemRepository->find($id)) === NULL) { throw new BadRequestException(); } $this->itemRepository->delete($entity); if (!$this->presenter->isAjax()) { $this->redirect('this', array('id' => NULL)); } $this->presenter->payload->url = $this->link('this', array('id' => NULL)); $this->invalidateControl('view'); }