@Route(
"/{id}/duplicate",
requirements={"id" = "\d+"},
name="KunstmaanNodeBundle_nodes_duplicate",
methods={"POST"}
)

@param Request $request
@param int     $id

@return RedirectResponse

@throws AccessDeniedException
548736
public function duplicateAction(Request $request, $id)
    {
        $this->init($request);
        /* @var Node $parentNode */
        $originalNode = $this->em->getRepository('KunstmaanNodeBundle:Node')
            ->find($id);

        // Check with Acl
        $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $originalNode);

        $request = $this->get('request_stack')->getCurrentRequest();

        $originalNodeTranslations = $originalNode->getNodeTranslation($this->locale, true);
        $originalRef = $originalNodeTranslations->getPublicNodeVersion()->getRef($this->em);
        $newPage = $this->get('kunstmaan_admin.clone.helper')
            ->deepCloneAndSave($originalRef);

        //set the title
        $title = $request->get('title');
        if (is_string($title) && !empty($title)) {
            $newPage->setTitle($title);
        } else {
            $newPage->setTitle('New page');
        }

        //set the parent
        $parentNodeTranslation = $originalNode->getParent()->getNodeTranslation($this->locale, true);
        $parent = $parentNodeTranslation->getPublicNodeVersion()->getRef($this->em);
        $newPage->setParent($parent);
        $this->em->persist($newPage);
        $this->em->flush();

        /* @var Node $nodeNewPage */
        $nodeNewPage = $this->em->getRepository('KunstmaanNodeBundle:Node')->createNodeFor(
            $newPage,
            $this->locale,
            $this->user
        );

        $nodeTranslation = $nodeNewPage->getNodeTranslation($this->locale, true);
        if ($newPage->isStructureNode()) {
            $nodeTranslation->setSlug('');
            $this->em->persist($nodeTranslation);
        }
        $this->em->flush();

        $this->aclManager->updateNodeAcl($originalNode, $nodeNewPage);

        $this->addFlash(
            FlashTypes::SUCCESS,
            $this->get('translator')->trans('kuma_node.admin.duplicate.flash.success')
        );

        return $this->redirect(
            $this->generateUrl('KunstmaanNodeBundle_nodes_edit', array('id' => $nodeNewPage->getId()))
        );
    }
723376
public function update(Request $request, $id)
    {
        $this->validate(
            $request,
            [
                'key' => 'required|string|unique:settings,key,' . $id,
                'value' => 'required'
            ]
        );
        $requestData = $request->all();

        $setting = Setting::findOrFail($id);
        $setting->update($requestData);

        return redirect('admin/settings')->with('flash_message', 'Setting updated!');
    }
1319696
public function batchTranslateAction(Request $request)
    {
        if ($this->admin->isGranted('ROLE_SUPER_ADMIN') === false) {
            throw new AccessDeniedException();
        }

        $form = $this->createForm('Networking\InitCmsBundle\Form\Type\PageBatchCopyType', [],
            ['locales' => $this->getParameter('networking_init_cms.page.languages')]);

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $data = $form->getData();

            /** @var PageHelper $pageHelper */
            $pageHelper = $this->container->get('networking_init_cms.helper.page_helper');

            $pages = $this->admin->getModelManager()->findBy($this->admin->getClass(), ['locale' => $data['fromLocale']]);
            /** @var PageInterface $page */
            foreach ($pages as $page) {
                $translatedLocales = $page->getTranslatedLocales();

                if (in_array($data['toLocale'], $translatedLocales)) {
                    continue;
                }
                $pageHelper->makeTranslationCopy($page, $data['toLocale']);
            }

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

        return $this->renderWithExtraParams('@NetworkingInitCms/PageAdmin/batch_page_copy.html.twig',
            ['action' => 'batchCopy', 'form' => $form->createView()]
        );
    }
109842
public function update(Request $request, $id)
    {
        $this->validate($request, [
			'title' => 'required',
			'content' => 'required'
		]);
        $requestData = $request->all();
        
        $page = Page::findOrFail($id);
        $page->update($requestData);

        return redirect('admin/pages')->with('flash_message', 'Page updated!');
    }
560696
public function editAction(Request $request, $id)
    {
        $mailingList = $this->getDoctrine()->getRepository('OpiferMailingListBundle:MailingList')->find($id);

        $form = $this->createForm(MailingListType::class, $mailingList);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->flush();

            return $this->redirectToRoute('opifer_mailing_list_mailing_list_index');
        }

        return $this->render('OpiferMailingListBundle:MailingList:edit.html.twig', [
            'form' => $form->createView(),
            'mailing_list' => $mailingList,
        ]);
    }
