public function importMediaAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $modal = $this->createModal();
        $modal->setTitle('ekyna_media.import.title');

        $folderId = $request->attributes->get('id');
        $folder = $this->findFolderById($folderId);

        $import = new MediaImport($folder);

        $flow = $this->get('ekyna_media.import_media.form_flow');
        $flow->bind($import);

        $form = $flow->createForm();
        if ($flow->isValid($form)) {
            $flow->saveCurrentStepData($form);

            if ($flow->nextStep()) {
                $form = $flow->createForm();
            } else {
                // TODO use ResourceManager
                $operator = $this->get('ekyna_media.media.operator');
                foreach ($import->getMedias() as $media) {
                    $event = $operator->create($media);
                    if ($event->isPropagationStopped()) {
                        $this->addFlash(sprintf('Failed to create "%s" media.', $media->getPath()), 'danger');
                    }
                }

                $modal->setContent(array('success' => true));
                return $this->get('ekyna_core.modal')->render($modal);
            }
        }

        $modal->setContent($form->createView());

        return $this->get('ekyna_core.modal')->render($modal);
    }
public function importMediaAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $modal = $this->createModal();
        $modal->setTitle('ekyna_media.import.title');

        $folderId = $request->attributes->get('id');
        $folder = $this->findFolderById($folderId);

        $import = new MediaImport($folder);

        $flow = $this->get('ekyna_media.import_media.form_flow');
        $flow->bind($import);

        $form = $flow->createForm();
        if ($flow->isValid($form)) {
            $flow->saveCurrentStepData($form);

            if ($flow->nextStep()) {
                $form = $flow->createForm();
            } else {
                // TODO use ResourceManager
                $operator = $this->get('ekyna_media.media.operator');
                foreach ($import->getMedias() as $media) {
                    $event = $operator->create($media);
                    if ($event->isPropagationStopped()) {
                        $this->addFlash(sprintf('Failed to create "%s" media.', $media->getPath()), 'danger');
                    }
                }

                $modal->setContent(array('success' => true));
                return $this->get('ekyna_core.modal')->render($modal);
            }
        }

        $modal->setContent($form->createView());

        return $this->get('ekyna_core.modal')->render($modal);
    }
public function importMediaAction ( Request $ request ) { if ( ! $ request -> isXmlHttpRequest ( ) ) { throw new NotFoundHttpException ( ) ; } $ modal = $ this -> createModal ( ) ; $ modal -> setTitle ( 'ekyna_media.import.title' ) ; $ folderId = $ request -> attributes -> get ( 'id' ) ; $ folder = $ this -> findFolderById ( $ folderId ) ; $ import = new MediaImport ( $ folder ) ; $ flow = $ this -> get ( 'ekyna_media.import_media.form_flow' ) ; $ flow -> bind ( $ import ) ; $ form = $ flow -> createForm ( ) ; if ( $ flow -> isValid ( $ form ) ) { $ flow -> saveCurrentStepData ( $ form ) ; if ( $ flow -> nextStep ( ) ) { $ form = $ flow -> createForm ( ) ; } else { // TODO use ResourceManager $ operator = $ this -> get ( 'ekyna_media.media.operator' ) ; foreach ( $ import -> getMedias ( ) as $ media ) { $ event = $ operator -> create ( $ media ) ; if ( $ event -> isPropagationStopped ( ) ) { $ this -> addFlash ( sprintf ( 'Failed to create "%s" media.' , $ media -> getPath ( ) ) , 'danger' ) ; } } $ modal -> setContent ( array ( 'success' => true ) ) ; return $ this -> get ( 'ekyna_core.modal' ) -> render ( $ modal ) ; } } $ modal -> setContent ( $ form -> createView ( ) ) ; return $ this -> get ( 'ekyna_core.modal' ) -> render ( $ modal ) ; }
Imports the media into the folder.

@param Request $request

@return Response
Imports the media into the folder .