Gets a resource for a given id.

@param Request $request the request object
@param mixed $id the resource id

@return View

@throws NotFoundHttpException when resource not exist
325478
public function getAction(Request $request, $id)
    {
        $this->checkAccess('GET', $id);
        $resource = $this->getResourceManager()->find($id);
        $view = $this->view($resource, \FOS\RestBundle\Util\Codes::HTTP_OK);
        return $this->handleView($view);
    }
696407
public function update($id, Request $request)
    {
        $entity = $this->getEntityById($id);

        if (!$entity) {
            return $this->response(null, Response::HTTP_NOT_FOUND);
        }

        $params = $request->only($this->fillable);

        $result = $this->manager->update($entity, $params);

        if (!$result->ok()) {
            return $this->response(['errors' => $result->getSimpleErrors()], Response::HTTP_BAD_REQUEST);
        }

        return $this->response($this->serialize($result->getResource(), $request), Response::HTTP_OK);
    }
1075728
public function toggleFiltrableAction(Request $request, $id)
    {
        if (false === $request->isXmlHttpRequest()) {
            throw $this->createNotFoundException();
        }

        $isFiltrable = $this->get('admin_manager')->toggleFiltrable('EcommerceBundle:Feature', $id);

        return new Response(intval($isFiltrable), 200);
    }
208317
public function putAction(Request $request, $id)
    {
        try {
            /** @var ContactTitle $title */
            $title = $this->getDoctrine()
                ->getRepository(self::$entityName)
                ->find($id);

            if (!$title) {
                throw new EntityNotFoundException(self::$entityName, $id);
            } else {
                $name = $request->get('title');

                if (empty($name)) {
                    throw new RestException('There is no title-name for the given title');
                } else {
                    $em = $this->getDoctrine()->getManager();
                    $title->setTitle($name);

                    $em->flush();
                    $view = $this->view($title, 200);
                }
            }
        } catch (EntityNotFoundException $enfe) {
            $view = $this->view($enfe->toArray(), 404);
        } catch (RestException $exc) {
            $view = $this->view($exc->toArray(), 400);
        }

        return $this->handleView($view);
    }
1310706
public function cgetAction(Request $request)
    {
        $ids = array_filter(explode(',', $request->get('ids', '')));

        $result = $this->getCustomerManager()->findByIds($ids);

        $list = new CollectionRepresentation(
            $result,
            self::$entityKey
        );
        $view = $this->view($list, 200);

        return $this->handleView($view);
    }
466579
public function getAction(Request $request, $id)
    {
        if (null !== $request->get('fields')) {
            return $this->getContent($request, $id);
        }

        return $this->getSingleNode($request, $id);
    }
651326
public function show($id)
    {
        $modelName = $this->modelFullName;
        $model = $modelName::find($id);
        if(!$model) throw new NotFoundException('There is no Resource with id = ' . $id . ' !');
        return $model;
    }
1356464
public function edit($id,Request $request)
    {
        if($request->ajax())
        {
            return URL::to('feature/'. $id . '/edit');
        }

         $pac = array(null => 'Package providing this feature...') + Package::orderBy('id', 'desc')->pluck('name', 'id')->all();        
        $feature = Feature::findOrfail($id);
        return view('unstarter.feature.edit',compact('feature','pac'))
            ->with('task','edit')->with('itemkind', 'features');
    }
413144
public function putAction(Request $request, $id)
    {
        $jsonData = $request->getContent();
        $data = json_decode($jsonData, true);

        // Id should be taken of request uri.
        $data['id'] = $id;

        $targetGroup = $this->deserializeData(json_encode($data));
        $targetGroup = $this->getTargetGroupRepository()->save($targetGroup);
        $this->getEntityManager()->flush();

        return $this->handleView($this->view($targetGroup));
    }
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));
    }
1159164
public function viewAction(Request $request, $id)
    {
        $manager = $this->get('opifer.content.content_manager');
        $content = $manager->getRepository()->find($id);

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

        return new Response($content, 200, ['Content-Type' => 'application/json']);
    }
520982
public function formAction($id, Request $request)
    {
        if (is_null($id)) {
            throw new RouteNotFoundException();
        }

        return parent::formAction($id, $request);
    }
