From: Matthias Schmidt Date: Tue, 8 Jun 2021 11:47:22 +0000 (+0200) Subject: Add `AbstractTemplateDeletePackageInstallationPlugin` X-Git-Tag: 5.5.0_Alpha_1~682^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=41a20cde81d2d15317241022ababb16be1e8ecec;p=GitHub%2FWoltLab%2FWCF.git Add `AbstractTemplateDeletePackageInstallationPlugin` --- diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractTemplateDeletePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractTemplateDeletePackageInstallationPlugin.class.php new file mode 100644 index 0000000000..8618171f0d --- /dev/null +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractTemplateDeletePackageInstallationPlugin.class.php @@ -0,0 +1,52 @@ + + * @package WoltLabSuite\Core\System\Package\Plugin + * @since 5.5 + */ +abstract class AbstractTemplateDeletePackageInstallationPlugin extends AbstractFileDeletePackageInstallationPlugin +{ + /** + * @inheritDoc + */ + public $tagName = 'template'; + + /** + * @inheritDoc + */ + protected function getFilenameTableColumn(): string + { + return 'templateName'; + } + + /** + * @inheritDoc + */ + protected function addFormFields(IFormDocument $form) + { + parent::addFormFields($form); + + /** @var TextFormField $templateFormField */ + $templateFormField = $form->getNodeById($this->tagName); + $templateFormField->addValidator(new FormFieldValidator('tplSuffix', static function (TextFormField $formField) { + if (\substr($formField->getValue(), -4) === '.tpl') { + $formField->addValidationError(new FormFieldValidationError( + 'tplSuffix', + 'wcf.acp.pip.acpTemplateDelete.template.error.tplSuffix' + )); + } + })); + } +}