Completed
Push — master ( 91fdab...75a7b9 )
by
unknown
13:37
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
    /**
23
     * Returns a list of functions to add to the existing list.
24
     *
25
     * @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...
26
     */
27
    public function getFunctions()
28
    {
29
        return [
30
            'get_possible_child_types' => new \Twig_SimpleFunction(
31
                'get_possible_child_types', [$this, 'getPossibleChildTypes']
32
            ),
33
            'get_homepage_types' => new \Twig_SimpleFunction(
34
                'get_homepage_types', [$this, 'getHomepageTypes']
35
            ),
36
        ];
37
    }
38
39
    /**
40
     * @param string|HasNodeInterface $reference
41
     *
42
     * @return array
43
     */
44
    public function getPossibleChildTypes($reference)
45
    {
46
        return $this->pagesConfiguration->getPossibleChildTypes($reference);
47
    }
48
49
    /**
50
     * @return array
51
     */
52
    public function getHomepageTypes()
53
    {
54
        return $this->pagesConfiguration->getHomepageTypes();
55
    }
56
}
57