WizardService::getWizardIcon()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Helper class for wizard handling.
5
 */
6
7
namespace HDNET\Focuspoint\Service;
8
9
use TYPO3\CMS\Core\Imaging\Icon;
10
use TYPO3\CMS\Core\Imaging\IconFactory;
11
use TYPO3\CMS\Core\Utility\GeneralUtility;
12
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
13
14
/**
15
 * WizardService.
16
 */
17
class WizardService extends AbstractService
18
{
19
    /**
20
     * Get the wizard button with the given URI.
21
     *
22
     * @param string $uri
23
     * @param string $additionalClass
24
     *
25
     * @return string
26
     */
27
    public function getWizardButton(string $uri = '', string $additionalClass = '')
28
    {
29
        $spriteIcon = $this->getWizardIcon();
30
        $label = LocalizationUtility::translate('focuspoint.wizard', 'focuspoint');
31
        if ('' === $uri) {
32
            $label .= ' ' . LocalizationUtility::translate('focuspoint.wizard.imagesonly', 'focuspoint');
33
34
            return '<span class="btn btn-default disabled" title="' . $label . '">' . $spriteIcon . '</span>';
35
        }
36
37
        return '<a href="' . $uri . '" class="btn btn-default' . ('' !== $additionalClass ? ' ' . $additionalClass : '') . '" title="' . $label . '">' . $spriteIcon . '</a>';
38
    }
39
40
    /**
41
     * Get the wizard icon.
42
     *
43
     * @return string
44
     */
45
    protected function getWizardIcon(): string
46
    {
47
        /** @var IconFactory $iconFactory */
48
        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
49
        $icon = $iconFactory->getIcon(
50
            'tcarecords-tx_focuspoint_domain_model_filestandalone-default',
51
            Icon::SIZE_SMALL,
52
            null
53
        );
54
55
        return $icon->render();
56
    }
57
}
58