Stopping a package upgrade if requirements aren't met?
Permalink
I'm working on a package, and I need to now install an attribute type from another package. If that attribute type is installed, I want to perform the upgrade and create an attribute for the package. Otherwise, I want to return false and not upgrade the package. This is the code that I'm using:
When I try to run the upgrade, it shows the "Requirements not met" message, but it also increments the package version in the database and marks it as upgraded. Is there a different way to do this so that it won't mark the package as upgraded?
public function upgrade() { $haveGeolocation = 0; $packages = Package::getInstalledList(); foreach ($packages as $package){ $handle = $package->getPackageHandle(); if ($handle == "geolocation_attribute"){ $haveGeolocation = 1; } } if ($haveGeolocation){ $this->installGeolocationAttribute($pkg); parent::upgrade(); } else { $message = t("Requirements not met, you must have the geolocation attribute installed."); throw new Exception($message);
Viewing 15 lines of 18 lines. View entire code block.
When I try to run the upgrade, it shows the "Requirements not met" message, but it also increments the package version in the database and marks it as upgraded. Is there a different way to do this so that it won't mark the package as upgraded?