Remove two deprecated methods from the Newsletter model
Those methods were deprecated over six months ago and can now be removed. They are assoacited with the NewsletterOption model which was removed in the previous commit. deprecationError() is also removed as PHPStan was complaining that it is not used anymore. [MAILPOET-5762]
This commit is contained in:
@@ -105,21 +105,6 @@ 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',
|
|
||||||
'newsletter_id',
|
|
||||||
'option_field_id'
|
|
||||||
)->select_expr(MP_NEWSLETTER_OPTION_TABLE . '.value');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save() {
|
public function save() {
|
||||||
if (is_string($this->deletedAt) && strlen(trim($this->deletedAt)) === 0) {
|
if (is_string($this->deletedAt) && strlen(trim($this->deletedAt)) === 0) {
|
||||||
$this->set_expr('deleted_at', 'NULL');
|
$this->set_expr('deleted_at', 'NULL');
|
||||||
@@ -257,22 +242,6 @@ class Newsletter extends Model {
|
|||||||
return $this;
|
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 = [];
|
|
||||||
} else {
|
|
||||||
$this->options = array_column($options, 'value', 'name');
|
|
||||||
}
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function filterWithOptions($orm, $type) {
|
public static function filterWithOptions($orm, $type) {
|
||||||
$orm = $orm->select(MP_NEWSLETTERS_TABLE . '.*');
|
$orm = $orm->select(MP_NEWSLETTERS_TABLE . '.*');
|
||||||
$optionFieldsRepository = ContainerWrapper::getInstance()->get(NewsletterOptionFieldsRepository::class);
|
$optionFieldsRepository = ContainerWrapper::getInstance()->get(NewsletterOptionFieldsRepository::class);
|
||||||
@@ -378,11 +347,4 @@ class Newsletter extends Model {
|
|||||||
}
|
}
|
||||||
return self::filter('filterWithOptions', $newsletter->type)->findOne($id);
|
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user