Performs one of the edit section actions

@since Moodle 3.3
@param string $action
@param int $id section id
@param int $sectionreturn section to return to
@return string
166534
public static function edit_section($action, $id, $sectionreturn) {
        global $DB;
        // Validate and normalize parameters.
        $params = self::validate_parameters(self::edit_section_parameters(),
            array('action' => $action, 'id' => $id, 'sectionreturn' => $sectionreturn));
        $action = $params['action'];
        $id = $params['id'];
        $sr = $params['sectionreturn'];

        $section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST);
        $coursecontext = context_course::instance($section->course);
        self::validate_context($coursecontext);

        $rv = course_get_format($section->course)->section_action($section, $action, $sectionreturn);
        if ($rv) {
            return json_encode($rv);
        } else {
            return null;
        }
    }
718518
public function getEntryById(string $sectionHandle, string $id): JsonResponse
    {
        $request = $this->requestStack->getCurrentRequest();

        $optionsResponse = $this->preFlightOptions($request, self::ALLOWED_HTTP_METHODS);
        if ($optionsResponse) {
            return $optionsResponse;
        }

        $this->dispatcher->dispatch(
            ApiFetchEntry::NAME,
            new ApiFetchEntry($request, $sectionHandle)
        );

        if ($abort = $this->shouldAbort($request)) {
            return $abort;
        }

        try {
            $section = $this->sectionManager->readByHandle(Handle::fromString($sectionHandle));

            try {
                $this->cache->start(
                    $section->getConfig()->getFullyQualifiedClassName(),
                    $this->getFields(),
                    self::CACHE_CONTEXT_GET_ENTRY_BY_ID,
                    $id
                );
            } catch (\Psr\Cache\InvalidArgumentException $exception) {
                //
            }

            if ($this->cache->isHit()) {
                return new JsonResponse(
                    $this->cache->get(),
                    JsonResponse::HTTP_OK,
                    $this->getDefaultResponseHeaders($request)
                );
            }

            $entry = $this->readSection->read(ReadOptions::fromArray([
                ReadOptions::SECTION => $sectionHandle,
                ReadOptions::ID => (int)$id
            ]))->current();

            $responseData = $this->serialize->toArray($request, $entry);
            $jsonResponse = new JsonResponse(
                $responseData,
                JsonResponse::HTTP_OK,
                $this->getDefaultResponseHeaders($request)
            );

            $this->dispatcher->dispatch(
                ApiEntryFetched::NAME,
                new ApiEntryFetched($request, $responseData, $jsonResponse, $entry)
            );

            if ($abort = $this->shouldAbort($request)) {
                return $abort;
            }

            $this->cache->set($responseData);

            return $jsonResponse;
        } catch (\Exception $exception) {
            return $this->errorResponse($request, $exception);
        }
    }
250775
public function generatePath($action, $id = null)
    {
        if (!is_null($id)) {
            return sprintf('%s/%s/%s/%s', self::VERSION, static::PATH, $action, $id);
        }

        return sprintf('%s/%s/%s', self::VERSION, static::PATH, $action);
    }
1320042
static protected function build_section_plan($controller, $id) {

        $plan = $controller->get_plan();

        // Add the section task, responsible for outputting
        // all the section related information
        $plan->add_task(backup_factory::get_backup_section_task($controller->get_format(), $id));

        // For the given section, add as many activity tasks as necessary
        $coursemodules = backup_plan_dbops::get_modules_from_sectionid($id);
        foreach ($coursemodules as $coursemodule) {
            if (plugin_supports('mod', $coursemodule->modname, FEATURE_BACKUP_MOODLE2)) { // Check we support the format
                self::build_activity_plan($controller, $coursemodule->id);
            } else {
                // TODO: Debug information about module not supported
            }
        }
    }
1335741
public function editAction($id)
    {
        $breadcumbs = $this->container->get('bacon_breadcrumbs');

        $breadcumbs->addItem(array(
            'title' => 'Language',
            'route' => 'admin_language',
        ));

        $breadcumbs->addItem(array(
            'title' => 'Edit',
            'route' => '',
        ));

        $entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);

        if (!$entity) {

            $this->get('session')->getFlashBag()->add('message', array(
                'type' => 'error',
                'message' => 'The registry not Found',
            ));

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

        $form = $this->createForm(new LanguageFormType(), $entity);
        $deleteForm = $this->createDeleteForm($id);

        return array(
            'entity'      => $entity,
            'form'        => $form->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
38740
public function editAction($id)
        {
            /** @var User $oUser */
            $oUser = UserQuery::create()->findOneById($id);

            if (count($oUser) === 0) {
                throw $this->createNotFoundException('Unable to find User entity.');
            }

            $editForm = $this->createEditForm($oUser);
            $deleteForm = $this->createDeleteForm($id);

            // preselect Role
            $editForm->get('roles')->setData($oUser->getRole());

            return $this->render('SlashworksBackendBundle:User:edit.html.twig', array(
                'entity'      => $oUser,
                'edit_form'   => $editForm->createView(),
                'delete_form' => $deleteForm->createView(),
            ));
        }
494841
public function editAction($id = null)
    {
        try {
            return parent::editAction($id);
        } catch (\Exception $e) {
            return $this->editActionException($e);
        }
    }
596534
public static function remove_section( $id = '' ) {
		if ( ! in_array( $id, self::$sections_to_remove, true ) ) {
			self::$sections_to_remove[] = $id;
		}
	}
366219
public function editAction()
    {
        $id = $this->params()->fromRoute('id');
        $ids = [];
        if (! empty($id) && ! is_array($id)) {
            $ids = explode(',', $id);
        }
        if (empty($ids)) {
            $this->flashMessenger()->addMessage(
                $this->scTranslate('The file ID(s) was not specified.')
            );
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }

        try {
            $filesList = $this->getFileService()->getFilesList($ids);
        } catch (RuntimeException $e) {
            $this->flashMessenger()->addMessage($e->getMessage());
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }
        if ($filesList->isEmpty()) {
            $this->flashMessenger()->addMessage(
                $this->scTranslate('No files, available for editing.')
            );
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }

        $form = $this->getFileEditForm();
        $form->setAttribute(
            'action',
            $this->url()->fromRoute(
                'sc-admin/file/edit',
                ['id' => $id]
            )
        );
        $form->bind($filesList);
        if ($this->getRequest()->isPost()) {
            $form->setData($this->params()->fromPost());
            if ($form->isValid()) {
                $this->getFileService()->saveFiles($filesList);
            }
        }
        return new ViewModel([
            'form' => $form
        ]);
    }
908835
public function edit($id = null)
    {
        $role = $this->Roles->get($id, [
            'contain' => []
        ]);

        if ($this->request->is(['patch', 'post', 'put'])) {
            $role = $this->Roles->patchEntity($role, $this->request->data);
            if ($this->Roles->save($role)) {
                $this->Flash->success(__('The role has been saved.'));
                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error(__('The role could not be saved. Please, try again.'));
            }
        }

        $this->set(compact('role'));

        $this->render(Configure::read('CM.AdminRoleViews.edit'));
    }
688612
public function editAction(Request $request, $id = null)
    {
        $this->denyAccessUnlessGranted('ROLE_ADMIN');

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

        if (is_numeric($id)) {
            $locale = $em->getRepository(Locale::class)->find($id);
        } else {
            $locale = $em->getRepository(Locale::class)->findOneByLocale($id);
        }

        $form = $this->createForm(new LocaleType(), $locale);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em->persist($locale);
            $em->flush();

            $this->addFlash('success', 'Locale has been updated successfully');

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

        return $this->render('OpiferCmsBundle:Backend/Locale:edit.html.twig', [
            'locale' => $locale,
            'form' => $form->createView()
        ]);
    }
251843
public function editAction($id = null)
    {
        $request = $this->getRequest();
        $this->manager = $this->getDoctrine()->getManager();
        // the key used to lookup the template
        $templateKey = 'edit';

        $id = $request->get($this->admin->getIdParameter());
        $object = $this->admin->getObject($id);

        if (!$object) {
            throw $this->createNotFoundException(sprintf('unable to find the object with id : %s', $id));
        }

        $this->admin->checkAccess('edit', $object);

        $preResponse = $this->preEdit($request, $object);
        if ($preResponse !== null) {
            return $preResponse;
        }

        $this->admin->setSubject($object);

        /** @var $form Form */
        $form = $this->admin->getForm();
        $form->setData($object);
        $form->handleRequest($request);

        $this->handleFiles($object);

        if ($form->isSubmitted()) {
            //TODO: remove this check for 3.0
            if (method_exists($this->admin, 'preValidate')) {
                $this->admin->preValidate($object);
            }
            $isFormValid = $form->isValid();

            // persist if the form was valid and if in preview mode the preview was approved
            if ($isFormValid && (!$this->isInPreviewMode() || $this->isPreviewApproved())) {
                try {
                    $object = $this->admin->update($object);

                    if ($this->isXmlHttpRequest()) {
                        return $this->renderJson(array(
                                    'result'     => 'ok',
                                    'objectId'   => $this->admin->getNormalizedIdentifier($object),
                                    'objectName' => $this->escapeHtml($this->admin->toString($object)),
                                        ), 200, array());
                    }

                    $this->addFlash(
                        'sonata_flash_success',
                        $this->admin->trans(
                            'flash_edit_success',
                            array('%name%' => $this->escapeHtml($this->admin->toString($object))),
                            'SonataAdminBundle'
                        )
                    );

                    // redirect to edit mode
                    return $this->redirectTo($object);
                } catch (ModelManagerException $e) {
                    $this->handleModelManagerException($e);

                    $isFormValid = false;
                } catch (LockException $e) {
                    $this->addFlash('sonata_flash_error', $this->admin->trans('flash_lock_error', array(
                                '%name%'       => $this->escapeHtml($this->admin->toString($object)),
                                '%link_start%' => '<a href="' . $this->admin->generateObjectUrl('edit', $object) . '">',
                                '%link_end%'   => '</a>',
                                    ), 'SonataAdminBundle'));
                }
            }

            // show an error message if the form failed validation
            if (!$isFormValid) {
                if (!$this->isXmlHttpRequest()) {
                    $this->addFlash(
                        'sonata_flash_error',
                        $this->admin->trans(
                            'flash_edit_error',
                            array('%name%' => $this->escapeHtml($this->admin->toString($object))),
                            'SonataAdminBundle'
                        )
                    );
                }
            } elseif ($this->isPreviewRequested()) {
                // enable the preview template if the form was valid and preview was requested
                $templateKey = 'preview';
                $this->admin->getShow();
            }
        }

        $view = $form->createView();

        // set the theme for the current Admin Form
        $this->defineFormTheme($view, $this->admin->getFormTheme());

        return $this->render($this->admin->getTemplate($templateKey), array(
                    'action' => 'edit',
                    'form'   => $view,
                    'object' => $object,
                        ), null);
    }
1297448
public function edit(CommentsServiceContract $commentsService, int $id = 0): FormResponseContract
    {
        $item = $commentsService->getItemByIdForDisplay($id, [
            'columns' => ['parent_id']
        ]);

        $parentItem = ($item->parent_id)
            ? $commentsService->getItemByIdForDisplay($item->parent_id)
            : null;

        return app()->makeWith(FormResponseContract::class, [
            'data' => compact('item', 'parentItem'),
        ]);
    }
862894
public function Link($action = null)
    {
        if ($this->reportObject) {
            return $this->reportObject->getLink($action);
        }

        // Basic link to this cms section
        return parent::Link($action);
    }
790370
public function action($page, $id, $action)
    {
        $this->authorize($action, $eloquent = app('scaffold.model'));

        $response = app('scaffold.actions')->exec('action::' . $action, [$eloquent]);

        if ($response instanceof Response || $response instanceof Renderable) {
            return $response;
        }

        return back()->with(
            'messages',
            [trans('administrator::messages.action_success')]
        );
    }
211228
public function editAction($id, Request $request)
    {
        $cm = new CronManager();
        $crons = $cm->get();
        $this->addFlashFromCronManager($cm);
        $form = $this->createCronForm($crons[$id]);

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $cm->write();

            $this->addFlashFromCronManager($cm);

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

        return $this->render('@BCCCronManager:Default:edit.html.twig', array(
            'form'  => $form->createView(),
        ));
    }
968500
public function putStatus($id, $action)
    {
        try
        {
            $this->users->updateThrottleStatus($id,$action);
            return Redirect::route('cpanel.users.index')
                ->with('success', Lang::get('cpanel::throttle.success',array('action' => $action)));

        }
        catch (UserNotFoundException $e)
        {
            return Redirect::route('cpanel.users.index')
                ->with('error', $e->getMessage());
        }
        catch (\BadMethodCallException $e)
        {
            return Redirect::route('cpanel.users.index')
                ->with('error', "This method is not suported [{$action}]");
        }
    }