Completed
Push — master ( 1c3343...493201 )
by Fabien
52:23
created

ConfiguredPidTool::getTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Fab\Vidi\Tool;
3
4
/*
5
 * This file is part of the Fab/Vidi project under GPLv2 or later.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.md file that was distributed with this source code.
9
 */
10
11
use Fab\Vidi\Module\ModulePidService;
12
use TYPO3\CMS\Core\Utility\GeneralUtility;
13
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
14
15
/**
16
 * Class ConfiguredPidTool
17
 */
18
class ConfiguredPidTool extends AbstractTool
19
{
20
21
    /**
22
     * Display the title of the tool on the welcome screen.
23
     *
24
     * @return string
25
     */
26
    public function getTitle(): string
27
    {
28
        return sprintf('%s (%s)',
29
            LocalizationUtility::translate('tool.configured_pid', 'vidi'),
30
            $this->getModulePidService()->getConfiguredNewRecordPid()
31
        );
32
    }
33
34
    /**
35
     * Display the description of the tool in the welcome screen.
36
     *
37
     * @return string
38
     */
39
    public function getDescription(): string
40
    {
41
        $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ConfiguredPid/Launcher.html';
42
        $view = $this->initializeStandaloneView($templateNameAndPath);
43
        $view->assignMultiple([
44
            'sitePath' => PATH_site,
45
            'dataType' => $this->getModuleLoader()->getDataType(),
46
            'configuredPid' => $this->getModulePidService()->getConfiguredNewRecordPid(),
47
            'errors' => $this->getModulePidService()->validateConfiguredPid(),
48
        ]);
49
50
        return $view->render();
51
    }
52
53
    /**
54
     * Do the job
55
     *
56
     * @param array $arguments
57
     * @return string
58
     */
59
    public function work(array $arguments = array()): string
60
    {
61
        return '';
62
    }
63
64
    /**
65
     * Tell whether the tools should be displayed according to the context.
66
     *
67
     * @return bool
68
     */
69
    public function isShown(): bool
70
    {
71
        return $this->getBackendUser()->isAdmin();# && GeneralUtility::getApplicationContext()->isDevelopment();
72
    }
73
74
    /**
75
     * Get the Vidi Module Loader.
76
     *
77
     * @return \Fab\Vidi\Module\ModuleLoader|object
78
     */
79
    protected function getModuleLoader(): \Fab\Vidi\Module\ModuleLoader
80
    {
81
        return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class);
82
    }
83
84
    /**
85
     * @return ModulePidService|object
86
     */
87
    public function getModulePidService()
88
    {
89
        /** @var ModulePidService $modulePidService */
90
        return GeneralUtility::makeInstance(ModulePidService::class);
91
    }
92
93
}
94
95