3 namespace wcf\system\package\plugin
;
5 use wcf\system\event\EventHandler
;
6 use wcf\system\package\PackageArchive
;
7 use wcf\system\package\PackageInstallationDispatcher
;
11 * Abstract implementation of a package installation plugin.
13 * @author Alexander Ebert
14 * @copyright 2001-2019 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 abstract class AbstractPackageInstallationPlugin
implements IPackageInstallationPlugin
20 * table application prefix
23 public $application = 'wcf';
29 public $tableName = '';
32 * active instance of PackageInstallationDispatcher
33 * @var PackageInstallationDispatcher
38 * install/update instructions
41 public $instruction = [];
44 * Creates a new AbstractPackageInstallationPlugin object.
46 * @param PackageInstallationDispatcher $installation
47 * @param array $instruction
49 public function __construct(PackageInstallationDispatcher
$installation, $instruction = [])
51 $this->installation
= $installation;
52 $this->instruction
= $instruction;
54 // call 'construct' event
55 EventHandler
::getInstance()->fireAction($this, 'construct');
61 public function install()
63 // call 'install' event
64 EventHandler
::getInstance()->fireAction($this, 'install');
70 public function update()
72 // call 'update' event
73 EventHandler
::getInstance()->fireAction($this, 'update');
75 return $this->install();
81 public function hasUninstall()
83 // call 'hasUninstall' event
84 EventHandler
::getInstance()->fireAction($this, 'hasUninstall');
86 $sql = "SELECT COUNT(*)
87 FROM " . $this->application
. WCF_N
. "_" . $this->tableName
. "
89 $statement = WCF
::getDB()->prepareStatement($sql);
90 $statement->execute([$this->installation
->getPackageID()]);
92 return $statement->fetchSingleColumn() > 0;
98 public function uninstall()
100 // call 'uninstall' event
101 EventHandler
::getInstance()->fireAction($this, 'uninstall');
103 $sql = "DELETE FROM " . $this->application
. WCF_N
. "_" . $this->tableName
. "
104 WHERE packageID = ?";
105 $statement = WCF
::getDB()->prepareStatement($sql);
106 $statement->execute([$this->installation
->getPackageID()]);
110 * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename()
113 public static function getDefaultFilename()
121 public static function isValid(PackageArchive
$packageArchive, $instruction)