Completed
Push — master ( e6c0c9...d841f8 )
by Jeroen
35:52 queued 19:21
created

Twig/PagesConfigurationTwigExtension.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\NodeBundle\Twig;
4
5
use Kunstmaan\NodeBundle\Entity\HasNodeInterface;
6
use Kunstmaan\NodeBundle\Helper\PagesConfiguration;
7
8
class PagesConfigurationTwigExtension extends \Twig_Extension
9
{
10
    /** @var PagesConfiguration */
11
    private $pagesConfiguration;
12
13
    /**
14
     * @param PagesConfiguration $pagesConfiguration
15
     */
16
    public function __construct(PagesConfiguration $pagesConfiguration)
17
    {
18
        $this->pagesConfiguration = $pagesConfiguration;
19
    }
20
21
    /**
22
     * Returns a list of functions to add to the existing list.
23
     *
24
     * @return array An array of functions
0 ignored issues
show
Consider making the return type a bit more specific; maybe use array<string,\Twig_SimpleFunction>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
25
     */
26
    public function getFunctions()
27
    {
28
        return [
29
            'get_possible_child_types' => new \Twig_SimpleFunction(
30
                'get_possible_child_types', [$this, 'getPossibleChildTypes']
31
            ),
32
            'get_homepage_types' => new \Twig_SimpleFunction(
33
                'get_homepage_types', [$this, 'getHomepageTypes']
34
            ),
35
        ];
36
    }
37
38
    /**
39
     * @param string|HasNodeInterface $reference
40
     *
41
     * @return array
42
     */
43
    public function getPossibleChildTypes($reference)
44
    {
45
        return $this->pagesConfiguration->getPossibleChildTypes($reference);
46
    }
47
48
    /**
49
     * @return array
50
     */
51
    public function getHomepageTypes()
52
    {
53
        return $this->pagesConfiguration->getHomepageTypes();
54
    }
55
}
56