Skip to content

Commit

Permalink
Updated to support Craft 4.0+
Browse files Browse the repository at this point in the history
bhashkar007 committed Jan 2, 2023
1 parent bd9e2b6 commit d62d355
Showing 8 changed files with 27 additions and 25 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"name": "by/guest-entries-notification",
"description": "A plugin to get notification when an entry is created.",
"type": "craft-plugin",
"version": "1.0.2",
"version": "2.0.0",
"keywords": [
"craft",
"cms",
@@ -22,8 +22,8 @@
}
],
"require": {
"craftcms/cms": "^3.0.0",
"craftcms/guest-entries": "^2.1.3"
"craftcms/cms": "^4.0.0",
"craftcms/guest-entries": "^3.0.0"
},
"autoload": {
"psr-4": {
9 changes: 5 additions & 4 deletions src/GuestEntriesNotification.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Guest Entries Notification plugin for Craft CMS 3.x
* Guest Entries Notification plugin for Craft CMS 4.x
*
* A plugin to get notification when an entry is created.
*
@@ -14,6 +14,7 @@
use by\guestentriesnotification\models\Settings;

use Craft;
use craft\base\Model;
use craft\base\Plugin;
use craft\services\Plugins;
use craft\events\PluginEvent;
@@ -28,7 +29,7 @@
*
* @author Bhashkar Yadav
* @package GuestEntriesNotification
* @since 1.0.0
* @since 2.0.0
*
* @property GuestEntriesNotificationServiceService $guestEntriesNotificationService
*/
@@ -48,7 +49,7 @@ class GuestEntriesNotification extends Plugin
/**
* @var string
*/
public $schemaVersion = '1.0.0';
public string $schemaVersion = '2.0.0';

// Public Methods
// =========================================================================
@@ -97,7 +98,7 @@ function (PluginEvent $event) {
/**
* @inheritdoc
*/
protected function createSettingsModel()
protected function createSettingsModel(): ?Model
{
return new Settings();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Guest Entries Notification plugin for Craft CMS 3.x
* Guest Entries Notification plugin for Craft CMS 4.x
*
* A plugin to get notification when an entry is created.
*
@@ -17,7 +17,7 @@
/**
* @author Bhashkar Yadav
* @package GuestEntriesNotification
* @since 1.0.0
* @since 2.0.0
*/
class GuestEntriesNotificationAsset extends AssetBundle
{
2 changes: 1 addition & 1 deletion src/config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Guest Entries Notification plugin for Craft CMS 3.x
* Guest Entries Notification plugin for Craft CMS 4.x
*
* A plugin to get notification when an entry is created.
*
6 changes: 3 additions & 3 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Guest Entries Notification plugin for Craft CMS 3.x
* Guest Entries Notification plugin for Craft CMS 4.x
*
* A plugin to get notification when an entry is created.
*
@@ -18,7 +18,7 @@
/**
* @author Bhashkar Yadav
* @package GuestEntriesNotification
* @since 1.0.0
* @since 2.0.0
*/
class Settings extends Model
{
@@ -40,7 +40,7 @@ class Settings extends Model
/**
* @inheritdoc
*/
public function rules()
public function rules(): array
{
return [
['confirmationTemplate', 'string'],
7 changes: 4 additions & 3 deletions src/services/GuestEntriesNotificationService.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Guest Entries Notification plugin for Craft CMS 3.x
* Guest Entries Notification plugin for Craft CMS 4.x
*
* A plugin to get notification when an entry is created.
*
@@ -21,7 +21,7 @@
/**
* @author Bhashkar Yadav
* @package GuestEntriesNotification
* @since 1.0.0
* @since 2.0.0
*/
class GuestEntriesNotificationService extends Component
{
@@ -33,7 +33,8 @@ class GuestEntriesNotificationService extends Component
*/
public function sendNotification($entry)
{
$settings = Craft::$app->systemSettings->getSettings('email');
$prohectConfig = Craft::$app->getProjectConfig();
$settings = $prohectConfig->get('email');
$pluginSettings = GuestEntriesNotification::$plugin->getSettings();

if(isset($pluginSettings->emailTo) and !empty($pluginSettings->emailTo)){
14 changes: 7 additions & 7 deletions src/templates/settings.twig
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{# @var craft \craft\web\twig\variables\CraftVariable #}
{#
/**
* Guest Entries Notification plugin for Craft CMS 3.x
* Guest Entries Notification plugin for Craft CMS 4.x
*
* Guest Entries Notification Settings.twig
*
* @author Bhashkar Yadav
* @copyright Copyright (c) 2018 Bhashkar Yadav
* @link https://360adaptive.com
* @package GuestEntriesNotification
* @since 1.0.0
* @since 2.0.0
*/
#}

{% import "_includes/forms" as forms %}

{% set systemSettings = craft.systemSettings.email %}

{% set defaultEmail = systemSettings.fromEmail %}
{% set prohectConfig = craft.app.getProjectConfig() %}
{% set emailSettings = prohectConfig.get('email') %}

{{ forms.textField({
label: 'From Email',
instructions: 'Enter the Email that will send the Notification Emails.',
id: 'fromEmail',
name: 'fromEmail',
value: settings['fromEmail']})
value: settings['fromEmail'] ? settings['fromEmail'] : emailSettings.fromEmail
})
}}

{{ forms.textField({
label: 'From Name',
instructions: 'Enter the Name that will send the Notification Emails.',
id: 'fromName',
name: 'fromName',
value: settings['fromName']})
value: settings['fromName'] ? settings['fromName'] : emailSettings.fromEmail})
}}

{{ forms.textField({
4 changes: 2 additions & 2 deletions src/translations/en/guest-entries-notification.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Guest Entries Notification plugin for Craft CMS 3.x
* Guest Entries Notification plugin for Craft CMS 4.x
*
* A plugin to get notification when an entry is created.
*
@@ -11,7 +11,7 @@
/**
* @author Bhashkar Yadav
* @package GuestEntriesNotification
* @since 1.0.0
* @since 2.0.0
*/
return [
'Guest Entries Notification plugin loaded' => 'Guest Entries Notification plugin loaded',

0 comments on commit d62d355

Please sign in to comment.