Files
piratepoet/lib/API/JSON/v1/UserFlags.php
Jan Jakeš 01a0fe96c4 Remove no longer necessary checks
[MAILPOET-1948]
2019-09-12 13:59:32 +02:00

39 lines
944 B
PHP

<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Settings\UserFlagsController;
use MailPoet\WP\Functions as WPFunctions;
class UserFlags extends APIEndpoint {
/** @var UserFlagsController */
private $user_flags;
public $permissions = [
'global' => AccessControl::ALL_ROLES_ACCESS,
];
function __construct(UserFlagsController $user_flags) {
$this->user_flags = $user_flags;
}
function set(array $flags = []) {
if (empty($flags)) {
return $this->badRequest(
[
APIError::BAD_REQUEST =>
WPFunctions::get()->__('You have not specified any user flags to be saved.', 'mailpoet'),
]);
} else {
foreach ($flags as $name => $value) {
$this->user_flags->set($name, $value);
}
return $this->successResponse([]);
}
}
}