src/Controller/DefaultController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Service\WOS;
  7. use App\Service\Sidbi;
  8. use App\Repository\AuthorRepository;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use App\Entity\PublicationAuthor;
  11. use App\Form\PublicationAuthorType;
  12. use App\Form\PublicationAuthor2AuthorType;
  13. use App\Repository\PublicationAuthorRepository;
  14. use Doctrine\ORM\EntityManagerInterface;
  15. class DefaultController extends AbstractController
  16. {
  17.     /**
  18.      * @Route("/", name="homepage")
  19.      */
  20.     public function index(): Response
  21.     {
  22.         return $this->render('default/index.html.twig', [
  23.         ]);
  24.     }
  25.     //tuve que dejar esto aqui porque el controlador de publication controller no queria funcionar
  26.     /**
  27.      * @Route("/toauthor/{id}", name="app_publication_author_2_author", methods={"GET", "POST"})
  28.      */
  29.     public function toauthor(Request $requestPublicationAuthor $publicationAuthorEntityManagerInterface $entityManagerPublicationAuthorRepository $publicationAuthorRepository): Response
  30.     {
  31.         $form $this->createForm(PublicationAuthor2AuthorType::class, $publicationAuthor);
  32.         $form->handleRequest($request);
  33.         if ($form->isSubmitted() && $form->isValid()) {
  34.             $externalAuthor $publicationAuthor->getExternalAuthor();
  35.             $entityManager->remove($externalAuthor);
  36.             $entityManager->remove($publicationAuthor->setExternalAuthor(null));
  37.             $entityManager->persist($externalAuthor);
  38.             $entityManager->persist($publicationAuthor);
  39.             $entityManager->flush();
  40.             $publicationAuthorRepository->removeOrphaned();
  41.             $this->addFlash('success''Autor correctamente asociado');
  42.             return $this->redirectToRoute('publication_edit', ['id'=>$publicationAuthor->getPublication()->getId()], Response::HTTP_SEE_OTHER);
  43.         }
  44.         return $this->renderForm('default/toauthor.html.twig', [
  45.             'publication_author' => $publicationAuthor,
  46.             'form' => $form,
  47.         ]);
  48.     }
  49.     /**
  50.      * @Route("/test", name="test")
  51.      */
  52.     public function test(Sidbi $sidbiWOS $wosAuthorRepository $authorRepository): Response
  53.     {
  54.         /*$wos->setApi('expanded');
  55.         $resp = $wos->getQuota();
  56.         var_dump($resp);
  57.         die();
  58.         */
  59.         $author $authorRepository->find(33);
  60.         echo "hola mundo";
  61.         die();
  62.         [$publications$recordsFound$queryId] = $wos->getAuthorPublications($author);
  63.         var_dump($publications$recordsFound);
  64.         /*
  65.         [$publications, $recordsFound, $queryId] = $wos->getPublications('F-8281-2013',1,1);
  66.         var_dump($publications, $recordsFound);
  67.         */
  68.         /*
  69.         $rIds = $sidbi->getResearchersId();
  70.         echo count($rIds);*/
  71.         return $this->render('default/index.html.twig', [
  72.         ]);
  73.     }
  74. }