Passed
Pull Request — master (#123)
by
unknown
06:40 queued 02:39
created

DeleteAdditionalFieldProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 25
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAdditionalFields() 0 40 2
1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
namespace Kitodo\Dlf\Task;
13
14
use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
15
use TYPO3\CMS\Scheduler\Task\AbstractTask;
16
use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
17
18
/**
19
 * Additional fields for index document task.
20
 *
21
 * @package TYPO3
22
 * @subpackage dlf
23
 *
24
 * @access public
25
 */
26
class DeleteAdditionalFieldProvider extends BaseAdditionalFieldProvider
27
{
28
    /**
29
     * Gets additional fields to render in the form to add/edit a task
30
     *
31
     * @param array $taskInfo Values of the fields from the add/edit task form
32
     * @param BaseTask $task The task object being edited. Null when adding a task!
33
     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module
34
     * @return array A two dimensional array, array('Identifier' => array('fieldId' => array('code' => '', 'label' => '', 'cshKey' => '', 'cshLabel' => ''))
35
     */
36
    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
37
    {
38
        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
39
40
        /** @var BaseTask $task */
41
        if ($currentSchedulerModuleAction->equals(Action::EDIT)) {
42
            $taskInfo['doc'] = $task->getDoc();
43
            $taskInfo['pid'] = $task->getPid();
44
            $taskInfo['solr'] = $task->getSolr();
45
            $taskInfo['softCommit'] = $task->isSoftCommit();
46
        } else {
47
            $taskInfo['doc'] = 'https://';
48
            $taskInfo['pid'] = - 1;
49
            $taskInfo['solr'] = - 1;
50
            $taskInfo['softCommit'] = false;
51
        }
52
53
        $additionalFields = [];
54
55
        // Text field for document URL
56
        $fieldName = 'doc';
57
        $fieldId = 'task_' . $fieldName;
58
        $fieldHtml = '<input type="text" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="' . $taskInfo[$fieldName] . '" >';
59
        $additionalFields[$fieldId] = [
60
            'code' => $fieldHtml,
61
            'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_tasks.xlf:additionalFields.doc',
62
            'cshKey' => '_MOD_system_txschedulerM1',
63
            'cshLabel' => $fieldId
64
        ];
65
66
        // DropDown for storage page
67
        $additionalFields['pid'] = $this->getPidField($taskInfo['pid']);
68
69
        // DropDown for Solr core
70
        $additionalFields['solr'] = $this->getSolrField($taskInfo['solr'], $taskInfo['pid']);
71
72
        // Checkbox for soft commit
73
        $additionalFields['softCommit'] = $this->getSoftCommitField($taskInfo['softCommit']);
74
75
        return $additionalFields;
76
    }
77
}
78