Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
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
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(
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated with message: since Twig 2.7, use "Twig\TwigFunction" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
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