6b18b03c3a0fbf51d364fd87088e04bfa05d9c2e
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\package\plugin;
3 use wcf\system\WCF;
4
5 /**
6 * Installs, updates and deletes object type definitions.
7 *
8 * @author Alexander Ebert
9 * @copyright 2001-2016 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package com.woltlab.wcf
12 * @subpackage acp.package.plugin
13 * @category Community Framework
14 */
15 class ObjectTypeDefinitionPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
16 /**
17 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
18 */
19 public $className = 'wcf\data\object\type\definition\ObjectTypeDefinitionEditor';
20
21 /**
22 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
23 */
24 public $tagName = 'definition';
25
26 /**
27 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
28 */
29 protected function handleDelete(array $items) {
30 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
31 WHERE definitionName = ?
32 AND packageID = ?";
33 $statement = WCF::getDB()->prepareStatement($sql);
34 foreach ($items as $item) {
35 $statement->execute([
36 $item['attributes']['name'],
37 $this->installation->getPackageID()
38 ]);
39 }
40 }
41
42 /**
43 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
44 */
45 protected function prepareImport(array $data) {
46 return [
47 'interfaceName' => (isset($data['elements']['interfacename']) ? $data['elements']['interfacename'] : ''),
48 'definitionName' => $data['elements']['name'],
49 'categoryName' => (isset($data['elements']['categoryname']) ? $data['elements']['categoryname'] : '')
50 ];
51 }
52
53 /**
54 * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
55 */
56 protected function findExistingItem(array $data) {
57 $sql = "SELECT *
58 FROM wcf".WCF_N."_".$this->tableName."
59 WHERE definitionName = ?";
60 $parameters = [$data['definitionName']];
61
62 return [
63 'sql' => $sql,
64 'parameters' => $parameters
65 ];
66 }
67 }