mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
abstract class StoreAction to enum
This commit is contained in:
parent
d0dc8c305a
commit
851c1b6472
3 changed files with 13 additions and 13 deletions
|
|
@ -354,11 +354,10 @@ trait Messages
|
|||
* @throws \MailSo\RuntimeException
|
||||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
* $sStoreAction = \MailSo\Imap\Enumerations\StoreAction::ADD_FLAGS_SILENT
|
||||
*/
|
||||
public function MessageStoreFlag(SequenceSet $oRange, array $aInputStoreItems, string $sStoreAction) : ?ResponseCollection
|
||||
public function MessageStoreFlag(SequenceSet $oRange, array $aInputStoreItems, StoreAction $eStoreAction) : ?ResponseCollection
|
||||
{
|
||||
if (!\count($oRange) || !\strlen(\trim($sStoreAction)) || !\count($aInputStoreItems)) {
|
||||
if (!\count($oRange) || !\count($aInputStoreItems)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +371,7 @@ trait Messages
|
|||
|
||||
return $this->SendRequestGetResponse(
|
||||
$oRange->UID ? 'UID STORE' : 'STORE',
|
||||
array((string) $oRange, $sStoreAction, $aInputStoreItems)
|
||||
array((string) $oRange, $eStoreAction->value, $aInputStoreItems)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ namespace MailSo\Imap\Enumerations;
|
|||
* @package Imap
|
||||
* @subpackage Enumerations
|
||||
*/
|
||||
abstract class StoreAction
|
||||
enum StoreAction: string
|
||||
{
|
||||
// const SET_FLAGS = 'FLAGS';
|
||||
// const SET_FLAGS_SILENT = 'FLAGS.SILENT';
|
||||
const ADD_FLAGS = '+FLAGS';
|
||||
const ADD_FLAGS_SILENT = '+FLAGS.SILENT';
|
||||
const REMOVE_FLAGS = '-FLAGS';
|
||||
const REMOVE_FLAGS_SILENT = '-FLAGS.SILENT';
|
||||
// case SET_FLAGS = 'FLAGS';
|
||||
// case SET_FLAGS_SILENT = 'FLAGS.SILENT';
|
||||
case ADD_FLAGS = '+FLAGS';
|
||||
case ADD_FLAGS_SILENT = '+FLAGS.SILENT';
|
||||
case REMOVE_FLAGS = '-FLAGS';
|
||||
case REMOVE_FLAGS_SILENT = '-FLAGS.SILENT';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,8 +103,9 @@ class MailClient
|
|||
{
|
||||
if (\count($oRange)) {
|
||||
if ($this->oImapClient->FolderSelect($sFolderName)->IsFlagSupported($sMessageFlag)) {
|
||||
$sStoreAction = $bSetAction ? StoreAction::ADD_FLAGS_SILENT : StoreAction::REMOVE_FLAGS_SILENT;
|
||||
$this->oImapClient->MessageStoreFlag($oRange, array($sMessageFlag), $sStoreAction);
|
||||
$this->oImapClient->MessageStoreFlag($oRange, array($sMessageFlag),
|
||||
$bSetAction ? StoreAction::ADD_FLAGS_SILENT : StoreAction::REMOVE_FLAGS_SILENT
|
||||
);
|
||||
} else if (!$bSkipUnsupportedFlag) {
|
||||
throw new \MailSo\RuntimeException('Message flag "'.$sMessageFlag.'" is not supported.');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue