diff --git a/bin/post-install.php b/bin/post-install.php index 26889ea..9da0878 100644 --- a/bin/post-install.php +++ b/bin/post-install.php @@ -1,9 +1,5 @@ db->toArray()); $install = new Install($adapter); -$result['init'] = $install->database(); -$result['config'] = $install->config(); - -var_dump($result); \ No newline at end of file +echo $install->database(); +echo $install->config(); \ No newline at end of file diff --git a/bin/post-remove.php b/bin/post-remove.php index 2e300ba..d4bd511 100644 --- a/bin/post-remove.php +++ b/bin/post-remove.php @@ -1,17 +1,19 @@ false, 'config' => false, ]; -$install = new Remove(); -$result['init'] = $install->init(); -$result['config'] = $install->manageConfig(); - -var_dump($result); \ No newline at end of file +$config = new Config(include realpath(__DIR__ . '/../../../config/autoload/global.php')); +$adapter = new Adapter($config->db->toArray()); +$install = new Remove($adapter); +echo $install->database(); +echo $install->config(); \ No newline at end of file diff --git a/bin/post-update.php b/bin/post-update.php index 5498700..38b1d93 100644 --- a/bin/post-update.php +++ b/bin/post-update.php @@ -1,17 +1,19 @@ false, 'config' => false, ]; -$install = new Update(); -$result['init'] = $install->init(); -$result['config'] = $install->manageConfig(); - -var_dump($result); \ No newline at end of file +$config = new Config(include realpath(__DIR__ . '/../../../config/autoload/global.php')); +$adapter = new Adapter($config->db->toArray()); +$install = new Update($adapter); +echo $install->database(); +echo $install->config(); \ No newline at end of file diff --git a/composer.json b/composer.json index 145e22a..ecd904f 100644 --- a/composer.json +++ b/composer.json @@ -65,6 +65,9 @@ ], "post-update-cmd": [ "php -r 'if (file_exists(\"bin/post-update.php\")) include \"bin/post-update.php\";'" + ], + "post-package-uninstall": [ + "php -r 'if (file_exists(\"bin/post-remove.php\")) include \"bin/post-remove.php\";'" ] }, diff --git a/src/Installer/Install.php b/src/Installer/Install.php index fc3c8fa..5b114d2 100644 --- a/src/Installer/Install.php +++ b/src/Installer/Install.php @@ -17,22 +17,22 @@ public function __construct( $this->db = $db; } - public function database($version = ''): bool + public function database($version = ''): string { // Set and check $sqlFile = realpath(__DIR__ . '/../../data/schema.sql'); if (!file_exists($sqlFile)) { - return false; + return 'Error to find or read schema.sql'; + } - // read query - $sql = file_get_contents($sqlFile); + $sql = file_get_contents($sqlFile); $statement = $this->db->createStatement($sql); $statement->execute(); - return true; + return 'User module database install successfully !'; } - public function config($file = ''): bool + public function config($file = ''): string { return true; } diff --git a/src/Installer/InstallerInterface.php b/src/Installer/InstallerInterface.php index 55d6106..81e7cda 100644 --- a/src/Installer/InstallerInterface.php +++ b/src/Installer/InstallerInterface.php @@ -4,7 +4,7 @@ interface InstallerInterface { - public function database($version = ''): bool; + public function database($version = ''): string; - public function config($file = ''): bool; + public function config($file = ''): string; } \ No newline at end of file diff --git a/src/Installer/Remove.php b/src/Installer/Remove.php index 05929a0..3672b47 100644 --- a/src/Installer/Remove.php +++ b/src/Installer/Remove.php @@ -17,12 +17,12 @@ public function __construct( $this->db = $db; } - public function database($version = ''): bool + public function database($version = ''): string { return true; } - public function config($file = ''): bool + public function config($file = ''): string { return true; } diff --git a/src/Installer/Update.php b/src/Installer/Update.php index ee3ae65..328fae5 100644 --- a/src/Installer/Update.php +++ b/src/Installer/Update.php @@ -17,12 +17,12 @@ public function __construct( $this->db = $db; } - public function database($version = ''): bool + public function database($version = ''): string { - return true; + return 'User module database update successfully !'; } - public function config($file = ''): bool + public function config($file = ''): string { return true; }