ContentItemDetailCRUDController::showAction()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 2
nop 1
dl 0
loc 11
ccs 0
cts 9
cp 0
crap 20
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
7
namespace Zicht\Bundle\PageBundle\Controller;
8
9
use Sonata\AdminBundle\Controller\CRUDController;
10
11
/**
12
 * Controller used for the ContentItem detail CRUD.
13
 *
14
 * This redirects to the "edit page" URL if the "list" is displayed within the context of a page. This makes sure
15
 * the breadcrumbs work (more or less) as expected.
16
 */
17
class ContentItemDetailCRUDController extends CRUDController
18
{
19
    /**
20
     * @{inheritDoc}
21
     */
22
    public function showAction($id = null)
23
    {
24
        $id = $this->get('request')->get($this->admin->getIdParameter());
0 ignored issues
show
Bug introduced by
The method get() does not exist on Zicht\Bundle\PageBundle\...temDetailCRUDController. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

24
        $id = $this->/** @scrutinizer ignore-call */ get('request')->get($this->admin->getIdParameter());
Loading history...
25
        $obj = $this->admin->getObject($id);
26
27
        $page = $obj->getPage();
28
        if ($page && $this->container->has('zicht_url.provider') && $this->get('zicht_url.provider')->supports($page)) {
29
            return $this->redirect($this->get('zicht_url.provider')->url($page));
0 ignored issues
show
Bug introduced by
The method redirect() does not exist on Zicht\Bundle\PageBundle\...temDetailCRUDController. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

29
            return $this->/** @scrutinizer ignore-call */ redirect($this->get('zicht_url.provider')->url($page));
Loading history...
30
        }
31
32
        return parent::showAction($id);
33
    }
34
35
    /**
36
     * @{inheritDoc}
37
     */
38
    public function listAction()
39
    {
40
        if (($parent = $this->admin->getParent()) && ($container = $parent->getSubject())) {
41
            return $this->redirect(
42
                $parent->generateObjectUrl('edit', $container)
43
            );
44
        }
45
        return parent::listAction();
46
    }
47
}
48