2 namespace wcf\system\package\plugin;
3 use wcf\system\cache\builder\TemplateListenerCacheBuilder;
4 use wcf\system\cache\builder\TemplateListenerCodeCacheBuilder;
8 * Installs, updates and deletes template listeners.
10 * @author Alexander Ebert
11 * @copyright 2001-2014 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf
14 * @subpackage system.package.plugin
15 * @category Community Framework
17 class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
19 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
21 public $className = 'wcf\data\template\listener\TemplateListenerEditor';
24 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
26 protected function handleDelete(array $items) {
27 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
32 AND templateName = ?";
33 $statement = WCF::getDB()->prepareStatement($sql);
34 foreach ($items as $item) {
35 $statement->execute(array(
36 $this->installation->getPackageID(),
37 $item['elements']['environment'],
38 $item['elements']['eventname'],
39 $item['attributes']['name'],
40 $item['elements']['templatename']
46 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
48 protected function prepareImport(array $data) {
50 'environment' => $data['elements']['environment'],
51 'eventName' => $data['elements']['eventname'],
52 'name' => $data['attributes']['name'],
53 'templateCode' => $data['elements']['templatecode'],
54 'templateName' => $data['elements']['templatename']
59 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
61 protected function findExistingItem(array $data) {
63 FROM wcf".WCF_N."_".$this->tableName."
70 $this->installation->getPackageID(),
72 $data['templateName'],
79 'parameters' => $parameters
84 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup()
86 protected function cleanup() {
87 // clear cache immediately
88 TemplateListenerCacheBuilder::getInstance()->reset();
89 TemplateListenerCodeCacheBuilder::getInstance()->reset();