Add support for camel case properties to old models
[MAILPOET-1796]
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace MailPoet\Models;
|
namespace MailPoet\Models;
|
||||||
|
|
||||||
use MailPoet\Models\Model;
|
use MailPoet\Models\Model;
|
||||||
|
use MailPoet\Util\Helpers;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,6 +36,7 @@ class DynamicSegmentFilter extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function __get($name) {
|
public function __get($name) {
|
||||||
|
$name = Helpers::camelCaseToUnderscore($name);
|
||||||
$value = parent::__get($name);
|
$value = parent::__get($name);
|
||||||
if ($name === 'filter_data' && WPFunctions::get()->isSerialized($value)) {
|
if ($name === 'filter_data' && WPFunctions::get()->isSerialized($value)) {
|
||||||
return unserialize($value);
|
return unserialize($value);
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace MailPoet\Models;
|
namespace MailPoet\Models;
|
||||||
|
|
||||||
|
use MailPoet\Util\Helpers;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -374,4 +375,23 @@ class Model extends \MailPoetVendor\Sudzy\ValidModel {
|
|||||||
$this->setError($this->getValidationErrors());
|
$this->setError($this->getValidationErrors());
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __get($name) {
|
||||||
|
$value = parent::__get($name);
|
||||||
|
if ($value !== null) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
$name = Helpers::camelCaseToUnderscore($name);
|
||||||
|
return parent::__get($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __set($name, $value) {
|
||||||
|
$name = Helpers::camelCaseToUnderscore($name);
|
||||||
|
return parent::__set($name, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __isset($name) {
|
||||||
|
$name = Helpers::camelCaseToUnderscore($name);
|
||||||
|
return parent::__isset($name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ namespace MailPoet\Tasks;
|
|||||||
use MailPoet\Models\ScheduledTask;
|
use MailPoet\Models\ScheduledTask;
|
||||||
use MailPoet\Models\ScheduledTaskSubscriber;
|
use MailPoet\Models\ScheduledTaskSubscriber;
|
||||||
use MailPoet\Models\SendingQueue;
|
use MailPoet\Models\SendingQueue;
|
||||||
|
use MailPoet\Util\Helpers;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
use MailPoetVendor\Carbon\Carbon;
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
|
|
||||||
@@ -216,6 +217,7 @@ class Sending {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function __isset($prop) {
|
public function __isset($prop) {
|
||||||
|
$prop = Helpers::camelCaseToUnderscore($prop);
|
||||||
if ($this->isQueueProperty($prop)) {
|
if ($this->isQueueProperty($prop)) {
|
||||||
return isset($this->queue->$prop);
|
return isset($this->queue->$prop);
|
||||||
} else {
|
} else {
|
||||||
@@ -224,6 +226,7 @@ class Sending {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function __get($prop) {
|
public function __get($prop) {
|
||||||
|
$prop = Helpers::camelCaseToUnderscore($prop);
|
||||||
if ($this->isQueueProperty($prop)) {
|
if ($this->isQueueProperty($prop)) {
|
||||||
return $this->queue->$prop;
|
return $this->queue->$prop;
|
||||||
} else {
|
} else {
|
||||||
@@ -232,6 +235,7 @@ class Sending {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function __set($prop, $value) {
|
public function __set($prop, $value) {
|
||||||
|
$prop = Helpers::camelCaseToUnderscore($prop);
|
||||||
if ($this->isCommonProperty($prop)) {
|
if ($this->isCommonProperty($prop)) {
|
||||||
$this->queue->$prop = $value;
|
$this->queue->$prop = $value;
|
||||||
$this->task->$prop = $value;
|
$this->task->$prop = $value;
|
||||||
|
Reference in New Issue
Block a user