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