2 namespace wcf\system\package\plugin;
3 use wcf\data\template\listener\TemplateListenerEditor;
4 use wcf\system\cache\builder\TemplateListenerCodeCacheBuilder;
8 * Installs, updates and deletes template listeners.
10 * @author Alexander Ebert
11 * @copyright 2001-2016 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package WoltLabSuite\Core\System\Package\Plugin
15 class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
19 public $className = TemplateListenerEditor::class;
24 protected function handleDelete(array $items) {
25 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
30 AND templateName = ?";
31 $statement = WCF::getDB()->prepareStatement($sql);
32 foreach ($items as $item) {
34 $this->installation->getPackageID(),
35 $item['elements']['environment'],
36 $item['elements']['eventname'],
37 $item['attributes']['name'],
38 $item['elements']['templatename']
46 protected function prepareImport(array $data) {
47 $niceValue = isset($data['elements']['nice']) ? intval($data['elements']['nice']) : 0;
48 if ($niceValue < -128) {
51 else if ($niceValue > 127) {
56 'environment' => $data['elements']['environment'],
57 'eventName' => $data['elements']['eventname'],
58 'niceValue' => $niceValue,
59 'name' => $data['attributes']['name'],
60 'options' => isset($data['elements']['options']) ? $data['elements']['options'] : '',
61 'permissions' => isset($data['elements']['permissions']) ? $data['elements']['permissions'] : '',
62 'templateCode' => $data['elements']['templatecode'],
63 'templateName' => $data['elements']['templatename']
70 protected function findExistingItem(array $data) {
72 FROM wcf".WCF_N."_".$this->tableName."
79 $this->installation->getPackageID(),
81 $data['templateName'],
88 'parameters' => $parameters
95 protected function cleanup() {
96 // clear cache immediately
97 TemplateListenerCodeCacheBuilder::getInstance()->reset();