public function importAction()
    {
        $form = $this->getServiceLocator()->get('playgroundgame_import_form');
        $form->setAttribute('action', $this->adminUrl()->fromRoute('playgroundgame/import'));
        $form->setAttribute('method', 'post');
        
        if ($this->getRequest()->isPost()) {
            $data = array_replace_recursive(
                $this->getRequest()->getPost()->toArray(),
                $this->getRequest()->getFiles()->toArray()
            );
            
            if (! empty($data['import_file']['tmp_name'])) {
                ErrorHandler::start();
                $game = unserialize(file_get_contents($data['import_file']['tmp_name']));
                $game->setId(null);
                if ($data['slug']) {
                    $game->setIdentifier($data['slug']);
                }
                $duplicate = $this->getAdminGameService()->getGameMapper()->findByIdentifier($game->getIdentifier());
                if (!$duplicate) {
                    $this->getAdminGameService()->getGameMapper()->insert($game);
                }

                ErrorHandler::stop(true);
            }
            
            return $this->redirect()->toUrl($this->adminUrl()->fromRoute('playgroundgame/list'));
        }
        
        return array(
            'form' => $form,
        );
    }
public function importAction()
    {
        $form = $this->getServiceLocator()->get('playgroundgame_import_form');
        $form->setAttribute('action', $this->adminUrl()->fromRoute('playgroundgame/import'));
        $form->setAttribute('method', 'post');
        
        if ($this->getRequest()->isPost()) {
            $data = array_replace_recursive(
                $this->getRequest()->getPost()->toArray(),
                $this->getRequest()->getFiles()->toArray()
            );
            
            if (! empty($data['import_file']['tmp_name'])) {
                ErrorHandler::start();
                $game = unserialize(file_get_contents($data['import_file']['tmp_name']));
                $game->setId(null);
                if ($data['slug']) {
                    $game->setIdentifier($data['slug']);
                }
                $duplicate = $this->getAdminGameService()->getGameMapper()->findByIdentifier($game->getIdentifier());
                if (!$duplicate) {
                    $this->getAdminGameService()->getGameMapper()->insert($game);
                }

                ErrorHandler::stop(true);
            }
            
            return $this->redirect()->toUrl($this->adminUrl()->fromRoute('playgroundgame/list'));
        }
        
        return array(
            'form' => $form,
        );
    }
public function importAction ( ) { $ form = $ this -> getServiceLocator ( ) -> get ( 'playgroundgame_import_form' ) ; $ form -> setAttribute ( 'action' , $ this -> adminUrl ( ) -> fromRoute ( 'playgroundgame/import' ) ) ; $ form -> setAttribute ( 'method' , 'post' ) ; if ( $ this -> getRequest ( ) -> isPost ( ) ) { $ data = array_replace_recursive ( $ this -> getRequest ( ) -> getPost ( ) -> toArray ( ) , $ this -> getRequest ( ) -> getFiles ( ) -> toArray ( ) ) ; if ( ! empty ( $ data [ 'import_file' ] [ 'tmp_name' ] ) ) { ErrorHandler :: start ( ) ; $ game = unserialize ( file_get_contents ( $ data [ 'import_file' ] [ 'tmp_name' ] ) ) ; $ game -> setId ( null ) ; if ( $ data [ 'slug' ] ) { $ game -> setIdentifier ( $ data [ 'slug' ] ) ; } $ duplicate = $ this -> getAdminGameService ( ) -> getGameMapper ( ) -> findByIdentifier ( $ game -> getIdentifier ( ) ) ; if ( ! $ duplicate ) { $ this -> getAdminGameService ( ) -> getGameMapper ( ) -> insert ( $ game ) ; } ErrorHandler :: stop ( true ) ; } return $ this -> redirect ( ) -> toUrl ( $ this -> adminUrl ( ) -> fromRoute ( 'playgroundgame/list' ) ) ; } return array ( 'form' => $ form , ) ; }
This method take an uploaded txt file containing a serialized game
and persist it in the database
@return unknown
This method take an uploaded txt file containing a serialized game and persist it in the database