Add PackageArchive::getUpdateInstructionsFor()
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 16 Nov 2022 11:12:39 +0000 (12:12 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 16 Nov 2022 11:12:39 +0000 (12:12 +0100)
wcfsetup/install/files/lib/system/package/PackageArchive.class.php

index 84297fb0b9e2173956c424c942270fbaa63a64d6..4f7847cfd1be067ce3597e65c07e5b61c8c74615 100644 (file)
@@ -630,6 +630,23 @@ class PackageArchive
         return $this->instructions['update'];
     }
 
+    /**
+     * Returns the appropriate update instructions to update the given package,
+     * `null` if no appropriate instruction could be found.
+     *
+     * @since 6.0
+     */
+    public function getUpdateInstructionsFor(Package $package): ?array
+    {
+        foreach ($this->instructions['update'] as $fromVersion => $instructions) {
+            if (Package::checkFromversion($package->packageVersion, $fromVersion)) {
+                return $instructions;
+            }
+        }
+
+        return null;
+    }
+
     /**
      * Checks which package requirements do already exist in database.
      * Returns a list with the existing requirements.