Skip to content

Commit

Permalink
Update for API refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Mar 21, 2017
1 parent a19e9a2 commit 6927d35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions config/module.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[info]
version = "1.0.0-beta"
omeka_version_constraint = "^1.0.0-beta"
version = "1.0.0-beta2"
omeka_version_constraint = "^1.0.0-beta3"
name = "Custom Vocab"
description = "Describe your resources using vocabularies you create."
author = "Roy Rosenzweig Center for History & New Media"
Expand Down
18 changes: 6 additions & 12 deletions src/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ public function addAction()
$form->setData($this->params()->fromPost());
if ($form->isValid()) {
$formData = $form->getData();
$response = $this->api()->create('custom_vocabs', $formData);
if ($response->isError()) {
$form->setMessages($response->getErrors());
} else {
$response = $this->api($form)->create('custom_vocabs', $formData);
if ($response) {
$this->messenger()->addSuccess('Custom vocab created.');
return $this->redirect()->toRoute('admin/custom-vocab');
}
Expand All @@ -63,10 +61,8 @@ public function editAction()
$form->setData($this->params()->fromPost());
if ($form->isValid()) {
$formData = $form->getData();
$response = $this->api()->update('custom_vocabs', $vocab->id(), $formData);
if ($response->isError()) {
$form->setMessages($response->getErrors());
} else {
$response = $this->api($form)->update('custom_vocabs', $vocab->id(), $formData);
if ($response) {
$this->messenger()->addSuccess('Custom vocab updated.');
return $this->redirect()->toRoute('admin/custom-vocab');
}
Expand All @@ -87,10 +83,8 @@ public function deleteAction()
$form = $this->getForm(ConfirmForm::class);
$form->setData($this->getRequest()->getPost());
if ($form->isValid()) {
$response = $this->api()->delete('custom_vocabs', $this->params('id'));
if ($response->isError()) {
$this->messenger()->addError('Vocab could not be deleted');
} else {
$response = $this->api($form)->delete('custom_vocabs', $this->params('id'));
if ($response) {
$this->messenger()->addSuccess('Vocab successfully deleted');
}
} else {
Expand Down

0 comments on commit 6927d35

Please sign in to comment.