Completed
Push — master ( 8d3dbf...7592af )
by Paweł
62:36
created

FbiaArticleController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 47
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A listAction() 0 12 1
A updateSubmissionAction() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Core Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. 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 2016 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 Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
19
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
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
27
class FbiaArticleController extends Controller
28
{
29
    /**
30
     * @ApiDoc(
31
     *     resource=true,
32
     *     description="Lists Facebook Instant Articles submitted articles",
33
     *     statusCodes={
34
     *         200="Returned on success.",
35
     *         500="Unexpected error."
36
     *     }
37
     * )
38
     * @Route("/api/{version}/facebook/instantarticles/articles/", options={"expose"=true}, defaults={"version"="v1"}, name="swp_api_list_facebook_instant_articles_articles")
39
     * @Method("GET")
40
     */
41
    public function listAction(Request $request)
42
    {
43
        $repository = $this->get('swp.repository.facebook_instant_articles_article');
44
45
        $items = $repository->getPaginatedByCriteria(
46
            new Criteria(),
47
            ['createdAt' => 'desc'],
48
            new PaginationData($request)
49
        );
50
51
        return new ResourcesListResponse($items);
52
    }
53
54
    /**
55
     * @ApiDoc(
56
     *     resource=true,
57
     *     description="Updates status of submitted Instant Article",
58
     *     statusCodes={
59
     *         200="Returned on success.",
60
     *         500="Unexpected error."
61
     *     }
62
     * )
63
     * @Route("/api/{version}/facebook/instantarticles/articles/{submissionId}", options={"expose"=true}, defaults={"version"="v1"}, name="swp_api_facebook_instant_articles_articles_update")
64
     * @Method("POST")
65
     */
66
    public function updateSubmissionAction(string $submissionId)
67
    {
68
        $instantArticlesService = $this->get('swp.facebook.service.instant_articles');
69
        $instantArticle = $instantArticlesService->updateSubmissionStatus($submissionId);
70
71
        return new SingleResourceResponse($instantArticle);
72
    }
73
}
74