-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathAbstractTemplateDeletePackageInstallationPlugin.class.php
More file actions
50 lines (44 loc) · 1.48 KB
/
AbstractTemplateDeletePackageInstallationPlugin.class.php
File metadata and controls
50 lines (44 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace wcf\system\package\plugin;
use wcf\system\form\builder\field\TextFormField;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\field\validation\FormFieldValidator;
use wcf\system\form\builder\IFormDocument;
/**
* Abstract implementation of a package installation plugin deleting a certain type of templates.
*
* @author Matthias Schmidt
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @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);
$templateFormField = $form->getFormField($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'
));
}
}));
}
}