Completed
Pull Request — 3.x (#772)
by
unknown
01:52
created

SonataDoctrineORMAdminExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 6 1
A deprecateTemplate() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\DoctrineORMAdminBundle\Twig\Extension;
13
14
use Twig\Extension\AbstractExtension;
15
use Twig\TwigFunction;
16
17
class SonataDoctrineORMAdminExtension extends AbstractExtension
18
{
19
    public function getFunctions()
20
    {
21
        return [
22
            new TwigFunction('deprecate_template', [$this, 'deprecateTemplate']),
23
        ];
24
    }
25
26
    public function deprecateTemplate($templateName)
27
    {
28
        @trigger_error(
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
29
            "The $templateName template is deprecated since version 3.x and will be removed in 4.0."
30
            . 'Templates are moved to @SonataAdminBundle/CRUD/Association',
31
            E_USER_DEPRECATED
32
        );
33
    }
34
}
35