575810
public function handleEdit(int $id = null, array $request = [])
    {
        if ($id === null) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('users-list-page') . "?m=2");
            } else {
                return 'Redirect: ' . $this->router->generate('users-list-page') . "?m=2";
            }
        } elseif ($id === $this->core->auth()->details->id) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('users-list-page') . "?m=3");
            } else {
                return 'Redirect: ' . $this->router->generate('users-list-page') . "?m=3";
            }
        }
        $user = $this->core->api('User/' . $id, 'GET')->run();
        if ($user['headers'][0][2] === 422) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('users-list-page') . "?m=2");
            } else {
                return 'Redirect: ' . $this->router->generate('users-list-page') . "?m=2";
            }
        } elseif (($user["headers"][0][2] - 200) * ($user["headers"][0][2] - 299) > 0) {
            return $this->templates->render("500", [
                "error" => $user['response'],
                "result" => ''
            ]);
        }
        $user = $user['response'];

        if (isset($request['name']) === true && $request['name'] === '') {
            unset($request['name']);
        }
        if (isset($request['email']) === true && $request['email'] === '') {
            unset($request['email']);
        }
        if (isset($request['description']) === true && $request['description'] === '') {
            unset($request['description']);
        }
        if (isset($request['avatar']) === true && $request['avatar'] === '') {
            unset($request['avatar']);
        }

        $validator = new \Valitron\Validator($request);
        $validator->rule('optional', ['name', 'email', 'avatar', 'description']);
        $validator->rule(function ($field, $value, array $params, array $fields) {
            return is_string($value);
        }, ['name', 'description'])->message("{field} must be a string");
        $validator->rule('email', 'email');
        $validator->rule(function ($field, $value, array $params, array $fields) {
            return file_exists(rtrim(public_path(), '/') . $value) || (filter_var($value, FILTER_VALIDATE_URL) !== false);
        }, 'avatar')->message("{field} must be an external link or a local file path");
        if ($validator->validate() === false) {
            if (headers_sent() === false) {
                header('X-PHP-Response-Code: 422', true, 422);
            }
            $roles_list = $this->core->api('Role/all', 'GET')->run();
            return $this->templates->render("Main::Users/Edit", [
                "messages" => [
                    'error' => $validator->errors(),
                    'info' => '',
                    'success' => '',
                    'warning' => ''
                ],
                "user" => $user,
                "roles" => $roles_list['response']
            ]);
        }

        $response = $this->core->api('User/' . $user->id, 'PATCH')->run($request);
        if (headers_sent() === false) {
            foreach ($response["headers"] as $header) {
                header($header[0], $header[1], $header[2]);
            }
        }
        if ($response["headers"][0][2] === 422) {
            $roles_list = $this->core->api('Role/all', 'GET')->run();
            return $this->templates->render("Main::Dashboard", [
                "messages" => [
                    'error' => $response['response'],
                    'info' => '',
                    'success' => '',
                    'warning' => ''
                ],
                "user" => $user,
                "roles" => $roles_list['response']
            ]);
        } elseif (($response["headers"][0][2] - 200) * ($response["headers"][0][2] - 299) <= 0) {
            $user = $this->core->api('User/' . $id, 'GET')->run();
            $roles_list = $this->core->api('Role/all', 'GET')->run();
            return $this->templates->render("Main::Users/Edit", [
                "messages" => [
                    'error' => '',
                    'info' => '',
                    'success' => 'User details changed successfully.',
                    'warning' => ''
                ],
                "user" => $user['response'],
                "roles" => $roles_list['response']
            ]);
        } else {
            return $this->templates->render("500", [
                "error" => $response['response'],
                "result" => ''
            ]);
        }
    }
