| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace cx_newsletter;
- class plugin_updater
- extends plugin_worker
- implements plugin_worker_interface {
- public function update() : void {
- $init_settings = !(
- $this
- ->get_settings()
- ->is_initializated()
- );
- $init_database = !(
- $this
- ->get_versions()
- ->is_installed()
- );
- if ($init_settings or $init_database) {
- $this
- ->install();
- }
- $this
- ->get_installer()
- ->update();
- }
- public function install() : void {
- $this
- ->remove();
-
- $this
- ->get_settings()
- ->init();
-
- $this
- ->get_installer()
- ->init()
- ->update();
- }
- public function remove() : void {
- $this
- ->get_settings()
- ->clean();
- $this
- ->get_installer()
- ->clean();
- }
- private function get_installer() : database_installer {
- if ($this->installer !== null) {
- return $this->installer;
- }
- $this->installer = new database_installer(
- $this->get_database(),
- $this->get_tables(),
- $this->get_versions()
- );
- return $this->get_installer();
- }
- private ?database_installer $installer = null;
- }
|