Completed
Pull Request — 2.x (#556)
by Grégoire
03:14 queued 01:40
created

Extension/SonataDoctrinePHPCRAdminExtension.php (2 issues)

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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\DoctrinePHPCRAdminBundle\Twig\Extension;
15
16
use PHPCR\NodeInterface;
17
18
class SonataDoctrinePHPCRAdminExtension extends \Twig_Extension
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function getFilters()
24
    {
25
        return [
26
            new \Twig_SimpleFilter('render_node_property', [$this, 'renderNodeProperty'], ['is_safe' => ['html']]),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFilter has been deprecated with message: since Twig 2.7, use "Twig\TwigFilter" 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...
27
            new \Twig_SimpleFilter('render_node_path', [$this, 'renderNodePath'], ['is_safe' => ['html']]),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFilter has been deprecated with message: since Twig 2.7, use "Twig\TwigFilter" 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...
28
        ];
29
    }
30
31
    /**
32
     * Renders a property of a node.
33
     *
34
     * @param string $property
35
     *
36
     * @return string String representation of the property
37
     */
38
    public function renderNodeProperty(NodeInterface $node, $property)
39
    {
40
        return $node->getProperty($property)->getString();
41
    }
42
43
    /**
44
     * Renders a path of a node.
45
     *
46
     * @return string Node path
47
     */
48
    public function renderNodePath(NodeInterface $node)
49
    {
50
        return $node->getPath();
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function getName()
57
    {
58
        return 'sonata_doctrine_phpcr_admin';
59
    }
60
}
61