Completed
Push — master ( 227e03...1b465c )
by Artem
10:47 queued 05:43
created

FooterBlockService::configureSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Application\Bundle\DefaultBundle\Service;
4
5
use Doctrine\Common\Persistence\ObjectRepository;
6
use Sonata\BlockBundle\Block\BlockContextInterface;
7
use Sonata\BlockBundle\Block\Service\AbstractBlockService;
8
use Stfalcon\Bundle\EventBundle\Repository\PageRepository;
9
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
10
use Symfony\Component\HttpFoundation\Response;
11
use Symfony\Component\OptionsResolver\OptionsResolver;
12
13
/**
14
 * Class FooterBlockService.
15
 */
16
class FooterBlockService extends AbstractBlockService
17
{
18
    /** @var PageRepository */
19
    private $pageRepository;
20
21
    /**
22
     * ProgramEventBlockService constructor.
23
     *
24
     * @param string           $name
25
     * @param EngineInterface  $templating
26
     * @param ObjectRepository $pageRepository
27
     */
28
    public function __construct($name, EngineInterface $templating, ObjectRepository $pageRepository)
29
    {
30
        parent::__construct($name, $templating);
31
32
        $this->pageRepository = $pageRepository;
0 ignored issues
show
Documentation Bug introduced by
$pageRepository is of type Doctrine\Common\Persistence\ObjectRepository, but the property $pageRepository was declared to be of type Stfalcon\Bundle\EventBun...pository\PageRepository. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function execute(BlockContextInterface $blockContext, Response $response = null)
39
    {
40
        $pages = $this->pageRepository->findBy(['showInFooter' => true]);
41
42
        return $this->renderResponse($blockContext->getTemplate(), [
43
            'block' => $blockContext->getBlock(),
44
            'pages' => $pages,
45
        ], $response);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function configureSettings(OptionsResolver $resolver)
52
    {
53
        $resolver->setDefaults([
54
            'template' => 'ApplicationDefaultBundle:Redesign:_footer_pages.html.twig',
55
            'pages' => null,
56
        ]);
57
    }
58
}
59