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