Jump to content

Abort module installation


kongondo
 Share

Recommended Posts

Is there a way to abort the installation of a module using the API if a certain condition is not met? I am trying to incorporate the module SchedulePages in my module Blog. Instructions would be for the user to first install SchedulePages. But users being users.... :-)....In case they attempt to first install Blog, I would like to halt the process if SchedulePages is not found. The reason is Blog will need to grab the two date fields created by SchedulePages and add them to the template 'blog-post'. I tried adding some logic in ___install() and init() but got no joy. Blog module was installed anyway. Should I be hooking into something?  What is the process flow when modules are installed? What is called first? This situation I describe also arises because currently, AFAIK, PW will not download and install a third party module from the modules directory just because another module requires it. In my case, just because Blog says it requires 'SchedulePages does not mean PW will install it automatically if it is not bundled with Blog :D. Such third party modules need to be bundled with the module trying to install them. I suppose that is still the case. I tried :-)

Thanks.

Link to comment
Share on other sites

Thanks guys

@Adrian,

But getInstall() will only install modules available to install on your server no? I mean, it will not go to the ProcessWire modules directory to download (like ModulesManager) and install the 'missing' module, would it? I have tried and I get the message 'SchedulePages' installed but it isn't. I guess I could just write a script to go and download the module if it is not on the server, then install it. I am trying to avoid bundling the third party module with Blog if I can, thanks.

Not to worry guys. Changed my mind..., too much effort......I'll just abort if people don't follow instructions :D

Edited by kongondo
  • Like 1
Link to comment
Share on other sites

But getInstall() will only install modules available to install on your server no? I mean, it will not go to the ProcessWire modules directory to download

Yeah, it won't go and download it, but it will tell you if it is available to install. I mostly just used $this->modules->get to check, but that didn't seem to work for inputfields (eg InputfieldSelectMultipleTransfer) and inputfield classes (eg CKEditor - when it was a separate module). 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...