Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin Install Scripts #233

Merged
merged 6 commits into from
Aug 20, 2012
Merged

Plugin Install Scripts #233

merged 6 commits into from
Aug 20, 2012

Conversation

dkobia
Copy link

@dkobia dkobia commented Aug 16, 2012

  • Allows plugins to include install scripts that are run when the plugin is activated see Plugin Install Scripts #222
  • The plugin registers an installer callback
  • Added a footer plugin hook

Example init.php:

class Webanalytics_Init {

    public function __construct() 
    {
        // Register an installer
        Swiftriver_Plugins::register('webanalytics', array(new Webanalytics_Install(), 'db'));
    }
}

Example Callback:

class Webanalytics_Install {

    public function db()
    {

    }
}

David Kobia added 4 commits August 7, 2012 15:39
* added a hook for the footer right before the </body> tag
* Allow plugin to register an installer script callback in init.php
* Check for callback when activating a plugin and run
* Closes #222
// Does the plugin have an installer script?
if ( isset(self::$_installers[$plugin]) )
{
call_user_func(self::$_installers[$plugin]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception handling (and logging) where execution of the callback is unsuccessful.

I also think the return value should be of type bool as opposed to void - for convenience of writing a unit test for this method

@ekala
Copy link
Contributor

ekala commented Aug 16, 2012

I think we should have a plugin_installed column in the plugins table so that we don't call Swiftriver_Plugins::install() each time the plugin is enabled.

@Deathshiver
Copy link
Collaborator

Adding on to keeping track of plugins that are installed, I would suggest rather than automatically installing on enable, the plugin must be installed before being enabled. Put an "Install" button where the enable checkbox is if the plugin has yet to be installed. This would allow plugins to have a graphical install for configuration options if they chose to.

* Added exception handling for the installer callback
* Added a `plugin_installed` column on the plugins table so that the install is not called every time the plugin is enabled/disabled
* `Swiftriver_Plugins::install()` returns bool
@dkobia
Copy link
Author

dkobia commented Aug 19, 2012

Added exception handling and plugin_installed column. @Deathshiver, I think adding an extra install step during plugin installation complicates things slightly. I'm leaning more to this approach until we have an install that requires configuration options.

@ekala
Copy link
Contributor

ekala commented Aug 20, 2012

LGTM

dkobia pushed a commit that referenced this pull request Aug 20, 2012
Plugin Install Scripts

closes #233
@dkobia dkobia merged commit 5e87e52 into master Aug 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants