Completed
Push — master ( cbfe76...f32c2d )
by Fabien
03:34
created

ButtonGroupRenderer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
namespace Fab\Vidi\Grid;
3
4
/**
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19
/**
20
 * Class for rendering the "Button Group" in the Grid, e.g. edit, delete, etc..
21
 */
22
class ButtonGroupRenderer extends ColumnRendererAbstract
23
{
24
25
    /**
26
     * Configure the "Button Group" Grid Renderer.
27
     */
28 View Code Duplication
    public function __construct()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        $configuration = array(
31
            'sortable' => FALSE,
32
            'canBeHidden' => FALSE,
33
            'width' => '100px',
34
        );
35
        parent::__construct($configuration);
36
    }
37
38
    /**
39
     * Render the "Button Group" in the Grid, e.g. edit, delete, etc..
40
     *
41
     * @return string
42
     */
43
    public function render()
44
    {
45
        $components = $this->getModuleLoader()->getGridButtonsComponents();
46
47
        $buttons = [];
48
        foreach ($components as $component) {
49
50
            /** @var  $view */
51
            $view = GeneralUtility::makeInstance($component);
52
            $buttons[] = $view->render($this->getObject());
53
        }
54
55
        $output = sprintf(
56
            '<div class="btn-toolbar pull-right" role="toolbar" aria-label=""><div class="btn-group" role="group" aria-label="">%s</div></div>',
57
            implode("\n", $buttons)
58
        );
59
60
        return $output;
61
    }
62
63
}
64