Add space between foreach and ‘(‘
[MAILPOET-1791]
This commit is contained in:
@@ -56,7 +56,7 @@ class Form extends Model {
|
||||
$skipped_types = array('html', 'divider', 'submit');
|
||||
$fields = array();
|
||||
|
||||
foreach((array)$body as $field) {
|
||||
foreach ((array)$body as $field) {
|
||||
if(empty($field['id'])
|
||||
|| empty($field['type'])
|
||||
|| in_array($field['type'], $skipped_types)
|
||||
|
@@ -141,7 +141,7 @@ class Model extends \Sudzy\ValidModel {
|
||||
|
||||
if(!empty($keys)) {
|
||||
$first = true;
|
||||
foreach($keys as $field => $value) {
|
||||
foreach ($keys as $field => $value) {
|
||||
if($first) {
|
||||
$model = static::where($field, $value);
|
||||
$first = false;
|
||||
@@ -337,7 +337,7 @@ class Model extends \Sudzy\ValidModel {
|
||||
|
||||
public function validate() {
|
||||
$success = true;
|
||||
foreach(array_keys($this->_validations) as $field) {
|
||||
foreach (array_keys($this->_validations) as $field) {
|
||||
$success = $success && $this->validateField($field, $this->$field);
|
||||
}
|
||||
$this->setError($this->getValidationErrors());
|
||||
|
@@ -23,7 +23,7 @@ class ModelValidator extends \Sudzy\Engine {
|
||||
|
||||
private function setupValidators() {
|
||||
$_this = $this;
|
||||
foreach($this->validators as $validator => $action) {
|
||||
foreach ($this->validators as $validator => $action) {
|
||||
$this->addValidator($validator, function($params) use ($action, $_this) {
|
||||
return call_user_func(array($_this, $action), $params);
|
||||
});
|
||||
@@ -44,4 +44,4 @@ class ModelValidator extends \Sudzy\Engine {
|
||||
}
|
||||
return (is_null($newsletter_body) || (is_array($newsletter_body) && !empty($newsletter_body['html']) && !empty($newsletter_body['text'])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -391,7 +391,7 @@ class Newsletter extends Model {
|
||||
$segments = $this->segments()->findMany();
|
||||
|
||||
if(!empty($segments)) {
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$relation = NewsletterSegment::create();
|
||||
$relation->segment_id = $segment->id;
|
||||
$relation->newsletter_id = $duplicate->id;
|
||||
@@ -404,7 +404,7 @@ class Newsletter extends Model {
|
||||
->findMany();
|
||||
|
||||
if(!empty($options)) {
|
||||
foreach($options as $option) {
|
||||
foreach ($options as $option) {
|
||||
$relation = NewsletterOption::create();
|
||||
$relation->newsletter_id = $duplicate->id;
|
||||
$relation->option_field_id = $option->option_field_id;
|
||||
@@ -450,7 +450,7 @@ class Newsletter extends Model {
|
||||
$segments = $this->segments()->findMany();
|
||||
|
||||
if(!empty($segments)) {
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$relation = NewsletterSegment::create();
|
||||
$relation->segment_id = $segment->id;
|
||||
$relation->newsletter_id = $notification_history->id;
|
||||
@@ -486,7 +486,7 @@ class Newsletter extends Model {
|
||||
->whereNotIn('segment_id', $segment_ids)->findArray();
|
||||
$deleted_segments = array();
|
||||
|
||||
foreach($links as $link) {
|
||||
foreach ($links as $link) {
|
||||
$deleted_segments[] = array(
|
||||
'id' => $link['segment_id'],
|
||||
'name' => __('Deleted list', 'mailpoet')
|
||||
@@ -565,7 +565,7 @@ class Newsletter extends Model {
|
||||
);
|
||||
$result = array();
|
||||
|
||||
foreach($statisticsExprs as $name => $statisticsExpr) {
|
||||
foreach ($statisticsExprs as $name => $statisticsExpr) {
|
||||
if(!in_array($this->type, array(self::TYPE_WELCOME, self::TYPE_AUTOMATIC))) {
|
||||
$row = $statisticsExpr->whereRaw('`queue_id` = ?', array($this->queue['id']))->findOne();
|
||||
} else {
|
||||
@@ -664,7 +664,7 @@ class Newsletter extends Model {
|
||||
'value' => ''
|
||||
);
|
||||
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$newsletters = $segment->newsletters()
|
||||
->filter('filterType', $type, $group)
|
||||
->filter('groupBy', $data);
|
||||
@@ -689,7 +689,7 @@ class Newsletter extends Model {
|
||||
static function filterBy($orm, $data = array()) {
|
||||
// apply filters
|
||||
if(!empty($data['filter'])) {
|
||||
foreach($data['filter'] as $key => $value) {
|
||||
foreach ($data['filter'] as $key => $value) {
|
||||
if($key === 'segment') {
|
||||
$segment = Segment::findOne($value);
|
||||
if($segment !== false) {
|
||||
@@ -720,7 +720,7 @@ class Newsletter extends Model {
|
||||
static function filterWithOptions($orm, $type) {
|
||||
$orm = $orm->select(MP_NEWSLETTERS_TABLE.'.*');
|
||||
$optionFields = NewsletterOptionField::findArray();
|
||||
foreach($optionFields as $optionField) {
|
||||
foreach ($optionFields as $optionField) {
|
||||
if($optionField['newsletter_type'] !== $type) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ class ScheduledTaskSubscriber extends Model {
|
||||
* For large batches use MailPoet\Segments\SubscribersFinder::addSubscribersToTaskFromSegments()
|
||||
*/
|
||||
static function addSubscribers($task_id, array $subscriber_ids) {
|
||||
foreach($subscriber_ids as $subscriber_id) {
|
||||
foreach ($subscriber_ids as $subscriber_id) {
|
||||
self::createOrUpdate(array(
|
||||
'task_id' => $task_id,
|
||||
'subscriber_id' => $subscriber_id
|
||||
|
@@ -49,7 +49,7 @@ class Segment extends Model {
|
||||
$duplicate = parent::duplicate($data);
|
||||
|
||||
if($duplicate !== false) {
|
||||
foreach($this->subscribers()->findResultSet() as $relation) {
|
||||
foreach ($this->subscribers()->findResultSet() as $relation) {
|
||||
$new_relation = SubscriberSegment::create();
|
||||
$new_relation->set('subscriber_id', $relation->id);
|
||||
$new_relation->set('segment_id', $duplicate->id);
|
||||
@@ -280,7 +280,7 @@ class Segment extends Model {
|
||||
->groupBy('type')
|
||||
->findArray();
|
||||
$result = array();
|
||||
foreach($analytics as $segment) {
|
||||
foreach ($analytics as $segment) {
|
||||
$result[$segment['type']] = $segment['count'];
|
||||
}
|
||||
return $result;
|
||||
|
@@ -25,7 +25,7 @@ class SendingQueue extends Model {
|
||||
const PRIORITY_LOW = 10;
|
||||
|
||||
private $emoji;
|
||||
|
||||
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
@@ -109,7 +109,7 @@ class SendingQueue extends Model {
|
||||
|
||||
function encodeEmojisInBody($newsletter_rendered_body) {
|
||||
if(is_array($newsletter_rendered_body)) {
|
||||
foreach($newsletter_rendered_body as $key => $value) {
|
||||
foreach ($newsletter_rendered_body as $key => $value) {
|
||||
$newsletter_rendered_body[$key] = $this->emoji->encodeForUTF8Column(
|
||||
self::$_table,
|
||||
'newsletter_rendered_body',
|
||||
@@ -122,7 +122,7 @@ class SendingQueue extends Model {
|
||||
|
||||
function decodeEmojisInBody($newsletter_rendered_body) {
|
||||
if(is_array($newsletter_rendered_body)) {
|
||||
foreach($newsletter_rendered_body as $key => $value) {
|
||||
foreach ($newsletter_rendered_body as $key => $value) {
|
||||
$newsletter_rendered_body[$key] = $this->emoji->decodeEntities($value);
|
||||
}
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ class Setting extends Model {
|
||||
$settingsCollection = self::findMany();
|
||||
$settings = array();
|
||||
if(!empty($settingsCollection)) {
|
||||
foreach($settingsCollection as $setting) {
|
||||
foreach ($settingsCollection as $setting) {
|
||||
$value = (is_serialized($setting->value)
|
||||
? unserialize($setting->value)
|
||||
: $setting->value
|
||||
|
@@ -8,7 +8,7 @@ class StatisticsNewsletters extends Model {
|
||||
|
||||
static function createMultiple(array $data) {
|
||||
$values = array();
|
||||
foreach($data as $value) {
|
||||
foreach ($data as $value) {
|
||||
if(!empty($value['newsletter_id']) &&
|
||||
!empty($value['subscriber_id']) &&
|
||||
!empty($value['queue_id'])
|
||||
|
@@ -242,7 +242,7 @@ class Subscriber extends Model {
|
||||
'value' => 'none'
|
||||
);
|
||||
|
||||
foreach($segments as $segment) {
|
||||
foreach ($segments as $segment) {
|
||||
$subscribers_count = $segment->subscribers()
|
||||
->filter('groupBy', $group)
|
||||
->count();
|
||||
@@ -270,7 +270,7 @@ class Subscriber extends Model {
|
||||
if(empty($filters)) {
|
||||
return $orm;
|
||||
}
|
||||
foreach($filters as $key => $value) {
|
||||
foreach ($filters as $key => $value) {
|
||||
if($key === 'segment') {
|
||||
if($value === 'none') {
|
||||
return self::filter('withoutSegments');
|
||||
@@ -333,7 +333,7 @@ class Subscriber extends Model {
|
||||
static function filterWithCustomFields($orm) {
|
||||
$orm = $orm->select(MP_SUBSCRIBERS_TABLE.'.*');
|
||||
$customFields = CustomField::findArray();
|
||||
foreach($customFields as $customField) {
|
||||
foreach ($customFields as $customField) {
|
||||
$orm = $orm->select_expr(
|
||||
'IFNULL(GROUP_CONCAT(CASE WHEN ' .
|
||||
MP_CUSTOM_FIELDS_TABLE . '.id=' . $customField['id'] . ' THEN ' .
|
||||
@@ -363,7 +363,7 @@ class Subscriber extends Model {
|
||||
static function filterWithCustomFieldsForExport($orm) {
|
||||
$orm = $orm->select(MP_SUBSCRIBERS_TABLE.'.*');
|
||||
$customFields = CustomField::findArray();
|
||||
foreach($customFields as $customField) {
|
||||
foreach ($customFields as $customField) {
|
||||
$orm = $orm->selectExpr(
|
||||
'MAX(CASE WHEN ' .
|
||||
MP_CUSTOM_FIELDS_TABLE . '.id=' . $customField['id'] . ' THEN ' .
|
||||
@@ -493,7 +493,7 @@ class Subscriber extends Model {
|
||||
->whereIn('custom_field_id', $custom_field_ids)
|
||||
->where('subscriber_id', $this->id())
|
||||
->findMany();
|
||||
foreach($relations as $relation) {
|
||||
foreach ($relations as $relation) {
|
||||
$this->{'cf_'.$relation->custom_field_id} = $relation->value;
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ class Subscriber extends Model {
|
||||
// get custom fields
|
||||
$custom_fields = CustomField::whereIdIn($custom_field_ids)->findMany();
|
||||
|
||||
foreach($custom_fields as $custom_field) {
|
||||
foreach ($custom_fields as $custom_field) {
|
||||
$value = (isset($custom_fields_data[$custom_field->id])
|
||||
? $custom_fields_data[$custom_field->id]
|
||||
: null
|
||||
@@ -646,7 +646,7 @@ class Subscriber extends Model {
|
||||
$emails_sent = 0;
|
||||
if(!empty($subscribers)) {
|
||||
$sender = new ConfirmationEmailMailer();
|
||||
foreach($subscribers as $subscriber) {
|
||||
foreach ($subscribers as $subscriber) {
|
||||
if($sender->sendConfirmationEmail($subscriber)) {
|
||||
$emails_sent++;
|
||||
}
|
||||
@@ -830,7 +830,7 @@ class Subscriber extends Model {
|
||||
'last_name' => '',
|
||||
'status' => (!$settings->get('signup_confirmation.enabled')) ? self::STATUS_SUBSCRIBED : self::STATUS_UNCONFIRMED
|
||||
);
|
||||
foreach($required_field_default_values as $field => $value) {
|
||||
foreach ($required_field_default_values as $field => $value) {
|
||||
if(!isset($data[$field])) {
|
||||
$data[$field] = $value;
|
||||
}
|
||||
@@ -840,7 +840,7 @@ class Subscriber extends Model {
|
||||
|
||||
static function extractCustomFieldsFromFromObject($data) {
|
||||
$custom_fields = array();
|
||||
foreach($data as $key => $value) {
|
||||
foreach ($data as $key => $value) {
|
||||
if(strpos($key, 'cf_') === 0) {
|
||||
$custom_fields[(int)substr($key, 3)] = $value;
|
||||
unset($data[$key]);
|
||||
|
@@ -23,7 +23,7 @@ class SubscriberSegment extends Model {
|
||||
|
||||
if(!empty($segment_ids)) {
|
||||
// unsubscribe from segments
|
||||
foreach($segment_ids as $segment_id) {
|
||||
foreach ($segment_ids as $segment_id) {
|
||||
|
||||
// do not remove subscriptions to the WP Users or WooCommerce Customers segments
|
||||
if(($wp_segment !== false && (int)$wp_segment->id === (int)$segment_id)
|
||||
@@ -75,7 +75,7 @@ class SubscriberSegment extends Model {
|
||||
if($subscriber === false) return false;
|
||||
if(!empty($segment_ids)) {
|
||||
// subscribe to specified segments
|
||||
foreach($segment_ids as $segment_id) {
|
||||
foreach ($segment_ids as $segment_id) {
|
||||
if((int)$segment_id > 0) {
|
||||
self::createOrUpdate(array(
|
||||
'subscriber_id' => $subscriber->id,
|
||||
@@ -104,8 +104,8 @@ class SubscriberSegment extends Model {
|
||||
// create many subscriptions to each segment
|
||||
$values = array();
|
||||
$row_count = 0;
|
||||
foreach($segment_ids as &$segment_id) {
|
||||
foreach($subscriber_ids as &$subscriber_id) {
|
||||
foreach ($segment_ids as &$segment_id) {
|
||||
foreach ($subscriber_ids as &$subscriber_id) {
|
||||
$values[] = (int)$subscriber_id;
|
||||
$values[] = (int)$segment_id;
|
||||
$row_count++;
|
||||
|
Reference in New Issue
Block a user