/** * Perform an action on a Contenttype record. * * @param Request $request The Symfony Request * @param string $contenttypeslug The content type slug * @param integer $id The content ID * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function modify(Request $request, $action, $contenttypeslug, $id) { $contenttype = $this->getContentType($contenttypeslug); if (empty($contenttype['blimp_mode']) || $contenttype['blimp_mode'] === 'local') { return parent::modify($request, $action, $contenttypeslug, $id); } if ($action === 'held') { return parent::modify($request, $action, $contenttypeslug, $id); } if ($action === 'delete') { return $this->delete($request, $contenttypeslug, $id); } if ($contenttype['blimp_mode'] === 'sync') { // Map actions to new statuses $actionStatuses = ['publish' => 'published']; // Map actions to requred permission $actionPermissions = ['publish' => 'publish']; } if (!isset($actionStatuses[$action])) { $this->flashes()->error(Trans::__('No such action for content.')); return $this->redirectToRoute('overview', ['contenttypeslug' => $contenttypeslug]); } $newStatus = $actionStatuses[$action]; $content = $this->getContent("{$contenttypeslug}/{$id}"); if (empty($content)) { $this->flashes()->error(Trans::__('No such action for content.')); return $this->redirectToRoute('overview', ['contenttypeslug' => $contenttypeslug]); } $title = $content->getTitle(); if (!$this->isAllowed("contenttype:{$contenttypeslug}:{$actionPermissions[$action]}:{$id}") || !$this->users()->isContentStatusTransitionAllowed($content['status'], $newStatus, $contenttypeslug, $id)) { $this->flashes()->error(Trans::__('You do not have the right privileges to %ACTION% that record.', ['%ACTION%' => $actionPermissions[$action]])); return $this->redirectToRoute('overview', ['contenttypeslug' => $contenttypeslug]); } if ($this->app['blimp_client.storage']->publish($content)) { $this->flashes()->info(Trans::__("Content '%title%' has been changed to '%newStatus%'", ['%title%' => $title, '%newStatus%' => $newStatus])); } else { $this->flashes()->info(Trans::__("Content '%title%' could not be modified.", ['%title%' => $title])); } return $this->redirectToRoute('overview', ['contenttypeslug' => $contenttypeslug]); }