Symfony controller action for viewing the data of a CampaignChain Activity.

@param Request $request
@param $id
@param bool $isModal Modal view yes or no?
@return mixed
@throws \Exception
548943
public function readAction(Request $request, $id, $isModal = false)
    {
        $activityService = $this->get('campaignchain.core.activity');
        $this->activity = $activityService->getActivity($id);

        if($this->parameters['equals_operation']) {
            // Get the one operation.
            $this->operations[0] = $activityService->getOperation($id);
        } else {
            throw new \Exception(
                'Multiple Operations for one Activity not implemented yet.'
            );
        }

        if($this->handler){
            return $this->handler->readAction($this->operations[0], $isModal);
        } else {
            throw new \Exception('No read handler defined.');
        }
    }
935260
public function deleteAction(Request $request, $id)
    {
        $mediaManager = $this->get('opifer.media.media_manager');
        $media = $mediaManager->getRepository()->find($id);

        $dispatcher = $this->get('event_dispatcher');
        $event = new MediaResponseEvent($media, $request);
        $dispatcher->dispatch(OpiferMediaEvents::MEDIA_CONTROLLER_DELETE, $event);

        if (null !== $event->getResponse()) {
            return $event->getResponse();
        }

        $mediaManager->remove($media);

        return $this->redirectToRoute('opifer_media_media_index');
    }
1245185
public function getAction($id, Request $request)
    {
        if ($this->getBooleanRequestParameter($request, 'tree', false, false)) {
            $collections = $this->getCollectionManager()->getTreeById(
                $id,
                $this->getRequestParameter($request, 'locale', true)
            );

            return $this->handleView(
                $this->view(
                    new CollectionRepresentation($collections, 'collections')
                )
            );
        }

        try {
            $locale = $this->getRequestParameter($request, 'locale', true);
            $depth = intval($request->get('depth', 0));
            $breadcrumb = $this->getBooleanRequestParameter($request, 'breadcrumb', false, false);
            $children = $this->getBooleanRequestParameter($request, 'children', false, false);
            $collectionManager = $this->getCollectionManager();

            // filter children
            $listRestHelper = $this->get('sulu_core.list_rest_helper');
            $limit = $request->get('limit', null);
            $offset = $this->getOffset($request, $limit);
            $search = $listRestHelper->getSearchPattern();
            $sortBy = $request->get('sortBy');
            $sortOrder = $request->get('sortOrder', 'ASC');

            $filter = [
                'limit' => $limit,
                'offset' => $offset,
                'search' => $search,
            ];

            $view = $this->responseGetById(
                $id,
                function($id) use ($locale, $collectionManager, $depth, $breadcrumb, $filter, $sortBy, $sortOrder, $children) {
                    $collection = $collectionManager->getById(
                        $id,
                        $locale,
                        $depth,
                        $breadcrumb,
                        $filter,
                        null !== $sortBy ? [$sortBy => $sortOrder] : [],
                        $children
                    );

                    if (SystemCollectionManagerInterface::COLLECTION_TYPE === $collection->getType()->getKey()) {
                        $this->get('sulu_security.security_checker')->checkPermission(
                            'sulu.media.system_collections',
                            PermissionTypes::VIEW
                        );
                    }

                    return $collection;
                }
            );
        } catch (CollectionNotFoundException $cnf) {
            $view = $this->view($cnf->toArray(), 404);
        } catch (MediaException $e) {
            $view = $this->view($e->toArray(), 400);
        }

        return $this->handleView($view);
    }
964149
public function update(Request $request, $id = null)
    {
        try {
            $application = $this->applications->save($request, $id);
            if ($request->has('theme')) {
                \Cookie::queue('soda-theme', $request->input('theme'));
                $request->session()->put('soda-theme', $request->input('theme'));
            }
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.update', ['object' => 'application']));
        }

        return redirect()->route('soda.settings.edit', $application->getKey())->with('success', trans('soda::messages.updated', ['object' => 'application']));
    }
