Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ parameters:
identifier: trait.unused
count: 1
path: src/MailSubscriber.php
-
message: '#^Access to constant on deprecated class YlsIdeas\\SubscribableNotifications\\Channels\\SubscriberMailChannel#'
identifier: classConstant.deprecatedClass
count: 1
path: src/SubscribableServiceProvider.php
13 changes: 13 additions & 0 deletions src/Channels/SubscriberMailChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
use YlsIdeas\SubscribableNotifications\Contracts\CheckNotifiableSubscriptionStatus;
use YlsIdeas\SubscribableNotifications\Contracts\CheckSubscriptionStatusBeforeSendingNotifications;

/**
* @deprecated v1.x will be removed in v2.0. Automatic unsubscribe-link injection via a custom
* MailChannel is replaced by explicit opt-in: return SubscribableMailMessage::via($notifiable, $this)
* from your notification's toMail() method instead.
* See the upgrade guide: UPGRADE.md
*/
class SubscriberMailChannel extends MailChannel
{
/**
Expand All @@ -29,6 +35,13 @@ class SubscriberMailChannel extends MailChannel
*/
public function send($notifiable, Notification $notification)
{
trigger_error(
'SubscriberMailChannel is deprecated and will be removed in v2.0.'
. ' Return SubscribableMailMessage::via($notifiable, $this) from your notification\'s'
. ' toMail() method to opt in to unsubscribe-link injection explicitly.',
E_USER_DEPRECATED
);

// Check if the user would want the mail
if ($notifiable instanceof CheckSubscriptionStatusBeforeSendingNotifications &&
$notification instanceof CheckNotifiableSubscriptionStatus &&
Expand Down
6 changes: 6 additions & 0 deletions src/Contracts/CheckNotifiableSubscriptionStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

namespace YlsIdeas\SubscribableNotifications\Contracts;

/**
* @deprecated v1.x will be removed in v2.0. Subscription gating is now handled by
* SubscribableMailMessage::via() rather than the SubscriberMailChannel.
* Remove this interface from your notifications.
* See the upgrade guide: UPGRADE.md
*/
interface CheckNotifiableSubscriptionStatus
{
public function checkMailSubscriptionStatus(): bool;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

use Illuminate\Notifications\Notification;

/**
* @deprecated v1.x will be removed in v2.0. Subscription gating is now handled by
* SubscribableMailMessage::via() rather than the SubscriberMailChannel.
* Remove this interface from your models.
* See the upgrade guide: UPGRADE.md
*/
interface CheckSubscriptionStatusBeforeSendingNotifications
{
public function mailSubscriptionStatus(Notification $notification): bool;
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @method static void routes()
* @method static string routeName()
* @method static mixed userModel(string $model = null)
* @method static mixed userModel(string $model = null) @deprecated v1.x will be removed in v2.0. Remove all userModel() calls; model resolution is now polymorphic via the URL.
* @method static void onCompletion(callable|string $handler)
* @method static void onUnsubscribeFromMailingList(callable|string $handler)
* @method static void onUnsubscribeFromAllMailingLists(callable|string $handler)
Expand Down
14 changes: 14 additions & 0 deletions src/SubscribableApplicationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

use Illuminate\Support\ServiceProvider;

/**
* @deprecated v1.x will be removed in v2.0. Publish the subscriber-provider stub and configure
* Subscriber callbacks directly in your own service provider's boot() method instead.
* See the upgrade guide: UPGRADE.md
*/
abstract class SubscribableApplicationServiceProvider extends ServiceProvider
{
/**
Expand All @@ -18,6 +23,15 @@ abstract class SubscribableApplicationServiceProvider extends ServiceProvider

public function boot()
{
trigger_error(
sprintf(
'%s is deprecated and will be removed in v2.0. Publish the subscriber-provider stub'
. ' and configure Subscriber callbacks directly in your boot() method instead.',
static::class
),
E_USER_DEPRECATED
);

if ($this->loadRoutes === true) {
$this->loadRoutes();
}
Expand Down
11 changes: 11 additions & 0 deletions src/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,22 @@ public function routeName()
}

/**
* @deprecated v1.x will be removed in v2.0. Model resolution is now polymorphic via the URL.
* Remove all Subscriber::userModel() calls and add a morph map instead.
* See the upgrade guide: UPGRADE.md
*
* @param string|null $model
* @return string|null
*/
public function userModel(?string $model = null)
{
trigger_error(
'Subscriber::userModel() is deprecated and will be removed in v2.0.'
. ' Model resolution is now polymorphic via the URL.'
. ' Remove all userModel() calls and register a morph map instead.',
E_USER_DEPRECATED
);

if ($model) {
$this->userModel = $model;

Expand Down
4 changes: 4 additions & 0 deletions stubs/SubscribableServiceProvider.stub
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

// @deprecated This stub and SubscribableApplicationServiceProvider will be removed in v2.0.
// After upgrading to v2, run `php artisan vendor:publish --tag=subscriber-provider` to get
// the new plain-stub and migrate your callbacks. See UPGRADE.md for details.

namespace App\Providers;

use YlsIdeas\SubscribableNotifications\SubscribableApplicationServiceProvider;
Expand Down
Loading