1089018
public function unlinkAction(Request $request, $id, $translationId)
    {

        /** @var PageInterface $page */
        $page = $this->admin->getObject($id);
        $translatedPage = $this->admin->getObject($translationId);

        if (!$page) {
            throw new NotFoundHttpException(sprintf('unable to find the Page with id : %s', $id));
        }

        if ($request->getMethod() == 'DELETE') {
            $page->removeTranslation($translatedPage);
            $translatedPage->removeTranslation($page);

            $this->admin->update($page);
            $this->admin->update($translatedPage);

            if ($this->isXmlHttpRequest()) {
                $html = $this->renderView(
                    '@NetworkingInitCms/PageAdmin/page_translation_settings.html.twig',
                    ['object' => $page, 'admin' => $this->admin]
                );

                return $this->renderJson(
                    [
                        'result' => 'ok',
                        'html' => $html,
                    ]
                );
            }

            $this->get('session')->getFlashBag()->add('sonata_flash_success', 'flash_link_success');

            return new RedirectResponse($this->admin->generateUrl('edit', ['id' => $page->getId()]));
        }

        return $this->renderWithExtraParams(
            '@NetworkingInitCms/PageAdmin/page_translation_unlink.html.twig',
            [
                'action' => 'unlink',
                'page' => $page,
                'translationId' => $translationId,
                'admin' => $this->admin,
                'translatedPage' => $translatedPage,
            ]
        );
    }
112075
public function putAction(Request $request, $id)
    {
        /** @var Group $group */
        $group = $this->getDoctrine()
            ->getRepository(static::$entityName)
            ->findGroupById($id);

        try {
            if (!$group) {
                throw new EntityNotFoundException(static::$entityName, $id);
            } else {
                $em = $this->getDoctrine()->getManager();

                $name = $request->get('name');

                $group->setName($name);

                $this->setParent($group, $request);

                if (!$this->processRoles($group, $request->get('roles', []))) {
                    throw new RestException('Could not update dependencies!');
                }

                $em->flush();
                $view = $this->view($group, 200);
            }
        } catch (EntityNotFoundException $enfe) {
            $view = $this->view($enfe->toArray(), 404);
        } catch (RestException $re) {
            $view = $this->view($re->toArray(), 400);
        }

        return $this->handleView($view);
    }
1025884
public function showAction(Request $request, $id)
    {
        $this->checkIfUserHasPermission(Permission::VIEW);

        list($parentEntity) = $this->getParentEntityDefinition($request);

        $entity = $this->getEntity($id);

        $this->getEventDispatcher()->dispatch(
            Events::PRE_CRUD_CONTROLLER_ACTION,
            new CrudControllerActionEvent($this->meta, __FUNCTION__)
        );

        try {
            $this->getCustomObjectLoader()->loadCustomObjects($entity);
        } catch (CustomObjectException $ex) {
        }

        $view = $this->getEntityToShowViewTransformer()->transform($this->meta, $entity);

        return $this->renderResponse('show', [
            'entity'        => $entity,
            'meta'          => $this->meta,
            'parent_entity' => $parentEntity,
            'view'          => $view,
        ], $request->isXmlHttpRequest());
    }
1126717
public function createByTypeAction($id, Request $request)
    {
        $contentType = $this->contentTypeManager->getContentTypeById($id);

        if ($contentType === null) {
            throw EntityNotFoundException::fromClassNameAndIdentifier(
                $this->configurationManager->getEntityClass('content_type'),
                [$id]
            );
        }

        $contentEntityClass = $this->configurationManager->getEntityClass('content');
        $content = new $contentEntityClass;
        $content->setContentType($contentType);

        $form = $this->createForm(ContentType::class, $content, [
            'action' => $this->generateUrl('sherlockode_acb_content_create_by_type', ['id' => $contentType->getId()]),
            'contentType' => $content->getContentType(),
        ]);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->om->persist($content);
            $this->om->flush();

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

        return $this->render('@SherlockodeAdvancedContent/Content/edit_content.html.twig', [
            'form' => $form->createView(),
            'is_ajax' => $request->isXmlHttpRequest(),
        ]);
    }
886079
public function editAction($id, Request $request)
    {
        $template = $this->container->get('synapse.template.orm_loader')
            ->retrieveOne(array(
                'id' => $id,
                'scope' => TemplateInterface::GLOBAL_SCOPE
            ))
        ;
        if (!$template) {
            throw new NotFoundHttpException(sprintf('No global template found for id "%s"', $id));
        }

        $form = $this->container->get('form.factory')->createNamed(
            'template',
            TemplateType::class,
            $template,
            array(
                'theme' => $request->attributes->get(
                    'synapse_theme',
                    $this->container->get('synapse')
                        ->enableDefaultTheme()
                        ->getCurrentTheme()
                ),
                'content_type' => $template->getContentType(),
                'template_type' => $template->getTemplateType(),
                'action' => $formUrl = $this->container->get('router')->generate(
                    'synapse_admin_template_edition',
                    array('id' => $template->getId())
                ),
                'method' => 'POST',
                'csrf_protection' => false,
            )
        );
        if ($request->request->has('template')) {
            $form->handleRequest($request);
            if ($form->isValid()) {
                return $this->redirect(
                    $this->container->get('router')->generate(
                        'synapse_admin_template_edition',
                        array('id' => $template->getId())
                    )
                );
            }
        }

        return $this->render('SynapseAdminBundle:Template:edit.html.twig', array(
            'template' => $template,
            'form' => $form->createView(),
        ));
    }