Changes to plugin API in 0.9.5
In the up-and-coming Frog 0.9.5, a number of changes were made to the plugin API/system of which plugin developers should be aware.
Path changes
Due to the removal of the split between front-end and back-end in Frog 0.9.5, a lot of functionality has become available. However, the paths to files have also changed. Plugin developers that want to use their 0.9.4 plugins on 0.9.5 should update their paths with regards to views. For example:
$this->assignToLayout('sidebar', new View('../../../plugins/comment/views/sidebar'));
becomes:
$this->assignToLayout('sidebar', new View('../../plugins/comment/views/sidebar'));
Skeleton plugin
To allow for a quick start on plugin development, a simple skeleton plugin was added to the core.
Basic inter-plugin dependency support
To allow plugin developers to modify their plugin’s behaviour depending upon the availability of other plugins, a new function was added:
Plugin::isEnabled($plugin_id)
Easily retrieve and store plugin settings
To enable a plugin developer to just work on his plugin and not re-invent the settings wheel, a couple of functions were added:
/** * Returns the value for a specified setting. * Returns false when unsuccessful in retrieving the setting. * * @param <type> $name * @param <type> $plugin_id */ static function getSetting($name=null, $plugin_id=null)/** * Retrieves all settings for a plugin and returns an array of name-value pairs. * Returns empty array when unsuccessful in retrieving the settings. * * @param <type> $plugin_id */ static function getAllSettings($plugin_id=null)/** * Allows you to store a single setting in the database. * * @param string $name Setting name * @param string $value Setting value * @param string $plugin_id Plugin folder name */ static function setSetting($name=null, $value=null, $plugin_id=null)/** * Stores all settings from a name<->value pair array in the database. * * @param array $settings Array of name-value pairs * @param string $plugin_id The folder name of the plugin */ static function setAllSettings($array=null, $plugin_id=null)
New events
A number of new events were added in 0.9.5, the complete list is:
Comment plugin
Observer::notify('comment_after_edit', $comment);
Observer::notify('comment_after_delete', $comment);
Observer::notify('comment_after_approve', $comment);
Observer::notify('comment_after_unapprove', $comment);
Observer::notify('comment_after_add', $comment);
Pages
Observer::notify('page_not_found');
Observer::notify('page_requested', $uri);
Observer::notify('page_found', $page);
Observer::notify('page_add_after_save', $page);
Observer::notify('part_edit_after_save', $part);
Observer::notify('page_delete', $page);
Observer::notify('view_backend_list_plugin', $plugin_name, $plugin);
Observer::notify('view_page_edit_tabs', $page);
Observer::notify('view_page_edit_plugins', $page);
Observer::notify('view_page_edit_popup');
Layouts
Observer::notify('layout_after_add', $layout);
Observer::notify('layout_after_edit', $layout);
Plugins
Observer::notify('plugin_after_enable', $plugin);
Observer::notify('plugin_after_disable', $plugin);
Users
Observer::notify('user_after_add', $user->name);
Observer::notify('user_after_edit', $user->name);
Observer::notify('user_after_delete', $user->name);
Observer::notify('admin_login_success', $data['username']);
Observer::notify('admin_login_failed', $data['username']);
Observer::notify('admin_after_logout', $username);
Snippets
Observer::notify('snippet_after_add', $snippet); Observer::notify('snippet_after_edit', $snippet); Observer::notify('snippet_after_delete', $snippet);
