| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of the Superdesk Web Publisher Core Bundle. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Copyright 2015 Sourcefabric z.u. and contributors. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * For the full copyright and license information, please see the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * AUTHORS and LICENSE files distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @copyright 2015 Sourcefabric z.ú | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @license http://www.superdesk.org/license | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | namespace SWP\Bundle\CoreBundle\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Nelmio\ApiDocBundle\Annotation\ApiDoc; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Symfony\Component\Routing\Annotation\Route; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use SWP\Bundle\ContentBundle\Model\ArticleInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use SWP\Component\Common\Criteria\Criteria; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use SWP\Component\Common\Pagination\PaginationData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use SWP\Component\Common\Response\ResourcesListResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use SWP\Component\Common\Response\SingleResourceResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use Symfony\Component\HttpFoundation\Request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | class SlideshowController extends Controller | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @ApiDoc( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      *     resource=true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      *     description="List all slideshows", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      *     statusCodes={ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      *         200="Returned on success." | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      *     }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      *     filters={ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      *         {"name"="sorting", "dataType"="string", "pattern"="[updatedAt]=asc|desc"} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      *     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @Route("/api/{version}/content/slideshows/{articleId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_slideshows_list") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 43 |  | View Code Duplication |     public function listAction(Request $request, string $articleId) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $repository = $this->get('swp.repository.slideshow'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $article = $this->findArticleOr404($articleId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $slideshows = $repository->getPaginatedByCriteria(new Criteria([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             'article' => $article, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         ]), $request->query->get('sorting', []), new PaginationData($request)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         return new ResourcesListResponse($slideshows); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @ApiDoc( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      *     resource=true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      *     description="Get single slideshow", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      *     statusCodes={ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      *         200="Returned on success." | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      *     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @Route("/api/{version}/content/slideshows/{articleId}/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_get_slideshow", requirements={"id"="\d+"}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     public function getAction($id, string $articleId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $article = $this->findArticleOr404($articleId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         return new SingleResourceResponse($this->findOr404($id, $article)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     private function findOr404($id, ArticleInterface $article) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         if (null === $list = $this->get('swp.repository.slideshow')->findOneBy([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 'id' => $id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                 'article' => $article, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             ])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             throw new NotFoundHttpException(sprintf('Slideshow with id "%s" was not found.', $id)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         return $list; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 85 |  |  |     private function findArticleOr404($id) | 
            
                                                        
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 87 |  |  |         if (null === $article = $this->get('swp.repository.article')->findOneById($id)) { | 
            
                                                        
            
                                    
            
            
                | 88 |  |  |             throw new NotFoundHttpException(sprintf('Article with id "%s" was not found.', $id)); | 
            
                                                        
            
                                    
            
            
                | 89 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 91 |  |  |         return $article; | 
            
                                                        
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 93 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 94 |  |  |  | 
            
                        
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.