src/Sulu/Bundle/SecurityBundle/Controller/RoleSettingController.php
public function putAction(Request $request, $roleId, $key)
    {
        /** @var EntityManagerInterface $entityManager */
        $entityManager = $this->get('doctrine.orm.entity_manager');
        /** @var RoleSettingRepository $repository */
        $repository = $this->get('sulu.repository.role_setting');

        $setting = $repository->findSetting($roleId, $key);
        if (!$setting) {
            $setting = $repository->createNew();
        }

        $setting->setKey($key);
        $setting->setValue($request->get('value', []));
        $setting->setRole($entityManager->getReference(Role::class, $roleId));

        $entityManager->persist($setting);
        $entityManager->flush();

        return $this->handleView($this->view($setting->getValue()));
    }
public function putAction(Request $request, $roleId, $key)
    {
        /** @var EntityManagerInterface $entityManager */
        $entityManager = $this->get('doctrine.orm.entity_manager');
        /** @var RoleSettingRepository $repository */
        $repository = $this->get('sulu.repository.role_setting');

        $setting = $repository->findSetting($roleId, $key);
        if (!$setting) {
            $setting = $repository->createNew();
        }

        $setting->setKey($key);
        $setting->setValue($request->get('value', []));
        $setting->setRole($entityManager->getReference(Role::class, $roleId));

        $entityManager->persist($setting);
        $entityManager->flush();

        return $this->handleView($this->view($setting->getValue()));
    }
public function putAction ( Request $ request , $ roleId , $ key ) { /** @var EntityManagerInterface $entityManager */ $ entityManager = $ this -> get ( 'doctrine.orm.entity_manager' ) ; /** @var RoleSettingRepository $repository */ $ repository = $ this -> get ( 'sulu.repository.role_setting' ) ; $ setting = $ repository -> findSetting ( $ roleId , $ key ) ; if ( ! $ setting ) { $ setting = $ repository -> createNew ( ) ; } $ setting -> setKey ( $ key ) ; $ setting -> setValue ( $ request -> get ( 'value' , [ ] ) ) ; $ setting -> setRole ( $ entityManager -> getReference ( Role :: class , $ roleId ) ) ; $ entityManager -> persist ( $ setting ) ; $ entityManager -> flush ( ) ; return $ this -> handleView ( $ this -> view ( $ setting -> getValue ( ) ) ) ; }
Save role-setting with value from request body.

@param Request $request
@param int $roleId
@param string $key

@return Response
Save role - setting with value from request body .