From 41a20cde81d2d15317241022ababb16be1e8ecec Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 8 Jun 2021 13:47:22 +0200 Subject: [PATCH] Add `AbstractTemplateDeletePackageInstallationPlugin` --- ...eDeletePackageInstallationPlugin.class.php | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/package/plugin/AbstractTemplateDeletePackageInstallationPlugin.class.php 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' + )); + } + })); + } +} -- 2.20.1