Skip to content

Commit

Permalink
Start v3
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Feb 16, 2024
1 parent 24e7177 commit 8980124
Show file tree
Hide file tree
Showing 57 changed files with 524 additions and 2,108 deletions.
1 change: 1 addition & 0 deletions .github/workflows/code-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- develop
- v3
workflow_dispatch:
permissions:
contents: read
Expand Down
558 changes: 4 additions & 554 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This plugin requires a commercial license purchasable through the [Craft Plugin

## Requirements

This plugin requires [Craft CMS](https://craftcms.com/) 3.1.20 or later, or 4.0.0 or later.
This plugin requires [Craft CMS](https://craftcms.com/) 3.1.20 or later, or 4.0.0 or later, or 5.0.0 or later.

## Installation

Expand Down
33 changes: 16 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "putyourlightson/craft-campaign",
"description": "Send and manage email campaigns, contacts and mailing lists.",
"version": "2.12.1",
"version": "3.0.0-beta.1",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/campaign",
"license": "proprietary",
Expand All @@ -16,37 +16,36 @@
"contact"
],
"require": {
"php": "^8.0.2",
"php": "^8.2",
"ext-dom": "*",
"aws/aws-php-sns-message-validator": "^1.5",
"craftcms/cms": "^4.0",
"elvanto/litemoji": "^3.0.1|^4.0",
"craftcms/cms": "^5.0.0-beta.1",
"html2text/html2text": "^4.3.1",
"matomo/device-detector": "^3.9.1|^4.0|^5.0|^6.0",
"starkbank/ecdsa": "0.*"
},
"require-dev": {
"craftcms/ecs": "dev-main",
"craftcms/feed-me": "^5.0.0",
"craftcms/feed-me": "^5.0.0-beta.1",
"craftcms/phpstan": "dev-main",
"markhuot/craft-pest-core": "^2.0.0-rc2",
"mockery/mockery": "^1.0",
"markhuot/craft-pest-core": "v3.x-dev",
"putyourlightson/craft-generate-test-spec": "v2.x-dev"
},
"scripts": {
"phpstan": "phpstan --ansi --memory-limit=1G",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --fix --ansi"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/bencroker/craft-pest-core"
}
],
"autoload": {
"psr-4": {
"putyourlightson\\campaign\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"putyourlightson\\campaigntests\\": "tests/"
}
"scripts": {
"phpstan": "phpstan --ansi --memory-limit=1G",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --fix --ansi"
},
"config": {
"allow-plugins": {
Expand All @@ -68,7 +67,7 @@
"developer": "PutYourLightsOn",
"developerUrl": "https://putyourlightson.com/",
"documentationUrl": "https://putyourlightson.com/plugins/campaign",
"changelogUrl": "https://raw.githubusercontent.com/putyourlightson/craft-campaign/v1/CHANGELOG.md",
"changelogUrl": "https://raw.githubusercontent.com/putyourlightson/craft-campaign/v2/CHANGELOG.md",
"class": "putyourlightson\\campaign\\Campaign"
}
}
82 changes: 41 additions & 41 deletions src/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static function editions(): array
/**
* @inheritdoc
*/
public string $minVersionRequired = '1.21.0';
public string $minVersionRequired = '2.10.0';

/**
* The queue to use for running jobs.
Expand All @@ -203,36 +203,36 @@ public function init(): void
self::$plugin = $this;
$this->name = Craft::t('campaign', 'Plugin Name');

$this->_registerComponents();
$this->_registerInstances();
$this->_registerVariables();
$this->_registerLogTarget();
$this->_registerElementTypes();
$this->_registerFieldTypes();
$this->_registerAfterInstallEvent();
$this->_registerFieldEvents();
$this->_registerProjectConfigListeners();
$this->_registerTemplateHooks();
$this->_registerAllowedOrigins();
$this->_registerTwigExtensions();
$this->_registerFeedMeElements();
$this->registerComponents();
$this->registerInstances();
$this->registerVariables();
$this->registerLogTarget();
$this->registerElementTypes();
$this->registerFieldTypes();
$this->registerAfterInstallEvent();
$this->registerFieldEvents();
$this->registerProjectConfigListeners();
$this->registerTemplateHooks();
$this->registerAllowedOrigins();
$this->registerTwigExtensions();
$this->registerFeedMeElements();

// Register tracker controller shorthand for site requests
if (Craft::$app->getRequest()->getIsSiteRequest()) {
$this->controllerMap = ['t' => TrackerController::class];
}

if (Craft::$app->getRequest()->getIsCpRequest()) {
$this->_registerNativeFields();
$this->_registerAssetBundles();
$this->_registerCpUrlRules();
$this->_registerUtilities();
$this->_registerWidgets();
$this->registerNativeFields();
$this->registerAssetBundles();
$this->registerCpUrlRules();
$this->registerUtilities();
$this->registerWidgets();
}

// If Craft edition is pro
if (Craft::$app->getEdition() === Craft::Pro) {
$this->_registerUserPermissions();
$this->registerUserPermissions();
$this->sync->registerUserEvents();
}
}
Expand Down Expand Up @@ -421,7 +421,7 @@ protected function getCpRoutes(): array
'campaign/campaigns/<campaignTypeHandle:{handle}>/<elementId:\d+><slug:(?:-[^\/]*)?>' => 'elements/edit',
'campaign/contacts/new' => 'campaign/contacts/create',
'campaign/contacts/<elementId:\d+>' => 'elements/edit',
// TODO: remove in 5.0.0, when element index URLs include the source, added in Craft 4.3.0.
// TODO: remove in v3, when element index URLs include the source, added in Craft 4.3.0.
'campaign/contacts/view/<sourceId:\d+>' => ['template' => 'campaign/contacts/view'],
'campaign/contacts/import/<importId:\d+>' => ['template' => 'campaign/contacts/import/_view'],
'campaign/contacts/import' => 'campaign/imports/index',
Expand Down Expand Up @@ -477,15 +477,15 @@ protected function getCpRoutes(): array
*
* @see Plugins::$pluginConfigs
*/
private function _registerComponents(): void
private function registerComponents(): void
{
$this->set('mailer', fn() => $this->createMailer());
}

/**
* Registers instances configured via `config/app.php`, ensuring they are of the correct type.
*/
private function _registerInstances(): void
private function registerInstances(): void
{
$this->queue = Instance::ensure($this->queue, Queue::class);
}
Expand All @@ -495,7 +495,7 @@ private function _registerInstances(): void
*
* @since 2.0.0
*/
private function _registerVariables(): void
private function registerVariables(): void
{
Event::on(CraftVariable::class, CraftVariable::EVENT_INIT,
function(Event $event) {
Expand All @@ -511,7 +511,7 @@ function(Event $event) {
*
* @see LineFormatter::SIMPLE_FORMAT
*/
private function _registerLogTarget(): void
private function registerLogTarget(): void
{
Craft::getLogger()->dispatcher->targets[] = new MonologTarget([
'name' => 'campaign',
Expand All @@ -529,7 +529,7 @@ private function _registerLogTarget(): void
/**
* Registers element types.
*/
private function _registerElementTypes(): void
private function registerElementTypes(): void
{
Event::on(Elements::class, Elements::EVENT_REGISTER_ELEMENT_TYPES,
function(RegisterComponentTypesEvent $event) {
Expand All @@ -545,7 +545,7 @@ function(RegisterComponentTypesEvent $event) {
/**
* Registers custom field types.
*/
private function _registerFieldTypes(): void
private function registerFieldTypes(): void
{
Event::on(Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES, function(RegisterComponentTypesEvent $event) {
$event->types[] = CampaignsField::class;
Expand All @@ -557,7 +557,7 @@ private function _registerFieldTypes(): void
/**
* Registers after install event.
*/
private function _registerAfterInstallEvent(): void
private function registerAfterInstallEvent(): void
{
Event::on(Plugins::class, Plugins::EVENT_AFTER_INSTALL_PLUGIN,
function(PluginEvent $event) {
Expand Down Expand Up @@ -586,7 +586,7 @@ function(PluginEvent $event) {
/**
* Registers field events.
*/
private function _registerFieldEvents(): void
private function registerFieldEvents(): void
{
Event::on(Fields::class, Fields::EVENT_AFTER_SAVE_FIELD,
function(FieldEvent $event) {
Expand All @@ -606,7 +606,7 @@ function(FieldEvent $event) {
/**
* Registers event listeners for project config changes.
*/
private function _registerProjectConfigListeners(): void
private function registerProjectConfigListeners(): void
{
// Contact field layout
Craft::$app->getProjectConfig()
Expand Down Expand Up @@ -639,7 +639,7 @@ private function _registerProjectConfigListeners(): void
*
* @since 1.15.1
*/
private function _registerTemplateHooks(): void
private function registerTemplateHooks(): void
{
Craft::$app->getView()->hook('cp.users.edit.details', function($context) {
/** @var User|null $user */
Expand Down Expand Up @@ -668,7 +668,7 @@ private function _registerTemplateHooks(): void
*
* @since 1.21.0
*/
private function _registerAllowedOrigins(): void
private function registerAllowedOrigins(): void
{
Event::on(PreviewController::class, Controller::EVENT_BEFORE_ACTION,
function(ActionEvent $event) {
Expand Down Expand Up @@ -707,7 +707,7 @@ function(ActionEvent $event) {
*
* @since 2.0.0
*/
private function _registerTwigExtensions(): void
private function registerTwigExtensions(): void
{
Craft::$app->getView()->registerTwigExtension(new CampaignTwigExtension());
}
Expand All @@ -717,7 +717,7 @@ private function _registerTwigExtensions(): void
*
* @since 2.8.0
*/
private function _registerFeedMeElements(): void
private function registerFeedMeElements(): void
{
// Only check that the class exists, disregarding application initialisation.
// https://github.com/putyourlightson/craft-campaign/issues/428
Expand All @@ -737,7 +737,7 @@ function(RegisterFeedMeElementsEvent $event) {
*
* @since 2.0.0
*/
private function _registerNativeFields(): void
private function registerNativeFields(): void
{
Event::on(FieldLayout::class, FieldLayout::EVENT_DEFINE_NATIVE_FIELDS,
function(DefineFieldLayoutFieldsEvent $event) {
Expand All @@ -764,7 +764,7 @@ function(DefineFieldLayoutFieldsEvent $event) {
*
* @since 2.0.0
*/
private function _registerAssetBundles(): void
private function registerAssetBundles(): void
{
Craft::$app->getView()->registerAssetBundle(CpAsset::class);

Expand All @@ -778,7 +778,7 @@ private function _registerAssetBundles(): void
*
* @since 2.0.0
*/
private function _registerCpUrlRules(): void
private function registerCpUrlRules(): void
{
Event::on(UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES,
function(RegisterUrlRulesEvent $event) {
Expand All @@ -792,9 +792,9 @@ function(RegisterUrlRulesEvent $event) {
*
* @since 2.0.0
*/
private function _registerUtilities(): void
private function registerUtilities(): void
{
Event::on(Utilities::class, Utilities::EVENT_REGISTER_UTILITY_TYPES,
Event::on(Utilities::class, Utilities::EVENT_REGISTER_UTILITIES,
function(RegisterComponentTypesEvent $event) {
$event->types[] = CampaignUtility::class;
}
Expand All @@ -806,7 +806,7 @@ function(RegisterComponentTypesEvent $event) {
*
* @since 2.4.0
*/
private function _registerWidgets(): void
private function registerWidgets(): void
{
Event::on(Dashboard::class, Dashboard::EVENT_REGISTER_WIDGET_TYPES,
function(RegisterComponentTypesEvent $event) {
Expand All @@ -821,7 +821,7 @@ function(RegisterComponentTypesEvent $event) {
*
* @since 2.0.0
*/
private function _registerUserPermissions(): void
private function registerUserPermissions(): void
{
Event::on(UserPermissions::class, UserPermissions::EVENT_REGISTER_PERMISSIONS,
function(RegisterUserPermissionsEvent $event) {
Expand Down
Loading

0 comments on commit 8980124

Please sign in to comment.