mirror of
https://github.com/Mibew/mibew.git
synced 2025-03-03 18:38:31 +03:00
Move getUpdates to Maintenance\Utils class
This commit is contained in:
parent
abdfa54f36
commit
80f5873d9a
@ -122,7 +122,7 @@ class Updater
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get list of all available updates
|
// Get list of all available updates
|
||||||
$updates = $this->getUpdates();
|
$updates = Utils::getUpdates($this);
|
||||||
|
|
||||||
// Check if updates should be performed
|
// Check if updates should be performed
|
||||||
$versions = array_keys($updates);
|
$versions = array_keys($updates);
|
||||||
@ -258,35 +258,4 @@ class Updater
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets list of all available updates.
|
|
||||||
*
|
|
||||||
* @return array The keys of this array are version numbers and values are
|
|
||||||
* methods of the {@link \Mibew\Maintenance\Updater} class that should be
|
|
||||||
* performed.
|
|
||||||
*/
|
|
||||||
protected function getUpdates()
|
|
||||||
{
|
|
||||||
$updates = array();
|
|
||||||
|
|
||||||
$self_reflection = new \ReflectionClass($this);
|
|
||||||
foreach ($self_reflection->getMethods() as $method_reflection) {
|
|
||||||
// Filter update methods
|
|
||||||
$name = $method_reflection->getName();
|
|
||||||
if (preg_match("/^update([0-9]+)(?:Beta([0-9]+))?$/", $name, $matches)) {
|
|
||||||
$version = Utils::formatVersionId($matches[1]);
|
|
||||||
// Check if a beta version is defined.
|
|
||||||
if (!empty($matches[2])) {
|
|
||||||
$version .= '-beta.' . $matches[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
$updates[$version] = $name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uksort($updates, 'version_compare');
|
|
||||||
|
|
||||||
return $updates;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,37 @@ class Utils
|
|||||||
return implode('.', array_reverse($parts));
|
return implode('.', array_reverse($parts));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets list of all available updates.
|
||||||
|
*
|
||||||
|
* @param object $container Instance of the class that keeps update methods.
|
||||||
|
* @return array The keys of this array are version numbers and values are
|
||||||
|
* methods of the $container class that should be performed.
|
||||||
|
*/
|
||||||
|
public static function getUpdates($container)
|
||||||
|
{
|
||||||
|
$updates = array();
|
||||||
|
|
||||||
|
$container_reflection = new \ReflectionClass($container);
|
||||||
|
foreach ($container_reflection->getMethods() as $method_reflection) {
|
||||||
|
// Filter update methods
|
||||||
|
$name = $method_reflection->getName();
|
||||||
|
if (preg_match("/^update([0-9]+)(?:Beta([0-9]+))?$/", $name, $matches)) {
|
||||||
|
$version = self::formatVersionId($matches[1]);
|
||||||
|
// Check if a beta version is defined.
|
||||||
|
if (!empty($matches[2])) {
|
||||||
|
$version .= '-beta.' . $matches[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
$updates[$version] = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uksort($updates, 'version_compare');
|
||||||
|
|
||||||
|
return $updates;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class should not be instantiated
|
* This class should not be instantiated
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user