We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Total Complexity | 21 |
| Total Lines | 268 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | class NewTenant extends \Kitodo\Dlf\Common\AbstractModule { |
||
| 25 | protected $markerArray = [ |
||
| 26 | 'CSH' => '', |
||
| 27 | 'MOD_MENU' => '', |
||
| 28 | 'CONTENT' => '', |
||
| 29 | ]; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Add metadata configuration |
||
| 33 | * |
||
| 34 | * @access protected |
||
| 35 | * |
||
| 36 | * @return void |
||
| 37 | */ |
||
| 38 | protected function cmdAddMetadata() { |
||
| 39 | // Include metadata definition file. |
||
| 40 | include_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey).'Resources/Private/Data/MetadataDefaults.php'); |
||
| 41 | $i = 0; |
||
| 42 | // Build data array. |
||
| 43 | foreach ($metadataDefaults as $index_name => $values) { |
||
|
1 ignored issue
–
show
|
|||
| 44 | $formatIds = []; |
||
| 45 | foreach ($values['format'] as $format) { |
||
| 46 | $formatIds[] = uniqid('NEW'); |
||
| 47 | $data['tx_dlf_metadataformat'][end($formatIds)] = $format; |
||
| 48 | $data['tx_dlf_metadataformat'][end($formatIds)]['pid'] = intval($this->id); |
||
| 49 | $i++; |
||
| 50 | } |
||
| 51 | $data['tx_dlf_metadata'][uniqid('NEW')] = [ |
||
| 52 | 'pid' => intval($this->id), |
||
| 53 | 'label' => $GLOBALS['LANG']->getLL($index_name), |
||
| 54 | 'index_name' => $index_name, |
||
| 55 | 'format' => implode(',', $formatIds), |
||
| 56 | 'default_value' => $values['default_value'], |
||
| 57 | 'wrap' => (!empty($values['wrap']) ? $values['wrap'] : $GLOBALS['TCA']['tx_dlf_metadata']['columns']['wrap']['config']['default']), |
||
| 58 | 'index_tokenized' => $values['index_tokenized'], |
||
| 59 | 'index_stored' => $values['index_stored'], |
||
| 60 | 'index_indexed' => $values['index_indexed'], |
||
| 61 | 'index_boost' => $values['index_boost'], |
||
| 62 | 'is_sortable' => $values['is_sortable'], |
||
| 63 | 'is_facet' => $values['is_facet'], |
||
| 64 | 'is_listed' => $values['is_listed'], |
||
| 65 | 'index_autocomplete' => $values['index_autocomplete'], |
||
| 66 | ]; |
||
| 67 | $i++; |
||
| 68 | } |
||
| 69 | $_ids = Helper::processDBasAdmin($data, [], TRUE); |
||
|
1 ignored issue
–
show
|
|||
| 70 | // Check for failed inserts. |
||
| 71 | if (count($_ids) == $i) { |
||
| 72 | // Fine. |
||
| 73 | Helper::addMessage( |
||
| 74 | Helper::getMessage('flash.metadataAddedMsg'), |
||
| 75 | Helper::getMessage('flash.metadataAdded', TRUE), |
||
| 76 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK |
||
| 77 | ); |
||
| 78 | } else { |
||
| 79 | // Something went wrong. |
||
| 80 | Helper::addMessage( |
||
| 81 | Helper::getMessage('flash.metadataNotAddedMsg'), |
||
| 82 | Helper::getMessage('flash.metadataNotAdded', TRUE), |
||
| 83 | \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
||
| 84 | ); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Add Solr core |
||
| 90 | * |
||
| 91 | * @access protected |
||
| 92 | * |
||
| 93 | * @return void |
||
| 94 | */ |
||
| 95 | protected function cmdAddSolrCore() { |
||
| 96 | // Build data array. |
||
| 97 | $data['tx_dlf_solrcores'][uniqid('NEW')] = [ |
||
|
1 ignored issue
–
show
|
|||
| 98 | 'pid' => intval($this->id), |
||
| 99 | 'label' => $GLOBALS['LANG']->getLL('solrcore').' (PID '.$this->id.')', |
||
| 100 | 'index_name' => '', |
||
| 101 | ]; |
||
| 102 | $_ids = Helper::processDBasAdmin($data); |
||
| 103 | // Check for failed inserts. |
||
| 104 | if (count($_ids) == 1) { |
||
| 105 | // Fine. |
||
| 106 | Helper::addMessage( |
||
| 107 | Helper::getMessage('flash.solrcoreAddedMsg'), |
||
| 108 | Helper::getMessage('flash.solrcoreAdded', TRUE), |
||
| 109 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK |
||
| 110 | ); |
||
| 111 | } else { |
||
| 112 | // Something went wrong. |
||
| 113 | Helper::addMessage( |
||
| 114 | Helper::getMessage('flash.solrcoreNotAddedMsg'), |
||
| 115 | Helper::getMessage('flash.solrcoreNotAdded', TRUE), |
||
| 116 | \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
||
| 117 | ); |
||
| 118 | } |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * Add structure configuration |
||
| 123 | * |
||
| 124 | * @access protected |
||
| 125 | * |
||
| 126 | * @return void |
||
| 127 | */ |
||
| 128 | protected function cmdAddStructure() { |
||
| 157 | ); |
||
| 158 | } |
||
| 159 | } |
||
| 160 | |||
| 161 | /** |
||
| 162 | * Main function of the module |
||
| 163 | * |
||
| 164 | * @access public |
||
| 165 | * |
||
| 166 | * @param \Psr\Http\Message\ServerRequestInterface $request: The request object |
||
| 167 | * @param \Psr\Http\Message\ResponseInterface $response: The response object |
||
| 168 | * |
||
| 169 | * @return \Psr\Http\Message\ResponseInterface The response object |
||
| 170 | */ |
||
| 171 | public function main(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response) { |
||
| 294 |