Mark DynamicSegment model as deprecated
[MAILPOET-3484]
This commit is contained in:
@ -6,6 +6,11 @@ use MailPoet\Entities\SegmentEntity;
|
|||||||
use MailPoet\Models\Segment as MailPoetSegment;
|
use MailPoet\Models\Segment as MailPoetSegment;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This model is deprecated. Use MailPoet\Segments\DynamicSegments\DynamicSegmentsListingRepository and respective Doctrine entities instead.
|
||||||
|
* This class can be removed after 2021-09-25
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
@ -19,15 +24,18 @@ class DynamicSegment extends MailPoetSegment {
|
|||||||
const TYPE_DYNAMIC = SegmentEntity::TYPE_DYNAMIC;
|
const TYPE_DYNAMIC = SegmentEntity::TYPE_DYNAMIC;
|
||||||
|
|
||||||
public function save() {
|
public function save() {
|
||||||
|
self::deprecationError(__FUNCTION__);
|
||||||
$this->set('type', DynamicSegment::TYPE_DYNAMIC);
|
$this->set('type', DynamicSegment::TYPE_DYNAMIC);
|
||||||
return parent::save();
|
return parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dynamicSegmentFilters() {
|
public function dynamicSegmentFilters() {
|
||||||
|
self::deprecationError(__FUNCTION__);
|
||||||
return $this->has_many(__NAMESPACE__ . '\DynamicSegmentFilter', 'segment_id');
|
return $this->has_many(__NAMESPACE__ . '\DynamicSegmentFilter', 'segment_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function findAll() {
|
public static function findAll() {
|
||||||
|
self::deprecationError(__FUNCTION__);
|
||||||
$query = self::select('*');
|
$query = self::select('*');
|
||||||
return $query->where('type', DynamicSegment::TYPE_DYNAMIC)
|
return $query->where('type', DynamicSegment::TYPE_DYNAMIC)
|
||||||
->whereNull('deleted_at')
|
->whereNull('deleted_at')
|
||||||
@ -35,6 +43,7 @@ class DynamicSegment extends MailPoetSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function listingQuery(array $data = []) {
|
public static function listingQuery(array $data = []) {
|
||||||
|
self::deprecationError(__FUNCTION__);
|
||||||
$query = self::select('*');
|
$query = self::select('*');
|
||||||
$query->where('type', DynamicSegment::TYPE_DYNAMIC);
|
$query->where('type', DynamicSegment::TYPE_DYNAMIC);
|
||||||
if (isset($data['group'])) {
|
if (isset($data['group'])) {
|
||||||
@ -47,6 +56,7 @@ class DynamicSegment extends MailPoetSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function groups() {
|
public static function groups() {
|
||||||
|
self::deprecationError(__FUNCTION__);
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
'name' => 'all',
|
'name' => 'all',
|
||||||
@ -62,11 +72,13 @@ class DynamicSegment extends MailPoetSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
|
self::deprecationError(__FUNCTION__);
|
||||||
DynamicSegmentFilter::where('segment_id', $this->id)->deleteMany();
|
DynamicSegmentFilter::where('segment_id', $this->id)->deleteMany();
|
||||||
return parent::delete();
|
return parent::delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function bulkTrash($orm) {
|
public static function bulkTrash($orm) {
|
||||||
|
self::deprecationError(__FUNCTION__);
|
||||||
$count = parent::bulkAction($orm, function($ids) {
|
$count = parent::bulkAction($orm, function($ids) {
|
||||||
$placeholders = join(',', array_fill(0, count($ids), '?'));
|
$placeholders = join(',', array_fill(0, count($ids), '?'));
|
||||||
DynamicSegment::rawExecute(join(' ', [
|
DynamicSegment::rawExecute(join(' ', [
|
||||||
@ -80,6 +92,7 @@ class DynamicSegment extends MailPoetSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function bulkDelete($orm) {
|
public static function bulkDelete($orm) {
|
||||||
|
self::deprecationError(__FUNCTION__);
|
||||||
$count = parent::bulkAction($orm, function($ids) {
|
$count = parent::bulkAction($orm, function($ids) {
|
||||||
$placeholders = join(',', array_fill(0, count($ids), '?'));
|
$placeholders = join(',', array_fill(0, count($ids), '?'));
|
||||||
DynamicSegmentFilter::rawExecute(join(' ', [
|
DynamicSegmentFilter::rawExecute(join(' ', [
|
||||||
@ -94,4 +107,16 @@ class DynamicSegment extends MailPoetSegment {
|
|||||||
|
|
||||||
return ['count' => $count];
|
return ['count' => $count];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This is here for displaying the deprecation warning for properties.
|
||||||
|
*/
|
||||||
|
public function __get($key) {
|
||||||
|
self::deprecationError('property "' . $key . '"');
|
||||||
|
return parent::__get($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function deprecationError($methodName) {
|
||||||
|
trigger_error('Calling ' . $methodName . ' is deprecated and will be removed. Use MailPoet\Segments\DynamicSegments\DynamicSegmentsListingRepository and respective Doctrine entities instead.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user