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

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

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

            if ( $form->isValid() )
            {
                $data       = $form->getData();
                $beforeId   = $this->getLayoutId();
                $clonedId   = $this->getParagraphModel()
                                   ->cloneFrom( $data['importId'], '_central' );
                $success    = $this->saveLayout( $clonedId );

                $this->getServiceLocator()
                     ->get( 'Grid\Menu\Model\Menu\Model' )
                     ->interleaveParagraphs( $clonedId, $beforeId );
            }
            else
            {
                $success    = false;
            }
        }

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

        if ( false === $success )
        {
            $this->messenger()
                 ->add( 'paragraph.action.importLayout.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 importAction()
    {
        $success = null;
        $request = $this->getRequest();
        $data    = $request->getPost();
        $form    = $this->getServiceLocator()
                        ->get( 'Form' )
                        ->create( 'Grid\Paragraph\ChangeLayout\Import', array(
                            'returnUri' => $request->getQuery( 'returnUri' ),
                        ) );

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

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

            if ( $form->isValid() )
            {
                $data       = $form->getData();
                $beforeId   = $this->getLayoutId();
                $clonedId   = $this->getParagraphModel()
                                   ->cloneFrom( $data['importId'], '_central' );
                $success    = $this->saveLayout( $clonedId );

                $this->getServiceLocator()
                     ->get( 'Grid\Menu\Model\Menu\Model' )
                     ->interleaveParagraphs( $clonedId, $beforeId );
            }
            else
            {
                $success    = false;
            }
        }

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

        if ( false === $success )
        {
            $this->messenger()
                 ->add( 'paragraph.action.importLayout.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 importAction ( ) { $ success = null ; $ request = $ this -> getRequest ( ) ; $ data = $ request -> getPost ( ) ; $ form = $ this -> getServiceLocator ( ) -> get ( 'Form' ) -> create ( 'Grid\Paragraph\ChangeLayout\Import' , array ( 'returnUri' => $ request -> getQuery ( 'returnUri' ) , ) ) ; $ form -> setAttribute ( 'action' , $ this -> url ( ) -> fromRoute ( 'Grid\Paragraph\ChangeLayout\Import' , array ( 'locale' => ( string ) $ this -> locale ( ) , 'paragraphId' => $ this -> paragraphId , 'returnUri' => $ request -> getQuery ( 'returnUri' ) , ) ) ) ; if ( $ request -> isPost ( ) ) { $ form -> setData ( $ data ) ; if ( $ form -> isValid ( ) ) { $ data = $ form -> getData ( ) ; $ beforeId = $ this -> getLayoutId ( ) ; $ clonedId = $ this -> getParagraphModel ( ) -> cloneFrom ( $ data [ 'importId' ] , '_central' ) ; $ success = $ this -> saveLayout ( $ clonedId ) ; $ this -> getServiceLocator ( ) -> get ( 'Grid\Menu\Model\Menu\Model' ) -> interleaveParagraphs ( $ clonedId , $ beforeId ) ; } else { $ success = false ; } } if ( true === $ success ) { $ this -> messenger ( ) -> add ( 'paragraph.action.importLayout.success' , 'paragraph' , Message :: LEVEL_INFO ) ; } if ( false === $ success ) { $ this -> messenger ( ) -> add ( 'paragraph.action.importLayout.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 ) ; }
Import layout & change to it
Import layout & change to it