1211300
public function deleteAction(Request $request, $id)
    {
        $this->init($request);
        /* @var Node $node */
        $node = $this->em->getRepository('KunstmaanNodeBundle:Node')->find($id);

        $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_DELETE, $node);

        $nodeTranslation = $node->getNodeTranslation($this->locale, true);
        $nodeVersion = $nodeTranslation->getPublicNodeVersion();
        $page = $nodeVersion->getRef($this->em);

        $this->get('event_dispatcher')->dispatch(
            Events::PRE_DELETE,
            new NodeEvent($node, $nodeTranslation, $nodeVersion, $page)
        );

        $node->setDeleted(true);
        $this->em->persist($node);

        $children = $node->getChildren();
        $this->deleteNodeChildren($this->em, $this->user, $this->locale, $children);
        $this->em->flush();

        $event = new NodeEvent($node, $nodeTranslation, $nodeVersion, $page);
        $this->get('event_dispatcher')->dispatch(Events::POST_DELETE, $event);
        if (null === $response = $event->getResponse()) {
            $nodeParent = $node->getParent();
            // Check if we have a parent. Otherwise redirect to pages overview.
            if ($nodeParent) {
                $url = $this->get('router')->generate(
                    'KunstmaanNodeBundle_nodes_edit',
                    array('id' => $nodeParent->getId())
                );
            } else {
                $url = $this->get('router')->generate(
                    'KunstmaanNodeBundle_nodes'
                );
            }
            $response = new RedirectResponse($url);
        }

        $this->addFlash(
            FlashTypes::SUCCESS,
            $this->get('translator')->trans('kuma_node.admin.delete.flash.success')
        );

        return $response;
    }
714223
public function nodeEditAction(Request $request, $id)
    {
        $cmsNode = $this->get('cms.node');
        $node = $cmsNode->get($id);

        if (empty($node)) {
            return $this->redirect($this->generateUrl('cms_admin_structure'));
        }

        $nodeParams = $node->getParams();

        $form = $cmsNode->createForm($node);
        $propertiesFormType = $cmsNode->getPropertiesFormType($node->getModule());
        $form_properties = $this->createForm($propertiesFormType, $nodeParams);

        $form->remove('module');

        if ($request->isMethod('POST')) {
            if ($request->request->has('update')) {
                $form->handleRequest($request);
                $form_properties->handleRequest($request);

                if ($form->isValid()
                    and (// @todo отрефакторить!!!
                        (empty($nodeParams) and !$form_properties->isValid())
                        or (!empty($nodeParams) and $form_properties->isValid())
                        or (empty($nodeParams) and $form_properties->isValid())
                    )
                ) {
                    /** @var $updatedNode \SmartCore\Bundle\CMSBundle\Entity\Node */
                    $updatedNode = $form->getData();
                    $updatedNode->setParams($form_properties->getData());
                    $cmsNode->update($updatedNode);

                    $this->get('tagcache')->deleteTag('node');
                    $this->addFlash('success', 'Параметры модуля <b>'.$node->getModule().'</b> ('.$node->getId().') обновлены.');

                    if ($request->query->has('redirect_to')) {
                        return $this->get('cms.router')->redirect($updatedNode);
                    }

                    return $this->redirect($this->generateUrl('cms_admin_structure'));
                } else {
                    ld('Ошибка валидации формы');
                    ld($nodeParams);
                    ld($form_properties->isValid());
                }
            } elseif ($request->request->has('delete')) {
                $form->handleRequest($request);

                /** @var $node \SmartCore\Bundle\CMSBundle\Entity\Node */
                $node = $form->getData();
                $node
                    ->setIsDeleted(true)
                    ->setDeletedAt(new \DateTime())
                ;

                $node->getFolder()->setRouterNodeId(null);

                $this->persist($node, true);

                $this->get('tagcache')->deleteTag('node');

                $this->addFlash('success', 'Нода <b>'.$node->getModule().'</b> ('.$node->getId().') удалена.');

                if ($request->query->has('redirect_to')) {
                    return $this->get('cms.router')->redirect($node);
                }

                return $this->redirectToRoute('cms_admin_structure');
            }
        }

        return $this->render('@CMS/AdminStructure/node_edit.html.twig', [
            'allow_delete'    => true,
            'form'            => $form->createView(),
            'form_properties' => $form_properties->createView(),
            'form_properties_template' => $propertiesFormType::getTemplate(),
            'node'            => $node,
        ]);
    }
1249948
public function update(Request $request, $id)
    {
	    $rules = [
		    'titulo' => 'required|unique:categorias,titulo,'.$id,
		    'publicar' => 'required'
	    ];

        $this->validate($request, $rules);

        $url = SlugUrl($request->input('titulo'));

        $row = $this->categoriaRepo->findOrFail($id);
        $row->slug_url = $url;
        $this->categoriaRepo->update($row, $request->all());

        flash()->success('El registro se actualizó satisfactoriamente');

        return redirect()->route('admin.categorias.index');
    }
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(),
        );
    }
