be225c07365fbc8c6f447b4151629c927a083105
[GitHub/WoltLab/WCF.git] /
1 <?php
2 declare(strict_types=1);
3 namespace wcf\system\package\plugin;
4 use wcf\data\object\type\definition\ObjectTypeDefinitionEditor;
5 use wcf\system\devtools\pip\IIdempotentPackageInstallationPlugin;
6 use wcf\system\WCF;
7
8 /**
9 * Installs, updates and deletes object type definitions.
10 *
11 * @author Alexander Ebert
12 * @copyright 2001-2018 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\Acp\Package\Plugin
15 */
16 class ObjectTypeDefinitionPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin implements IIdempotentPackageInstallationPlugin {
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
69 /**
70 * @inheritDoc
71 */
72 public static function getSyncDependencies() {
73 return [];
74 }
75 }