module/Paragraph/src/Grid/Paragraph/Controller/ChangeLayoutController.php
public function localAction()
    {
        $success = null;
        $request = $this->getRequest();
        $data    = $request->getPost();
        $form    = $this->getServiceLocator()
                        ->get( 'Form' )
                        ->create( 'Grid\Paragraph\ChangeLayout\Local', array(
                            'returnUri' => $request->getQuery( 'returnUri' ),
                        ) );

        $form->setAttribute(
            'action',
            $this->url()
                 ->fromRoute( 'Grid\Paragraph\ChangeLayout\Local', array(
                     'locale'       => (string) $this->locale(),
                     'paragraphId'  => $this->paragraphId,
                     'returnUri'    => $request->getQuery( 'returnUri' ),
                 ) )
        );

        if ( empty( $this->paragraphId ) )
        {
            $form->get( 'layoutId' )
                 ->setEmptyOption( null );
        }

        /* @var $form \Zend\Form\Form */
        $paragraph = $this->findParagraph();

        if ( ! empty( $paragraph ) )
        {
            $form->setHydrator( $paragraph->getMapper() )
                 ->bind( $paragraph );
        }

        if ( $request->isPost() )
        {
            $form->setData( $data );

            if ( $form->isValid() )
            {
                $data       = $form->getData();
                $success    = $this->saveLayout( $data['layoutId'] );
            }
            else
            {
                $success    = false;
            }
        }

        if ( true === $success )
        {
            $this->messenger()
                 ->add( 'paragraph.action.changeLayout.success',
                        'paragraph', Message::LEVEL_INFO );
        }

        if ( false === $success )
        {
            $this->messenger()
                 ->add( 'paragraph.action.changeLayout.failed',
                        'paragraph', Message::LEVEL_ERROR );
        }

        if ( null !== $success )
        {
            return $this->redirect()
                        ->toUrl( $form->get( 'returnUri' )
                                      ->getValue() );
        }

        $view = new ViewModel( array(
            'form' => $form,
        ) );
        return $view->setTerminal( true );
    }
public function localAction()
    {
        $success = null;
        $request = $this->getRequest();
        $data    = $request->getPost();
        $form    = $this->getServiceLocator()
                        ->get( 'Form' )
                        ->create( 'Grid\Paragraph\ChangeLayout\Local', array(
                            'returnUri' => $request->getQuery( 'returnUri' ),
                        ) );

        $form->setAttribute(
            'action',
            $this->url()
                 ->fromRoute( 'Grid\Paragraph\ChangeLayout\Local', array(
                     'locale'       => (string) $this->locale(),
                     'paragraphId'  => $this->paragraphId,
                     'returnUri'    => $request->getQuery( 'returnUri' ),
                 ) )
        );

        if ( empty( $this->paragraphId ) )
        {
            $form->get( 'layoutId' )
                 ->setEmptyOption( null );
        }

        /* @var $form \Zend\Form\Form */
        $paragraph = $this->findParagraph();

        if ( ! empty( $paragraph ) )
        {
            $form->setHydrator( $paragraph->getMapper() )
                 ->bind( $paragraph );
        }

        if ( $request->isPost() )
        {
            $form->setData( $data );

            if ( $form->isValid() )
            {
                $data       = $form->getData();
                $success    = $this->saveLayout( $data['layoutId'] );
            }
            else
            {
                $success    = false;
            }
        }

        if ( true === $success )
        {
            $this->messenger()
                 ->add( 'paragraph.action.changeLayout.success',
                        'paragraph', Message::LEVEL_INFO );
        }

        if ( false === $success )
        {
            $this->messenger()
                 ->add( 'paragraph.action.changeLayout.failed',
                        'paragraph', Message::LEVEL_ERROR );
        }

        if ( null !== $success )
        {
            return $this->redirect()
                        ->toUrl( $form->get( 'returnUri' )
                                      ->getValue() );
        }

        $view = new ViewModel( array(
            'form' => $form,
        ) );
        return $view->setTerminal( true );
    }
public function localAction ( ) { $ success = null ; $ request = $ this -> getRequest ( ) ; $ data = $ request -> getPost ( ) ; $ form = $ this -> getServiceLocator ( ) -> get ( 'Form' ) -> create ( 'Grid\Paragraph\ChangeLayout\Local' , array ( 'returnUri' => $ request -> getQuery ( 'returnUri' ) , ) ) ; $ form -> setAttribute ( 'action' , $ this -> url ( ) -> fromRoute ( 'Grid\Paragraph\ChangeLayout\Local' , array ( 'locale' => ( string ) $ this -> locale ( ) , 'paragraphId' => $ this -> paragraphId , 'returnUri' => $ request -> getQuery ( 'returnUri' ) , ) ) ) ; if ( empty ( $ this -> paragraphId ) ) { $ form -> get ( 'layoutId' ) -> setEmptyOption ( null ) ; } /* @var $form \Zend\Form\Form */ $ paragraph = $ this -> findParagraph ( ) ; if ( ! empty ( $ paragraph ) ) { $ form -> setHydrator ( $ paragraph -> getMapper ( ) ) -> bind ( $ paragraph ) ; } if ( $ request -> isPost ( ) ) { $ form -> setData ( $ data ) ; if ( $ form -> isValid ( ) ) { $ data = $ form -> getData ( ) ; $ success = $ this -> saveLayout ( $ data [ 'layoutId' ] ) ; } else { $ success = false ; } } if ( true === $ success ) { $ this -> messenger ( ) -> add ( 'paragraph.action.changeLayout.success' , 'paragraph' , Message :: LEVEL_INFO ) ; } if ( false === $ success ) { $ this -> messenger ( ) -> add ( 'paragraph.action.changeLayout.failed' , 'paragraph' , Message :: LEVEL_ERROR ) ; } if ( null !== $ success ) { return $ this -> redirect ( ) -> toUrl ( $ form -> get ( 'returnUri' ) -> getValue ( ) ) ; } $ view = new ViewModel ( array ( 'form' => $ form , ) ) ; return $ view -> setTerminal ( true ) ; }
Change to local layout
Change to local layout