extensionService = $extensionService; } /** * Initialize arguments. */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('extension', Extension::class, '', true); $this->registerTagAttribute('enctype', 'string', 'MIME type with which the form is submitted'); $this->registerTagAttribute('method', 'string', 'Transfer type (GET or POST)'); $this->registerTagAttribute('name', 'string', 'Name of form'); $this->registerTagAttribute('onreset', 'string', 'JavaScript: On reset of the form'); $this->registerTagAttribute('onsubmit', 'string', 'JavaScript: On submit of the form'); $this->registerUniversalTagAttributes(); } /** * Renders a download link * * @return string the rendered a tag */ public function render() { /** @var Extension $extension */ $extension = $this->arguments['extension']; $installPaths = Extension::returnAllowedInstallPaths(); if (empty($installPaths)) { return ''; } $pathSelector = ''; $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder(); $action = 'checkDependencies'; $uriBuilder->reset(); $uriBuilder->setFormat('json'); $uri = $uriBuilder->uriFor($action, [ 'extension' => (int)$extension->getUid() ], 'Download'); $this->tag->addAttribute('data-href', $uri); $automaticInstallation = (bool)GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('extensionmanager', 'automaticInstallation'); $labelKeySuffix = $automaticInstallation ? '' : '.downloadOnly'; $label = '
'; $this->tag->setContent($label . $pathSelector); $this->tag->addAttribute('class', 'download'); return '
' . $this->tag->render() . '
'; } /** * Get the field name prefix * * @return string */ protected function getFieldNamePrefix() { if ($this->hasArgument('fieldNamePrefix')) { return $this->arguments['fieldNamePrefix']; } return $this->getDefaultFieldNamePrefix(); } /** * Retrieves the default field name prefix for this form * * @return string default field name prefix */ protected function getDefaultFieldNamePrefix() { $request = $this->renderingContext->getControllerContext()->getRequest(); if ($this->hasArgument('extensionName')) { $extensionName = $this->arguments['extensionName']; } else { $extensionName = $request->getControllerExtensionName(); } if ($this->hasArgument('pluginName')) { $pluginName = $this->arguments['pluginName']; } else { $pluginName = $request->getPluginName(); } if ($extensionName !== null && $pluginName != null) { return $this->extensionService->getPluginNamespace($extensionName, $pluginName); } return ''; } }