diff --git a/mailpoet/lib/Models/Newsletter.php b/mailpoet/lib/Models/Newsletter.php index fcc0097569..c9543caec0 100644 --- a/mailpoet/lib/Models/Newsletter.php +++ b/mailpoet/lib/Models/Newsletter.php @@ -105,7 +105,13 @@ class Newsletter extends Model { ); } + /** + * @deprecated This method can be removed after 2023-10-28. Make sure it is removed together with + * \MailPoet\Models\NewsletterOption and \MailPoet\Models\NewsletterOptionField. + */ public function options() { + self::deprecationError(__METHOD__); + return $this->hasManyThrough( __NAMESPACE__ . '\NewsletterOptionField', __NAMESPACE__ . '\NewsletterOption', @@ -251,7 +257,13 @@ class Newsletter extends Model { return $this; } + /** + * @deprecated This method can be removed after 2023-10-28. Make sure it is removed together with + * \MailPoet\Models\NewsletterOption and \MailPoet\Models\NewsletterOptionField. + */ public function withOptions() { + self::deprecationError(__METHOD__); + $options = $this->options()->findArray(); if (empty($options)) { $this->options = []; @@ -366,4 +378,11 @@ class Newsletter extends Model { } return self::filter('filterWithOptions', $newsletter->type)->findOne($id); } + + private static function deprecationError($methodName) { + trigger_error( + 'Calling ' . esc_html($methodName) . ' is deprecated and will be removed. Use \MailPoet\Newsletter\NewslettersRepository and \MailPoet\Entities\NewsletterEntity instead.', + E_USER_DEPRECATED + ); + } } diff --git a/mailpoet/lib/Models/NewsletterOption.php b/mailpoet/lib/Models/NewsletterOption.php index a98e252832..d01c1d0a52 100644 --- a/mailpoet/lib/Models/NewsletterOption.php +++ b/mailpoet/lib/Models/NewsletterOption.php @@ -9,7 +9,7 @@ namespace MailPoet\Models; * @property string $updatedAt * * @deprecated This model is deprecated. Use \MailPoet\Newsletter\Options\NewsletterOptionsRepository and - * \MailPoet\Entities\NewsletterOptionEntity instead. This class can be removed after 2022-11-11. + * \MailPoet\Entities\NewsletterOptionEntity instead. This class can be removed after 2023-10-28. */ class NewsletterOption extends Model { public static $_table = MP_NEWSLETTER_OPTION_TABLE; // phpcs:ignore PSR2.Classes.PropertyDeclaration diff --git a/mailpoet/lib/Models/NewsletterOptionField.php b/mailpoet/lib/Models/NewsletterOptionField.php index 4f74ae0981..a67a84cc8f 100644 --- a/mailpoet/lib/Models/NewsletterOptionField.php +++ b/mailpoet/lib/Models/NewsletterOptionField.php @@ -7,7 +7,7 @@ namespace MailPoet\Models; * @property string $newsletterType * * @deprecated This model is deprecated. Use \MailPoet\Newsletter\Options\NewsletterOptionFieldsRepository and - * \MailPoet\Entities\NewsletterOptionFieldEntity instead. This class can be removed after 2022-11-11. + * \MailPoet\Entities\NewsletterOptionFieldEntity instead. This class can be removed after 2023-10-28. */ class NewsletterOptionField extends Model { public static $_table = MP_NEWSLETTER_OPTION_FIELDS_TABLE; // phpcs:ignore PSR2.Classes.PropertyDeclaration