Jump to content

Search the Community

Showing results for tags 'abort'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. Hi all, I have a module which creates numerous fields, pages etc. I would like to disable the ability to uninstall the module if any of the generated pages have children, as a mistaken uninstall could really mess up any website which is using it. Im curious about what is the best way to achieve this, currently I have some like: public function ___uninstall(){ error_log('---- UNINSTALL!! ----'); //check to see if any config pages have been added and abort uninstall if true //to avoid uninstalling and losing any work which has been done up to this point. if($this->canWeUninstall()) { //remove pages $this->deletePages($this->cPages->getPages()); //remove templates and field groups $this->deleteTemplates($this->cTemplates->getTemplates()); //remove repeaters $this->deleteRepeaters($this->cRepeaters->getRepeaters()); //delete fields $this->deleteFields($this->cFields->getFields(), $this->cRepeaters->getRepeaters()); } else { error_log('Uninstall aborted because config settings exist!'); $this->error('Whoops! Module cant be uninstalled as it appears to be in use.'); return; } } This works in the sense that it doesn't remove any of the generated content, which is good as it wont break the website. However it still shows the module as uninstalled, I can achieve what i'm looking for by replacing 'return' with 'die' but that results in a white page and looks rather rubbish so its not really a great solution. I would imagine there must be a better way to achieve this, any thoughts? Would it be possible to do this check via a hook before uninstallation and abort before we get to the point of running the uninstall() method, as I imagine that is what updates the DB to turn the module off so to speak?
×
×
  • Create New...