Entities/Permissions/View/PermissionsView.php
public function updateView(Request $request, Response $response, $args)
    {
        // make sure there is a permission for the primary key
        if (null === $permission = $this->permissionsEntityMapper->getObjectById((int) $args[ROUTEARG_PRIMARY_KEY])) {
            return $this->databaseRecordNotFound($response, $args[ROUTEARG_PRIMARY_KEY], PermissionsTableMapper::getInstance(), 'update');
        }

        $formAction = $this->router->pathFor(SlimPostgres::getRouteName(true, $this->routePrefix, 'update', 'put'), [ROUTEARG_PRIMARY_KEY => $args[ROUTEARG_PRIMARY_KEY]]);

        /** if input set we are redisplaying after invalid form submission */
        if ($request->isPut() && isset($args[SlimPostgres::USER_INPUT_KEY])) {
            $updateForm = new PermissionUpdateForm($formAction, $this->container, $args[SlimPostgres::USER_INPUT_KEY]);
        } else {
            $updateForm = new PermissionUpdateForm($formAction, $this->container);
            $updateForm->setFieldValuesToPermission($permission);
        }

        return $this->view->render(
            $response,
            'Admin/form.php',
            [
                'title' => $this->permissionsEntityMapper->getUpdateTitle(),
                'form' => $updateForm->getForm(),
                'primaryKey' => $args[ROUTEARG_PRIMARY_KEY],
                'navigationItems' => $this->navigationItems,
                'hideFocus' => true
            ]
        );
    }
public function updateView(Request $request, Response $response, $args)
    {
        // make sure there is a permission for the primary key
        if (null === $permission = $this->permissionsEntityMapper->getObjectById((int) $args[ROUTEARG_PRIMARY_KEY])) {
            return $this->databaseRecordNotFound($response, $args[ROUTEARG_PRIMARY_KEY], PermissionsTableMapper::getInstance(), 'update');
        }

        $formAction = $this->router->pathFor(SlimPostgres::getRouteName(true, $this->routePrefix, 'update', 'put'), [ROUTEARG_PRIMARY_KEY => $args[ROUTEARG_PRIMARY_KEY]]);

        /** if input set we are redisplaying after invalid form submission */
        if ($request->isPut() && isset($args[SlimPostgres::USER_INPUT_KEY])) {
            $updateForm = new PermissionUpdateForm($formAction, $this->container, $args[SlimPostgres::USER_INPUT_KEY]);
        } else {
            $updateForm = new PermissionUpdateForm($formAction, $this->container);
            $updateForm->setFieldValuesToPermission($permission);
        }

        return $this->view->render(
            $response,
            'Admin/form.php',
            [
                'title' => $this->permissionsEntityMapper->getUpdateTitle(),
                'form' => $updateForm->getForm(),
                'primaryKey' => $args[ROUTEARG_PRIMARY_KEY],
                'navigationItems' => $this->navigationItems,
                'hideFocus' => true
            ]
        );
    }
public function updateView ( Request $ request , Response $ response , $ args ) { // make sure there is a permission for the primary key if ( null === $ permission = $ this -> permissionsEntityMapper -> getObjectById ( ( int ) $ args [ ROUTEARG_PRIMARY_KEY ] ) ) { return $ this -> databaseRecordNotFound ( $ response , $ args [ ROUTEARG_PRIMARY_KEY ] , PermissionsTableMapper :: getInstance ( ) , 'update' ) ; } $ formAction = $ this -> router -> pathFor ( SlimPostgres :: getRouteName ( true , $ this -> routePrefix , 'update' , 'put' ) , [ ROUTEARG_PRIMARY_KEY => $ args [ ROUTEARG_PRIMARY_KEY ] ] ) ; /** if input set we are redisplaying after invalid form submission */ if ( $ request -> isPut ( ) && isset ( $ args [ SlimPostgres :: USER_INPUT_KEY ] ) ) { $ updateForm = new PermissionUpdateForm ( $ formAction , $ this -> container , $ args [ SlimPostgres :: USER_INPUT_KEY ] ) ; } else { $ updateForm = new PermissionUpdateForm ( $ formAction , $ this -> container ) ; $ updateForm -> setFieldValuesToPermission ( $ permission ) ; } return $ this -> view -> render ( $ response , 'Admin/form.php' , [ 'title' => $ this -> permissionsEntityMapper -> getUpdateTitle ( ) , 'form' => $ updateForm -> getForm ( ) , 'primaryKey' => $ args [ ROUTEARG_PRIMARY_KEY ] , 'navigationItems' => $ this -> navigationItems , 'hideFocus' => true ] ) ; }
this can be called for both the initial get and the posted form if errors exist (from controller)
this can be called for both the initial get and the posted form if errors exist ( from controller )