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\Block; |
||
15 | |||
16 | use Sonata\AdminBundle\Form\FormMapper; |
||
17 | use Sonata\BlockBundle\Block\BlockContextInterface; |
||
18 | use Sonata\BlockBundle\Block\Service\AbstractBlockService; |
||
19 | use Sonata\BlockBundle\Model\BlockInterface; |
||
20 | use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; |
||
21 | use Symfony\Component\HttpFoundation\Response; |
||
22 | use Symfony\Component\OptionsResolver\Options; |
||
23 | use Symfony\Component\OptionsResolver\OptionsResolver; |
||
24 | |||
25 | class TreeBlockService extends AbstractBlockService |
||
26 | { |
||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $defaults; |
||
31 | |||
32 | /** |
||
33 | * @param string $name |
||
34 | */ |
||
35 | public function __construct($name, EngineInterface $templating, array $defaults = []) |
||
36 | { |
||
37 | parent::__construct($name, $templating); |
||
38 | $this->defaults = $defaults; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | * |
||
44 | * NOOP as there is nothing to edit. |
||
45 | */ |
||
46 | public function buildEditForm(FormMapper $form, BlockInterface $block) |
||
0 ignored issues
–
show
|
|||
47 | { |
||
48 | // there is nothing to edit here |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function execute(BlockContextInterface $blockContext, Response $response = null) |
||
55 | { |
||
56 | return $this->renderResponse($blockContext->getTemplate(), [ |
||
57 | 'block' => $blockContext->getBlock(), |
||
58 | 'settings' => $blockContext->getSettings(), |
||
59 | ], $response); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | public function configureSettings(OptionsResolver $resolver) |
||
66 | { |
||
67 | // the callables are a workaround to make bundle configuration win over the default values |
||
68 | // see https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle/pull/345 |
||
69 | $resolver->setDefaults([ |
||
70 | 'template' => static function (Options $options, $value) { |
||
71 | return $value ?: '@SonataDoctrinePHPCRAdmin/Block/tree.html.twig'; |
||
72 | }, |
||
73 | 'id' => static function (Options $options, $value) { |
||
74 | return $value ?: '/'; |
||
75 | }, |
||
76 | 'selected' => static function (Options $options, $value) { |
||
77 | return $value ?: null; |
||
78 | }, |
||
79 | 'routing_defaults' => function (Options $options, $value) { |
||
80 | return $value ?: $this->defaults; |
||
81 | }, |
||
82 | ]); |
||
83 | } |
||
84 | } |
||
85 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.