Skip to content

Commit

Permalink
### Changed
Browse files Browse the repository at this point in the history
* Removed deprecated methods for events like `onAfterInstall`
* Added an example of using `Plugins::` events
  • Loading branch information
Andrew Welch committed Feb 15, 2017
1 parent 4e3bc7d commit b026aab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 87 deletions.
5 changes: 5 additions & 0 deletions CHANGLOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# generator-craftplugin Changelog

## 1.2.14 - 2017.02.15
### Changed
* Removed deprecated methods for events like `onAfterInstall`
* Added an example of using `Plugins::` events

## 1.2.13 - 2017.02.14
### Fixed
* Switched the translation back to use the `pluginCamelHandle` doh
Expand Down
98 changes: 12 additions & 86 deletions app/templates/api_version_3_0/src/_Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<% var includeRegisterUrlRulesEvent = false -%>
use Craft;
use craft\base\Plugin;
use craft\services\Plugins;
<% if (pluginComponents.indexOf('consolecommands') >= 0){ -%>
use craft\console\Application as ConsoleApplication;
<% } -%>
Expand Down Expand Up @@ -278,6 +279,17 @@ function (RegisterComponentTypesEvent $event) {
);
<% } -%>

<% if ((typeof codeComments !== 'undefined') && (codeComments)) { -%>
// Do something after we're installed
<% } else { -%>
<% } -%>
Event::on(
Plugins::className(),
Plugins::EVENT_AFTER_INSTALL_PLUGIN,
function (PluginEvent $event) {
}
);

<% if ((typeof codeComments !== 'undefined') && (codeComments)) { -%>
/**
* Logging in Craft involves using one of the following methods:
Expand Down Expand Up @@ -325,92 +337,6 @@ public function defineTemplateComponent()
// Protected Methods
// =========================================================================

<% if ((typeof codeComments !== 'undefined') && (codeComments)) { -%>
/**
* Performs actions before the plugin is installed.
*
* @return bool Whether the plugin should be installed
*/
<% } else { -%>
/**
* @inheritdoc
*/
<% } -%>
protected function beforeInstall(): bool
{
return true;
}

<% if ((typeof codeComments !== 'undefined') && (codeComments)) { -%>
/**
* Performs actions after the plugin is installed.
*/
<% } else { -%>
/**
* @inheritdoc
*/
<% } -%>
protected function afterInstall()
{
}

<% if ((typeof codeComments !== 'undefined') && (codeComments)) { -%>
/**
* Performs actions before the plugin is updated.
*
* @return bool Whether the plugin should be updated
*/
<% } else { -%>
/**
* @inheritdoc
*/
<% } -%>
protected function beforeUpdate(): bool
{
return true;
}

<% if ((typeof codeComments !== 'undefined') && (codeComments)) { -%>
/**
* Performs actions after the plugin is updated.
*/
<% } else { -%>
/**
* @inheritdoc
*/
<% } -%>
protected function afterUpdate()
{
}

<% if ((typeof codeComments !== 'undefined') && (codeComments)) { -%>
/**
* Performs actions before the plugin is installed.
*
* @return bool Whether the plugin should be installed
*/
<% } else { -%>
/**
* @inheritdoc
*/
<% } -%>
protected function beforeUninstall(): bool
{
return true;
}

<% if ((typeof codeComments !== 'undefined') && (codeComments)) { -%>
/**
* Performs actions after the plugin is installed.
*/
<% } else { -%>
/**
* @inheritdoc
*/
<% } -%>
protected function afterUninstall()
{
}
<% if (pluginComponents.indexOf('settings') >= 0){ -%>

<% if ((typeof codeComments !== 'undefined') && (codeComments)) { -%>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-craftplugin",
"version": "1.2.13",
"version": "1.2.14",
"description": "generator-craftplugin is a Yeoman generator for Craft CMS plugins",
"main": "app/index.js",
"files": [
Expand Down

0 comments on commit b026aab

Please sign in to comment.