currentVersion = $this->_getCurrentVersion(); } /** * put your comment there... * */ protected abstract function _getCurrentVersion(); /** * put your comment there... * */ public function getInstalledVersion() { return $this->installedVersion; } /** * put your comment there... * */ public function getState() { $installedVersion = $this->getInstalledVersion(); return ( ! $installedVersion ) ? self::STATE_FRESH_INSTALL : version_compare( $installedVersion, $this->currentVersion ); } /** * put your comment there... * */ public final function install() { return $this->processUpgraders( 0 ); } /** * put your comment there... * * @param mixed $startIndex */ protected function processUpgraders( $startIndex ) { # Run all upgraders, stop on error for ( $currentIndex = $startIndex; $currentIndex < count( $this->_upgraders ) ; $currentIndex++ ) { $upgraderName = str_replace( array( '.', '-' ), array( '', '_' ), $this->_upgraders[ $currentIndex ] ); $upgraderMethodName = "upgrade_{$upgraderName}"; if ( method_exists( $this, $upgraderMethodName ) ) { if ( ! $this->$upgraderMethodName() ) { return false; } } } # Set version number $this->installedVersion = $this->currentVersion; # Save state $this->writeState(); return true; } /** * put your comment there... * */ public function uninstall() { } /** * put your comment there... * */ public final function upgrade() { $result = false; $installedVersion = $this->getInstalledVersion(); $installedVersionUIdx = array_search( $installedVersion, $this->_upgraders ); if ( $installedVersionUIdx !== FALSE ) { $result = $this->processUpgraders( $installedVersionUIdx ); } return $result; } }