Files
piratepoet/mailpoet/lib/API/JSON/v1/UserFlags.php
David Remer b05e6d414c Remove WP\Functions::__ and other translate functions
Under the new sniffer rules, those functions produce errors and, when those methods
are used, the sniffer can not properly be applied.

[MAILPOET-4524]
2022-08-09 13:23:16 +02:00

40 lines
899 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;
class UserFlags extends APIEndpoint {
/** @var UserFlagsController */
private $userFlags;
public $permissions = [
'global' => AccessControl::ALL_ROLES_ACCESS,
];
public function __construct(
UserFlagsController $userFlags
) {
$this->userFlags = $userFlags;
}
public function set(array $flags = []) {
if (empty($flags)) {
return $this->badRequest(
[
APIError::BAD_REQUEST =>
__('You have not specified any user flags to be saved.', 'mailpoet'),
]);
} else {
foreach ($flags as $name => $value) {
$this->userFlags->set($name, $value);
}
return $this->successResponse([]);
}
}
}