800440
public function deleteAction(Request $request, $id)
    {
        $language = $this->getLanguage($request);
        $webspace = $this->getWebspace($request);
        $force = $this->getBooleanRequestParameter($request, 'force', false, false);

        if (!$force) {
            $references = array_filter(
                $this->getRepository()->getReferences($id),
                function(PropertyInterface $reference) {
                    return $reference->getParent()->isNodeType('sulu:page');
                }
            );

            if (count($references) > 0) {
                $data = [
                    'structures' => [],
                    'other' => [],
                ];

                foreach ($references as $reference) {
                    $content = $this->get('sulu.content.mapper')->load(
                        $reference->getParent()->getIdentifier(),
                        $webspace,
                        $language,
                        true
                    );
                    $data['structures'][] = $content->toArray();
                }

                return $this->handleView($this->view($data, 409));
            }
        }

        $view = $this->responseDelete(
            $id,
            function($id) use ($webspace) {
                try {
                    $this->getRepository()->deleteNode($id, $webspace);
                } catch (DocumentNotFoundException $ex) {
                    throw new EntityNotFoundException('Content', $id);
                }
            }
        );

        return $this->handleView($view);
    }
198989
public function submitAction(Request $request, $id)
    {
        $form = $this->get('opifer.form.form_manager')->getRepository()->find($id);

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

        $post = $this->get('opifer.eav.eav_manager')->initializeEntity($form->getSchema());
        $post->setForm($form);

        $postForm = $this->createForm(PostType::class, $post, ['form_id' => $id]);
        $postForm->handleRequest($request);

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

            $event = new FormSubmitEvent($post);
            $this->get('event_dispatcher')->dispatch(Events::POST_FORM_SUBMIT, $event);
            
            if ($form->getRedirectUrl()) {
                return $this->redirect($form->getRedirectUrl());
            }
        }

        return $this->redirect($request->headers->get('referer'));
    }
1356848
public function update(UpdateRedirectRequest $request, $id)
    {
        $redirect = $this->redirect->findOrFail($id);
        $redirect->update($request->all());

        return redirect('admin/redirects');
    }
1117801
public function update($id,Request $request)
    {
        $package = Package::findOrfail($id);
    	
        $package->name = $request->name;
        
        $package->description = $request->description;
        
        $package->string_composer = $request->string_composer;
        $package->description_does_what = $request->description_does_what;
        $package->dashboard_URL = $request->dashboard_URL;
        $package->github_URL = $request->github_URL;

        
        $package->save();

        return redirect('package');
    }
834968
public function crudDelete(Request $request, $id)
    {
        try{
            $form = $this->createMultipleDeleteForm($request, $id);
            
            if ($form->isValid()) {
                $em = $this->getDoctrine()->getManager();
                $ids = $this->getIdsToDelete($id);
                $entities = $this->getRepository()->findById($ids);

                foreach ($entities as $entity){
                    if($entity){
                      $em->remove($entity);
                    }
                }
                
                $em->flush();
            }
            return new Response();
        }catch(\Exception $e){
          return $this->failure($e);
        }
    }
1079418
public function deleteAction(Request $request, $id)
    {
        $entity = $this->getRepository()->find($id);

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

        $em = $this->getDoctrine()->getManager();

        $this->get('session')->getFlashBag()->add('success', ucfirst($this->getEntityName()) . ' has been deleted!');

        $em->remove($entity);
        $em->flush();

        if ($request->getMethod() == "DELETE") {
            return new JsonResponse([
                'success' => true
            ]);
        } else {
            return $this->redirect($this->getRefererUrl());
        }
    }
1187545
public function update(Request $request, $id)
    {
        if ($request->input('action') == 'update_account') {
            try {
                $this->userRepositoryInterface->update($request->all(), $id);
            } catch (FormValidationException $e) {
                Flash::error($e->getMessage());

                return redirect()
                  ->route('account.edit')
                  ->withErrors($e->getErrors())
                  ->withInput();
            } catch (UsersException $e) {
                Flash::error($e->getMessage());

                return redirect()->route('dashboard.index');
            }

            Flash::success(trans('dashboard::dashboard.flash.account.success'));

            return redirect()->route('account.edit');
        }

        if ($request->input('action') == 'change_password') {
            try {
                $this->userRepositoryInterface->updatePassword($request->all());
            } catch (FormValidationException $e) {
                Flash::error($e->getMessage());

                return redirect()
                  ->route('account.edit')
                  ->withErrors($e->getErrors());
            } catch (AuthenticationException $e) {
                Flash::error(trans('dashboard::dashboard.flash.password.fail'));

                return redirect()
                  ->route('account.edit');
            }

            Flash::success(trans('dashboard::dashboard.flash.password.success'));

            return redirect()->route('account.edit');
        }
    }