<?php namespace MailPoet\Models; if (!defined('ABSPATH')) exit; use MailPoet\Entities\SegmentEntity; use MailPoet\Models\Segment as MailPoetSegment; 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 string $name * @property string $description * @property string $createdAt * @property string $updatedAt * @property string|null $deletedAt */ class DynamicSegment extends MailPoetSegment { const TYPE_DYNAMIC = SegmentEntity::TYPE_DYNAMIC; public function save() { self::deprecationError(__FUNCTION__); $this->set('type', DynamicSegment::TYPE_DYNAMIC); return parent::save(); } public function dynamicSegmentFilters() { self::deprecationError(__FUNCTION__); return $this->has_many(__NAMESPACE__ . '\DynamicSegmentFilter', 'segment_id'); } public static function findAll() { self::deprecationError(__FUNCTION__); $query = self::select('*'); return $query->where('type', DynamicSegment::TYPE_DYNAMIC) ->whereNull('deleted_at') ->findMany(); } public static function listingQuery(array $data = []) { self::deprecationError(__FUNCTION__); $query = self::select('*'); $query->where('type', DynamicSegment::TYPE_DYNAMIC); if (isset($data['group'])) { $query->filter('groupBy', $data['group']); } if (isset($data['search'])) { $query->filter('search', $data['search']); } return $query; } public static function groups() { self::deprecationError(__FUNCTION__); return [ [ 'name' => 'all', 'label' => WPFunctions::get()->__('All', 'mailpoet'), 'count' => DynamicSegment::getPublished()->where('type', DynamicSegment::TYPE_DYNAMIC)->count(), ], [ 'name' => 'trash', 'label' => WPFunctions::get()->__('Trash', 'mailpoet'), 'count' => parent::getTrashed()->where('type', DynamicSegment::TYPE_DYNAMIC)->count(), ], ]; } public function delete() { self::deprecationError(__FUNCTION__); DynamicSegmentFilter::where('segment_id', $this->id)->deleteMany(); return parent::delete(); } public static function bulkTrash($orm) { self::deprecationError(__FUNCTION__); $count = parent::bulkAction($orm, function($ids) { $placeholders = join(',', array_fill(0, count($ids), '?')); DynamicSegment::rawExecute(join(' ', [ 'UPDATE `' . DynamicSegment::$_table . '`', 'SET `deleted_at` = NOW()', 'WHERE `id` IN (' . $placeholders . ')', ]), $ids); }); return ['count' => $count]; } public static function bulkDelete($orm) { self::deprecationError(__FUNCTION__); $count = parent::bulkAction($orm, function($ids) { $placeholders = join(',', array_fill(0, count($ids), '?')); DynamicSegmentFilter::rawExecute(join(' ', [ 'DELETE FROM `' . DynamicSegmentFilter::$_table . '`', 'WHERE `segment_id` IN (' . $placeholders . ')', ]), $ids); DynamicSegment::rawExecute(join(' ', [ 'DELETE FROM `' . DynamicSegment::$_table . '`', 'WHERE `id` IN (' . $placeholders . ')', ]), $ids); }); 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); } /** * @deprecated This is here for displaying the deprecation warning for static calls. */ public static function __callStatic($name, $arguments) { self::deprecationError($name); return parent::__callStatic($name, $arguments); } 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); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
CustomField.php | File | 3.79 KB | 0644 |
|
DynamicSegment.php | File | 4.05 KB | 0644 |
|
DynamicSegmentFilter.php | File | 1.35 KB | 0644 |
|
Form.php | File | 4.02 KB | 0644 |
|
MappingToExternalEntities.php | File | 378 B | 0644 |
|
Model.php | File | 13.58 KB | 0644 |
|
ModelValidator.php | File | 2.44 KB | 0644 |
|
Newsletter.php | File | 15.14 KB | 0644 |
|
NewsletterLink.php | File | 530 B | 0644 |
|
NewsletterOption.php | File | 670 B | 0644 |
|
NewsletterOptionField.php | File | 939 B | 0644 |
|
NewsletterSegment.php | File | 312 B | 0644 |
|
ScheduledTask.php | File | 6.58 KB | 0644 |
|
ScheduledTaskSubscriber.php | File | 5.31 KB | 0644 |
|
Segment.php | File | 10.89 KB | 0644 |
|
SendingQueue.php | File | 4.31 KB | 0644 |
|
StatisticsClicks.php | File | 1.08 KB | 0644 |
|
StatisticsForms.php | File | 1.85 KB | 0644 |
|
StatisticsNewsletters.php | File | 1.61 KB | 0644 |
|
StatisticsOpens.php | File | 807 B | 0644 |
|
StatisticsUnsubscribes.php | File | 821 B | 0644 |
|
StatisticsWooCommercePurchases.php | File | 1.5 KB | 0644 |
|
Subscriber.php | File | 20.83 KB | 0644 |
|
SubscriberCustomField.php | File | 2.5 KB | 0644 |
|
SubscriberIP.php | File | 1.12 KB | 0644 |
|
SubscriberSegment.php | File | 5.2 KB | 0644 |
|
index.php | File | 0 B | 0644 |
|