| Conditions | 11 |
| Paths | 21 |
| Total Lines | 52 |
| Code Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 35 | public function render() |
||
| 36 | { |
||
| 37 | $table = $this->data['tableName']; |
||
| 38 | $fieldName = $this->data['fieldName']; |
||
| 39 | $parameterArray = $this->data['parameterArray']; |
||
| 40 | $elementName = $parameterArray['itemFormElName']; |
||
| 41 | $config = $parameterArray['fieldConf']['config']; |
||
| 42 | $internalType = (string)$config['internal_type']; |
||
| 43 | $allowed = $config['allowed']; |
||
| 44 | |||
| 45 | if (isset($config['readOnly']) && $config['readOnly']) { |
||
| 46 | return []; |
||
| 47 | } |
||
| 48 | |||
| 49 | if ($internalType === 'db') { |
||
| 50 | $title = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.browse_db'; |
||
| 51 | } else { |
||
| 52 | $title = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.browse_file'; |
||
| 53 | } |
||
| 54 | |||
| 55 | // Check against inline uniqueness - Create some onclick js for delete control and element browser |
||
| 56 | // to override record selection in some FAL scenarios - See 'appearance' docs of group element |
||
| 57 | $inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class); |
||
| 58 | $inlineStackProcessor->initializeByGivenStructure($this->data['inlineStructure']); |
||
| 59 | $elementBrowserOnClickInline = ''; |
||
| 60 | if ($this->data['isInlineChild'] |
||
| 61 | && $this->data['inlineParentUid'] |
||
| 62 | && $this->data['inlineParentConfig']['foreign_table'] === $table |
||
| 63 | && $this->data['inlineParentConfig']['foreign_unique'] === $fieldName |
||
| 64 | ) { |
||
| 65 | $objectPrefix = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data['inlineFirstPid']) . '-' . $table; |
||
| 66 | $elementBrowserOnClickInline = $objectPrefix; |
||
| 67 | } |
||
| 68 | $elementBrowserType = $internalType; |
||
| 69 | if (is_array($config['appearance'] ?? null)) { |
||
| 70 | if (isset($config['appearance']['elementBrowserType'])) { |
||
| 71 | $elementBrowserType = $config['appearance']['elementBrowserType']; |
||
| 72 | } |
||
| 73 | if (isset($config['appearance']['elementBrowserAllowed'])) { |
||
| 74 | $allowed = $config['appearance']['elementBrowserAllowed']; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | // Remove any white-spaces from the allowed extension lists |
||
| 78 | $elementBrowserAllowed = implode(',', GeneralUtility::trimExplode(',', $allowed, true)); |
||
| 79 | |||
| 80 | return [ |
||
| 81 | 'iconIdentifier' => 'actions-insert-record', |
||
| 82 | 'title' => $title, |
||
| 83 | 'linkAttributes' => [ |
||
| 84 | 'class' => 't3js-element-browser', |
||
| 85 | 'data-mode' => htmlspecialchars($elementBrowserType), |
||
| 86 | 'data-params' => htmlspecialchars($elementName . '|||' . $elementBrowserAllowed . '|' . $elementBrowserOnClickInline) |
||
| 87 | ], |
||
| 91 |