-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
simon.rabjohns
committed
Oct 4, 2019
1 parent
21437bd
commit b040525
Showing
32 changed files
with
2,525 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Drip Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## 1.0.0 - 2019-10-02 | ||
### Added | ||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Extreme | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Drip plugin for Craft CMS 3.x | ||
|
||
Drip connector for Craft 3.x | ||
|
||
![Screenshot](resources/img/plugin-logo.png) | ||
|
||
## Requirements | ||
|
||
This plugin requires Craft CMS 3.0.0-beta.23 or later. | ||
|
||
## Installation | ||
|
||
To install the plugin, follow these instructions. | ||
|
||
1. Open your terminal and go to your Craft project: | ||
|
||
cd /path/to/project | ||
|
||
2. Then tell Composer to load the plugin: | ||
|
||
composer require extreme-creations/drip | ||
|
||
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Drip. | ||
|
||
## Drip Overview | ||
|
||
-Insert text here- | ||
|
||
## Configuring Drip | ||
|
||
-Insert text here- | ||
|
||
## Using Drip | ||
|
||
-Insert text here- | ||
|
||
## Drip Roadmap | ||
|
||
Some things to do, and ideas for potential features: | ||
|
||
* Release it | ||
|
||
Brought to you by [Extreme](madebyextreme.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "extreme/drip", | ||
"description": "Drip connector for Craft 3.x", | ||
"type": "craft-plugin", | ||
"version": "1.0.0", | ||
"keywords": [ | ||
"craft", | ||
"cms", | ||
"craftcms", | ||
"craft-plugin", | ||
"drip" | ||
], | ||
"support": { | ||
"docs": "https://github.com/extreme-creations/drip/blob/master/README.md", | ||
"issues": "https://github.com/extreme-creations/drip/issues" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Extreme", | ||
"homepage": "madebyextreme.com" | ||
} | ||
], | ||
"require": { | ||
"craftcms/cms": "^3.0.0-RC1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"extreme\\drip\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"name": "Drip", | ||
"handle": "drip", | ||
"hasCpSettings": true, | ||
"hasCpSection": false, | ||
"changelogUrl": "https://raw.githubusercontent.com/extreme-creations/drip/master/CHANGELOG.md", | ||
"components": { | ||
"dripService": "extreme\\drip\\services\\DripService" | ||
}, | ||
"class": "extreme\\drip\\Drip" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,266 @@ | ||
<?php | ||
/** | ||
* Drip plugin for Craft CMS 3.x | ||
* | ||
* Drip connector for Craft 3.x | ||
* | ||
* @link madebyextreme.com | ||
* @copyright Copyright (c) 2019 Extreme | ||
*/ | ||
|
||
namespace extreme\drip; | ||
|
||
use craft\records\Element; | ||
use craft\services\Elements; | ||
use extreme\drip\services\DripService as DripService; | ||
use extreme\drip\models\Settings; | ||
use extreme\drip\variables\DripVariable; | ||
|
||
use Craft; | ||
use craft\base\Plugin; | ||
use craft\services\Plugins; | ||
use craft\events\PluginEvent; | ||
use craft\web\UrlManager; | ||
use craft\services\Utilities; | ||
use craft\events\RegisterComponentTypesEvent; | ||
use craft\events\RegisterUrlRulesEvent; | ||
use craft\web\twig\variables\CraftVariable; | ||
use craft\services\Users; | ||
use craft\events\UserEvent; | ||
|
||
use Solspace\Freeform\Events\Submissions\SubmitEvent; | ||
use Solspace\Freeform\Services\FormsService; | ||
use Solspace\Freeform\Services\SubmissionsService; | ||
use yii\base\Event; | ||
use yii\web\User; | ||
use yii\web\View; | ||
|
||
|
||
/** | ||
* Class Drip | ||
* | ||
* @author Extreme | ||
* @package Drip | ||
* @since 1.0.0 | ||
* | ||
* @property DripService $dripService | ||
*/ | ||
class Drip extends Plugin | ||
{ | ||
// Static Properties | ||
// ========================================================================= | ||
|
||
/** | ||
* @var Drip | ||
*/ | ||
public static $plugin; | ||
|
||
// Public Properties | ||
// ========================================================================= | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $schemaVersion = '1.0.0'; | ||
|
||
// Public Methods | ||
// ========================================================================= | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function init() | ||
{ | ||
parent::init(); | ||
self::$plugin = $this; | ||
|
||
$view = Craft::$app->getView(); | ||
$view->registerJs($this->settings['dripSnippet'], View::POS_END); | ||
|
||
$this->initDripEvents(); | ||
|
||
// Register our site routes | ||
Event::on( | ||
UrlManager::class, | ||
UrlManager::EVENT_REGISTER_SITE_URL_RULES, | ||
function (RegisterUrlRulesEvent $event) { | ||
$event->rules['siteActionTrigger1'] = 'drip-ecrm-connector/drip'; | ||
$event->rules['restore-cart'] = 'drip-ecrm-connector/drip/restore-cart'; | ||
} | ||
); | ||
|
||
// Register our CP routes | ||
Event::on( | ||
UrlManager::class, | ||
UrlManager::EVENT_REGISTER_CP_URL_RULES, | ||
function (RegisterUrlRulesEvent $event) { | ||
$event->rules['drip-ecrm-connector/settings'] = 'drip-ecrm-connector/settings/load-settings'; | ||
$event->rules['drip-ecrm-connector/settings/drip'] = 'drip-ecrm-connector/settings/load-settings'; | ||
$event->rules['drip-ecrm-connector/settings/core'] = 'drip-ecrm-connector/settings/load-settings'; | ||
$event->rules['drip-ecrm-connector/settings/commerce'] = 'drip-ecrm-connector/settings/load-settings'; | ||
$event->rules['drip-ecrm-connector/settings/freeform'] = 'drip-ecrm-connector/settings/load-settings'; | ||
} | ||
); | ||
|
||
// Register our variables | ||
Event::on( | ||
CraftVariable::class, | ||
CraftVariable::EVENT_INIT, | ||
function (Event $event) { | ||
/** @var CraftVariable $variable */ | ||
$variable = $event->sender; | ||
$variable->set('drip', DripVariable::class); | ||
} | ||
); | ||
|
||
Event::on( | ||
Plugins::class, | ||
Plugins::EVENT_AFTER_INSTALL_PLUGIN, | ||
function (PluginEvent $event) { | ||
if ($event->plugin === $this) { | ||
} | ||
} | ||
); | ||
|
||
Craft::info( | ||
Craft::t( | ||
'drip', | ||
'{name} plugin loaded', | ||
['name' => $this->name] | ||
), | ||
__METHOD__ | ||
); | ||
} | ||
|
||
// Protected Methods | ||
// ========================================================================= | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function createSettingsModel() | ||
{ | ||
return new Settings(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function settingsHtml(): string | ||
{ | ||
return Craft::$app->view->renderTemplate( | ||
'drip/settings', | ||
[ | ||
'settings' => $this->getSettings() | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @return array|null | ||
*/ | ||
|
||
public function getCpNavItem() | ||
{ | ||
$subNavs = []; | ||
$navItem = parent::getCpNavItem(); | ||
|
||
$currentUser = Craft::$app->getUser()->getIdentity(); | ||
|
||
$subNavs['dashboard'] = [ | ||
'label' => 'Dashboard', | ||
'url' => 'drip/dashboard', | ||
]; | ||
|
||
$subNavs['settigns'] = [ | ||
'label' => 'Settings', | ||
'url' => 'drip/settings', | ||
]; | ||
|
||
|
||
$navItem = array_merge($navItem, [ | ||
'subnav' => $subNavs, | ||
]); | ||
|
||
return $navItem; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
private function initDripEvents() | ||
{ | ||
|
||
/** | ||
* Activate User Event | ||
* Testing with EVENT_AFTER_UNSUSPEND_USER | ||
* todo: Update to use EVENT_AFTER_ACTIVATE_USER for production | ||
* Full list of user events: craft/vendor/craftcms/cms/src/services/Users.php | ||
*/ | ||
|
||
Event::on( | ||
Users::class, | ||
Users::EVENT_AFTER_UNSUSPEND_USER, | ||
function (UserEvent $event) { | ||
Drip::$plugin->dripService->addCoreDripEvent('create', $event->user); | ||
} | ||
); | ||
|
||
/** | ||
* User Account Login Event | ||
* Core Yii Class event requires yii\web\User | ||
*/ | ||
|
||
Event::on( | ||
User::class, | ||
User::EVENT_AFTER_LOGIN, | ||
function (Event $event) { | ||
Drip::$plugin->dripService->addCoreDripEvent('login', $event->identity); | ||
} | ||
); | ||
|
||
/** | ||
* User Account Logout Event | ||
* Core Yii Class event requires yii\web\User | ||
*/ | ||
|
||
Event::on( | ||
User::class, | ||
User::EVENT_AFTER_LOGOUT, | ||
function (Event $event) { | ||
Drip::$plugin->dripService->addCoreDripEvent('logout', $event->identity); | ||
} | ||
); | ||
|
||
/** | ||
* User Account Update Event | ||
* | ||
*/ | ||
|
||
Event::on( | ||
Elements::class, | ||
Elements::EVENT_AFTER_SAVE_ELEMENT, | ||
function (Event $event) { | ||
if ($event->element instanceof \craft\elements\User) { | ||
Drip::$plugin->dripService->addCoreDripEvent('update', $event->element); | ||
} | ||
} | ||
); | ||
|
||
|
||
/** | ||
* Freeform form submission | ||
* http://docs.solspace.com/craft/freeform/v2/developer/events-and-hooks.html#submissions | ||
*/ | ||
|
||
Event::on( | ||
SubmissionsService::class, | ||
SubmissionsService::EVENT_AFTER_SUBMIT, | ||
function (SubmitEvent $event) { | ||
Drip::$plugin->dripService->addFormSubmission($event); | ||
} | ||
); | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.