a41df038f055c20b16ec2e0e9affe97050c7226a
[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 WoltLabSuite\Core\Acp\Package\Plugin
13 */
14 class ObjectTypeDefinitionPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
15 /**
16 * @inheritDoc
17 */
18 public $className = ObjectTypeDefinitionEditor::class;
19
20 /**
21 * @inheritDoc
22 */
23 public $tagName = 'definition';
24
25 /**
26 * @inheritDoc
27 */
28 protected function handleDelete(array $items) {
29 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
30 WHERE definitionName = ?
31 AND packageID = ?";
32 $statement = WCF::getDB()->prepareStatement($sql);
33 foreach ($items as $item) {
34 $statement->execute([
35 $item['attributes']['name'],
36 $this->installation->getPackageID()
37 ]);
38 }
39 }
40
41 /**
42 * @inheritDoc
43 */
44 protected function prepareImport(array $data) {
45 return [
46 'interfaceName' => (isset($data['elements']['interfacename']) ? $data['elements']['interfacename'] : ''),
47 'definitionName' => $data['elements']['name'],
48 'categoryName' => (isset($data['elements']['categoryname']) ? $data['elements']['categoryname'] : '')
49 ];
50 }
51
52 /**
53 * @inheritDoc
54 */
55 protected function findExistingItem(array $data) {
56 $sql = "SELECT *
57 FROM wcf".WCF_N."_".$this->tableName."
58 WHERE definitionName = ?";
59 $parameters = [$data['definitionName']];
60
61 return [
62 'sql' => $sql,
63 'parameters' => $parameters
64 ];
65 }
66 }