Issues (3627)

PageBundle/Controller/Api/PageApiController.php (1 issue)

1
<?php
2
3
/*
4
 * @copyright   2014 Mautic Contributors. All rights reserved
5
 * @author      Mautic
6
 *
7
 * @link        http://mautic.org
8
 *
9
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
10
 */
11
12
namespace Mautic\PageBundle\Controller\Api;
13
14
use Mautic\ApiBundle\Controller\CommonApiController;
15
use Mautic\PageBundle\Entity\Page;
16
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
17
18
/**
19
 * Class PageApiController.
20
 */
21
class PageApiController extends CommonApiController
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function initialize(FilterControllerEvent $event)
27
    {
28
        $this->model            = $this->getModel('page');
29
        $this->entityClass      = Page::class;
30
        $this->entityNameOne    = 'page';
31
        $this->entityNameMulti  = 'pages';
32
        $this->serializerGroups = ['pageDetails', 'categoryList', 'publishDetails'];
33
        $this->dataInputMasks   = ['customHtml' => 'html'];
34
35
        parent::initialize($event);
36
    }
37
38
    /**
39
     * Obtains a list of pages.
40
     *
41
     * @return \Symfony\Component\HttpFoundation\Response
42
     */
43
    public function getEntitiesAction()
44
    {
45
        //get parent level only
46
        $this->listFilters[] = [
47
            'column' => 'p.variantParent',
48
            'expr'   => 'isNull',
49
        ];
50
51
        $this->listFilters[] = [
52
            'column' => 'p.translationParent',
53
            'expr'   => 'isNull',
54
        ];
55
56
        return parent::getEntitiesAction();
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    protected function preSerializeEntity(&$entity, $action = 'view')
63
    {
64
        $entity->url = $this->model->generateUrl($entity);
0 ignored issues
show
The method generateUrl() does not exist on Mautic\CoreBundle\Model\AbstractCommonModel. It seems like you code against a sub-type of Mautic\CoreBundle\Model\AbstractCommonModel such as Mautic\PageBundle\Model\PageModel or Mautic\AssetBundle\Model\AssetModel. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

64
        /** @scrutinizer ignore-call */ 
65
        $entity->url = $this->model->generateUrl($entity);
Loading history...
65
    }
66
}
67