74417
public function display($modal = "no", $ids = "") {
		if (URequest::isAjax ()) {
			$instance = $this->getModelInstance ( $ids );
			$key = OrmUtils::getFirstKeyValue ( $instance );
			$this->jquery->execOn ( "click", "._close", '$("#table-details").html("");$("#dataTable").show();' );
			$this->jquery->getOnClick ( "._edit", $this->_getBaseRoute () . "/edit/" . $modal . "/" . $key, "#frm-add-update" );
			$this->jquery->getOnClick ( "._delete", $this->_getBaseRoute () . "/delete/" . $key, "#table-messages" );

			$this->_getModelViewer ()->getModelDataElement ( $instance, $this->model, $modal );
			$this->jquery->renderView ( $this->_getFiles ()->getViewDisplay (), [ "classname" => $this->model,"instance" => $instance,"pk" => $key ] );
		} else {
			$this->jquery->execAtLast ( "$('._display[data-ajax={$ids}]').trigger('click');" );
			$this->index ();
		}
	}
1132373
public function putAction(Request $request, $id)
    {
        $locale = $this->getProductLocaleManager()->retrieveLocale($this->getUser(), $request->get('locale'));

        try {
            $attribute = $this->getManager()->save(
                $request->request->all(),
                $locale,
                $this->getUser()->getId(),
                $id
            );
            $view = $this->view($attribute, 200);
        } catch (AttributeDependencyNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 400);
        } catch (AttributeNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 404);
        } catch (MissingAttributeException $exc) {
            $exception = new MissingArgumentException(self::$entityName, $exc->getAttribute());
            $view = $this->view($exception->toArray(), 400);
        }

        return $this->handleView($view);
    }
1271004
public function detailsAction(Request $request, $id)
    {
        $manager = $this->get('opifer.content.content_manager');
        $content = $manager->getRepository()->find($id);

        $form = $this->createForm(ContentType::class, $content);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $manager->save($content);
        }

        return $this->render($this->getParameter('opifer_content.content_details_view'), [
            'content' => $content,
            'form' => $form->createView()
        ]);
    }
1256361
public function cgetAction(Request $request, $id)
    {
        try {
            if ($request->get('flat') == 'true') {
                $list = $this->getListRepresentation($request, $id);
            } else {
                $list = new CollectionRepresentation(
                    $this->getManager()->findAllByAttributeIdAndLocale($this->getLocale($request), $id),
                    self::$entityKey
                );
            }
            $view = $this->view($list, 200);
        } catch (AttributeNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 404);
        }

        return $this->handleView($view);
    }
493853
public function putAction(Request $request, $id)
    {
        try {
            $order = $this->getManager()->save(
                $request->request->all(),
                $this->getLocaleManager()->retrieveLocale($this->getUser(), $request->get('locale')),
                $this->getUser()->getId(),
                $id
            );

            $view = $this->view($order, 200);
        } catch (OrderNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 404);
        } catch (OrderDependencyNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 400);
        } catch (MissingOrderAttributeException $exc) {
            $exception = new MissingArgumentException($this->getOrderEntityName(), $exc->getAttribute());
            $view = $this->view($exception->toArray(), 400);
        } catch (OrderException $exc) {
            $exception = new RestException($exc->getMessage());
            $view = $this->view($exception->toArray(), 400);
        }

        return $this->handleView($view);
    }
59764
public function show($id,Request $request)
    {
        if($request->ajax())
        {
            return URL::to('setting/'.$id);
        }

        $setting = Setting::findOrfail($id);
        return view('setting.show',compact('setting'));
    }
279328
public function getAction(Request $request, $id)
    {
        // If a json request, let parent handle it
        if (in_array('application/json', $request->getAcceptableContentTypes())) {
            return parent::getAction($request, $id);
        }

        /** @var File $file */
        $file = $this->getModel()->find($id);

        /** @var Response $response */
        return $this->fileManager->buildGetContentResponse(
            $this->getResponse(),
            $file
        );
    }
