public function importAction($plugin, Request $request)
    {
        /* @var $chain ChainSearch */
        $chain = $this->get('anime_db.plugin.import');
        /* @var $import ImportInterface */
        if (!($import = $chain->getPlugin($plugin))) {
            throw $this->createNotFoundException('Plugin \''.$plugin.'\' is not found');
        }

        $form = $this->createForm($import->getForm())->handleRequest($request);

        $list = [];
        if ($form->isValid()) {
            // import items
            $list = (array) $import->import($form->getData());

            // persist entity
            $em = $this->getDoctrine()->getManager();
            foreach ($list as $key => $item) {
                if ($item instanceof Item) {
                    $em->persist($item);
                } else {
                    unset($list[$key]);
                }
            }
        }

        return $this->render('AnimeDbCatalogBundle:Item:import.html.twig', [
            'plugin' => $plugin,
            'items' => $list,
            'form' => $form->createView(),
        ]);
    }
public function importAction($plugin, Request $request)
    {
        /* @var $chain ChainSearch */
        $chain = $this->get('anime_db.plugin.import');
        /* @var $import ImportInterface */
        if (!($import = $chain->getPlugin($plugin))) {
            throw $this->createNotFoundException('Plugin \''.$plugin.'\' is not found');
        }

        $form = $this->createForm($import->getForm())->handleRequest($request);

        $list = [];
        if ($form->isValid()) {
            // import items
            $list = (array) $import->import($form->getData());

            // persist entity
            $em = $this->getDoctrine()->getManager();
            foreach ($list as $key => $item) {
                if ($item instanceof Item) {
                    $em->persist($item);
                } else {
                    unset($list[$key]);
                }
            }
        }

        return $this->render('AnimeDbCatalogBundle:Item:import.html.twig', [
            'plugin' => $plugin,
            'items' => $list,
            'form' => $form->createView(),
        ]);
    }
public function importAction ( $ plugin , Request $ request ) { /* @var $chain ChainSearch */ $ chain = $ this -> get ( 'anime_db.plugin.import' ) ; /* @var $import ImportInterface */ if ( ! ( $ import = $ chain -> getPlugin ( $ plugin ) ) ) { throw $ this -> createNotFoundException ( 'Plugin \'' . $ plugin . '\' is not found' ) ; } $ form = $ this -> createForm ( $ import -> getForm ( ) ) -> handleRequest ( $ request ) ; $ list = [ ] ; if ( $ form -> isValid ( ) ) { // import items $ list = ( array ) $ import -> import ( $ form -> getData ( ) ) ; // persist entity $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; foreach ( $ list as $ key => $ item ) { if ( $ item instanceof Item ) { $ em -> persist ( $ item ) ; } else { unset ( $ list [ $ key ] ) ; } } } return $ this -> render ( 'AnimeDbCatalogBundle:Item:import.html.twig' , [ 'plugin' => $ plugin , 'items' => $ list , 'form' => $ form -> createView ( ) , ] ) ; }
Import items.

@param string $plugin
@param Request $request

@return Response
Import items .