2 namespace wcf\system\package\plugin;
3 use wcf\system\cache\builder\TemplateListenerCodeCacheBuilder;
7 * Installs, updates and deletes template listeners.
9 * @author Alexander Ebert
10 * @copyright 2001-2014 WoltLab GmbH
11 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12 * @package com.woltlab.wcf
13 * @subpackage system.package.plugin
14 * @category Community Framework
16 class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
18 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
20 public $className = 'wcf\data\template\listener\TemplateListenerEditor';
23 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
25 protected function handleDelete(array $items) {
26 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
31 AND templateName = ?";
32 $statement = WCF::getDB()->prepareStatement($sql);
33 foreach ($items as $item) {
34 $statement->execute(array(
35 $this->installation->getPackageID(),
36 $item['elements']['environment'],
37 $item['elements']['eventname'],
38 $item['attributes']['name'],
39 $item['elements']['templatename']
45 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
47 protected function prepareImport(array $data) {
49 'environment' => $data['elements']['environment'],
50 'eventName' => $data['elements']['eventname'],
51 'name' => $data['attributes']['name'],
52 'templateCode' => $data['elements']['templatecode'],
53 'templateName' => $data['elements']['templatename']
58 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
60 protected function findExistingItem(array $data) {
62 FROM wcf".WCF_N."_".$this->tableName."
69 $this->installation->getPackageID(),
71 $data['templateName'],
78 'parameters' => $parameters
83 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup()
85 protected function cleanup() {
86 // clear cache immediately
87 TemplateListenerCodeCacheBuilder::getInstance()->reset();