329280
public function getTemplateAction(Request $request, $id)
    {
        $version = $request->query->get('_version');

        /** @var TemplateBlockProvider $templateBlockProvider */
        $templateBlockProvider = $this->get('opifer.content.template_block_provider');
        $template = $templateBlockProvider->getBlockOwner($id);

        /** @var Environment $environment */
        $environment = $this->get('opifer.content.block_environment');
        $environment->setObject($template);

        if (null !== $version && $this->isGranted('ROLE_ADMIN')) {
            $environment->setDraft(true);
        }

        $environment->load();

        $blocks = $environment->getRootBlocks();

        $context = SerializationContext::create();
        $context->setGroups(['Default', 'tree', 'detail']);

        $contentItem = [
            'id' => $template->getId(),
            'name' => $template->getName(),
            'display_name' => $template->getDisplayName(),
            'blocks' => $blocks,
        ];

        $json = $this->get('jms_serializer')->serialize($contentItem, 'json', $context);

        return new JsonResponse(json_decode($json, true));
    }
77903
public function editAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();
        $site = $em->getRepository(Site::class)->find($id);

        $originalDomains = new ArrayCollection();
        foreach ($site->getDomains() as $domain) {
            $originalDomains->add($domain);
        }

        $form = $this->createForm(SiteType::class, $site);
        $form->handleRequest($request);


        if ($form->isSubmitted() && $form->isValid()) {

            // Remove deleted domains
            foreach ($originalDomains as $domain) {
                if (false === $site->getDomains()->contains($domain)) {
                    $em->remove($domain);
                }
            }

            // Add new domain
            foreach ($form->getData()->getDomains() as $domain) {
                $domain->setSite($site);
            }
            $em->persist($domain);

            $em->flush();

            return $this->redirectToRoute('opifer_cms_site_edit', ['id' => $site->getId()]);
        }

        return $this->render('OpiferCmsBundle:Backend/Site:edit.html.twig', [
            'form' => $form->createView(),
            'site' => $site,
        ]);
    }
432289
public function postAction($id, Request $request)
    {
        return $this->addMediaToEntity($this->getContactEntityName(), $id, $request->get('mediaId', ''));
    }
1049684
public function postFormPostAction(Request $request, $id)
    {
        /** @var Form $form */
        $form = $this->get('opifer.form.form_manager')->getRepository()->find($id);

        if (!$form) {
            throw $this->createNotFoundException('The form could not be found');
        }

        $data = json_decode($request->getContent(), true);

        $token = $data['_token'];
        if ($this->isCsrfTokenValid($form->getName(), $token)) {
            throw new InvalidCsrfTokenException();
        }

        // Remove the token from the data array, since it's not part of the form.
        unset($data['_token']);
        // We're stuck with a legacy form structure here, which we'd like to hide on the API.
        $data = ['valueset' => ['namedvalues' => $data]];

        /** @var Post $post */
        $post = $this->get('opifer.eav.eav_manager')->initializeEntity($form->getSchema());
        $post->setForm($form);

        $postForm = $this->createForm(PostType::class, $post, ['form_id' => $id, 'csrf_protection' => false]);
        $postForm->submit($data);

        if ($postForm->isSubmitted() && $postForm->isValid()) {
            $this->get('opifer.form.post_manager')->save($post);

            return new JsonResponse(['message' => 'Success'], 201);
        }

        return new JsonResponse([
            'errors' => (string) $postForm->getErrors()
        ], 400);
    }
821299
public function cgetAction($id, Request $request)
    {
        return $this->getMultipleView(
            $this->getContactEntityName(),
            'get_contact_medias',
            $this->get('sulu_contact.contact_manager'),
            $id,
            $request
        );
    }
130477
public function updateAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('VeonikBlogBundle:Tag')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Tag entity.');
        }

        $form = $this->createForm(new TagType(), $entity);
        $form->bind($request);

        if ($form->isValid()) {
            $em->persist($entity);
            $em->flush();

            $this->getSession()->getFlashBag()->set('success', 'The tag has been updated successfully.');

            return $this->redirect($this->generateUrl('manage_tags'));
        }

        return array(
            'entity'      => $entity,
            'form'   => $form->createView(),
        );
    }