src/Sulu/Bundle/SecurityBundle/Controller/GroupController.php
public function postAction(Request $request)
    {
        $name = $request->get('name');

        if (null != $name) {
            $em = $this->getDoctrine()->getManager();

            $group = new Group();
            $group->setName($name);

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

            $roles = $request->get('roles');
            if (!empty($roles)) {
                foreach ($roles as $roleData) {
                    $this->addRole($group, $roleData);
                }
            }

            $em->persist($group);
            $em->flush();

            $view = $this->view($group, 200);
        } else {
            $view = $this->view(null, 400);
        }

        return $this->handleView($view);
    }
public function postAction(Request $request)
    {
        $name = $request->get('name');

        if (null != $name) {
            $em = $this->getDoctrine()->getManager();

            $group = new Group();
            $group->setName($name);

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

            $roles = $request->get('roles');
            if (!empty($roles)) {
                foreach ($roles as $roleData) {
                    $this->addRole($group, $roleData);
                }
            }

            $em->persist($group);
            $em->flush();

            $view = $this->view($group, 200);
        } else {
            $view = $this->view(null, 400);
        }

        return $this->handleView($view);
    }
public function postAction ( Request $ request ) { $ name = $ request -> get ( 'name' ) ; if ( null != $ name ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ group = new Group ( ) ; $ group -> setName ( $ name ) ; $ this -> setParent ( $ group , $ request ) ; $ roles = $ request -> get ( 'roles' ) ; if ( ! empty ( $ roles ) ) { foreach ( $ roles as $ roleData ) { $ this -> addRole ( $ group , $ roleData ) ; } } $ em -> persist ( $ group ) ; $ em -> flush ( ) ; $ view = $ this -> view ( $ group , 200 ) ; } else { $ view = $ this -> view ( null , 400 ) ; } return $ this -> handleView ( $ view ) ; }
Creates a new group with the given data.

@param \Symfony\Component\HttpFoundation\Request $request

@throws \Sulu\Component\Rest\Exception\EntityNotFoundException

@return \Symfony\Component\HttpFoundation\Response
Creates a new group with the given data .