NavigationController: Fix action unshare()

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-18 13:24:44 +02:00
parent 19ebdcfb37
commit bef5eeda93
2 changed files with 15 additions and 16 deletions

View File

@ -277,26 +277,25 @@ class NavigationController extends Controller
'onSuccess' => function ($form) use ($navigationConfigForm) { 'onSuccess' => function ($form) use ($navigationConfigForm) {
try { try {
$navigationConfigForm->unshare($form->getValue('name')); $navigationConfigForm->unshare($form->getValue('name'));
if ($navigationConfigForm->save()) {
Notification::success(sprintf(
t('Navigation item "%s" has been unshared'),
$form->getValue('name')
));
} else {
// TODO: It failed obviously to write one of the configs, so we're leaving the user in
// a inconsistent state. Luckily, it's nothing lost but possibly duplicated...
Notification::error(sprintf(
t('Failed to unshare navigation item "%s"'),
$form->getValue('name')
));
}
} catch (NotFoundError $e) { } catch (NotFoundError $e) {
throw $e; throw $e;
} catch (Exception $e) { } catch (Exception $e) {
Notification::error($e->getMessage()); Notification::error($e->getMessage());
} }
if ($navigationConfigForm->save()) {
Notification::success(sprintf(
t('Navigation item "%s" has been unshared'),
$form->getValue('name')
));
} else {
// TODO: It failed obviously to write one of the configs, so we're leaving the user in
// a inconsistent state. Luckily, it's nothing lost but possibly duplicated...
Notification::error(sprintf(
t('Failed to unshare navigation item "%s"'),
$form->getValue('name')
));
}
$redirect = $form->getValue('redirect'); $redirect = $form->getValue('redirect');
if (! empty($redirect)) { if (! empty($redirect)) {
$form->setRedirectUrl(htmlspecialchars_decode($redirect)); $form->setRedirectUrl(htmlspecialchars_decode($redirect));

View File

@ -38,8 +38,8 @@
'block', 'block',
sprintf( sprintf(
$this->translate( $this->translate(
'This is a child of the navigation item %s. You can' 'This is a child of the navigation item %1$s. You can'
. ' only unshare this item by unsharing its parent' . ' only unshare this item by unsharing %1$s'
), ),
$item->parent $item->parent
) )