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