NotificationPusher icon indicating copy to clipboard operation
NotificationPusher copied to clipboard

Remove token.

Open michaeljcoyne opened this issue 9 years ago • 2 comments

When the class calls this function

private function checkDevicesTokens()
    {
        $devices = $this->getDevices();
        $adapter = $this->getAdapter();

        foreach ($devices as $device) {
            if (false === $adapter->supports($device->getToken())) {
                throw new AdapterException(
                    sprintf(
                        'Adapter %s does not support %s token\'s device',
                        (string) $adapter,
                        $device->getToken()
                    )
                );
            }
        }
    }

instead of throwing a new exception. Is there a way to just remove the token from the iterator object? And then the script would not die and just cleanse / purge the token list.

michaeljcoyne avatar Nov 08 '16 11:11 michaeljcoyne

This function is not supposed to have a heavy overhead (regarding to the original purpose that it have been developed for). Therefore, I suggest to add an API-function (preferably public function inside the class) that does similar loop to this one, except it must have a flag-check (boolean for "either skip or force to send the push after encountering error") and then do the logic and [if necessary] logging after the original loop-logic.

aliemam avatar Feb 25 '18 14:02 aliemam

@aliemam, I agree, but the name is like filterSupportedTokens() and without exception.

seyfer avatar Feb 26 '18 08:02 seyfer