composer-update-patch
This commit is contained in:
		| @@ -38,6 +38,13 @@ interface AdapterInterface | ||||
|      */ | ||||
|     public function supports($token); | ||||
|  | ||||
|     /** | ||||
|      * Get defined parameters. | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function getDefinedParameters(); | ||||
|  | ||||
|     /** | ||||
|      * Get default parameters. | ||||
|      * | ||||
|   | ||||
| @@ -11,8 +11,8 @@ | ||||
|  | ||||
| namespace Sly\NotificationPusher\Adapter; | ||||
|  | ||||
| use Sly\NotificationPusher\Model\BaseOptionedModel; | ||||
| use Sly\NotificationPusher\Model\PushInterface; | ||||
| use Sly\NotificationPusher\Model\MessageInterface; | ||||
| use Sly\NotificationPusher\Model\DeviceInterface; | ||||
| use Sly\NotificationPusher\Exception\AdapterException; | ||||
| use Sly\NotificationPusher\Exception\PushException; | ||||
| @@ -30,18 +30,24 @@ use ZendService\Apple\Apns\Client\Feedback as ServiceFeedbackClient; | ||||
|  * APNS adapter. | ||||
|  * | ||||
|  * @uses \Sly\NotificationPusher\Adapter\BaseAdapter | ||||
|  * @uses \Sly\NotificationPusher\Adapter\AdapterInterface | ||||
|  * | ||||
|  * @author Cédric Dugat <cedric@dugat.me> | ||||
|  */ | ||||
| class Apns extends BaseAdapter implements AdapterInterface | ||||
| class Apns extends BaseAdapter | ||||
| { | ||||
|  | ||||
|     /** @var ServiceClient */ | ||||
|     private $openedClient; | ||||
|  | ||||
|     /** @var ServiceFeedbackClient */ | ||||
|     private $feedbackClient; | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @throws \Sly\NotificationPusher\Exception\AdapterException | ||||
|      */ | ||||
|     public function __construct(array $parameters = array()) | ||||
|     public function __construct(array $parameters = []) | ||||
|     { | ||||
|         parent::__construct($parameters); | ||||
|  | ||||
| @@ -59,7 +65,7 @@ class Apns extends BaseAdapter implements AdapterInterface | ||||
|      */ | ||||
|     public function push(PushInterface $push) | ||||
|     { | ||||
|         $client = $this->getOpenedClient(new ServiceClient()); | ||||
|         $client = $this->getOpenedServiceClient(); | ||||
|  | ||||
|         $pushedDevices = new DeviceCollection(); | ||||
|  | ||||
| @@ -77,8 +83,6 @@ class Apns extends BaseAdapter implements AdapterInterface | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $client->close(); | ||||
|  | ||||
|         return $pushedDevices; | ||||
|     } | ||||
|  | ||||
| @@ -89,13 +93,12 @@ class Apns extends BaseAdapter implements AdapterInterface | ||||
|      */ | ||||
|     public function getFeedback() | ||||
|     { | ||||
|         $client           = $this->getOpenedClient(new ServiceFeedbackClient()); | ||||
|         $responses        = array(); | ||||
|         $client           = $this->getOpenedFeedbackClient(); | ||||
|         $responses        = []; | ||||
|         $serviceResponses = $client->feedback(); | ||||
|         $client->close(); | ||||
|  | ||||
|         foreach ($serviceResponses as $response) { | ||||
|             $responses[$response->getToken()] = new \DateTime(date("c", $response->getTime())); | ||||
|             $responses[$response->getToken()] = new \DateTime(date('c', $response->getTime())); | ||||
|         } | ||||
|  | ||||
|         return $responses; | ||||
| @@ -119,29 +122,62 @@ class Apns extends BaseAdapter implements AdapterInterface | ||||
|         return $client; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get opened ServiceClient | ||||
|      * | ||||
|      * @return ServiceAbstractClient | ||||
|      */ | ||||
|     private function getOpenedServiceClient() | ||||
|     { | ||||
|         if (!isset($this->openedClient)) { | ||||
|             $this->openedClient = $this->getOpenedClient(new ServiceClient()); | ||||
|         } | ||||
|  | ||||
|         return $this->openedClient; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get opened ServiceFeedbackClient | ||||
|      * | ||||
|      * @return ServiceAbstractClient | ||||
|      */ | ||||
|     private function getOpenedFeedbackClient() | ||||
|     { | ||||
|         if (!isset($this->feedbackClient)) { | ||||
|             $this->feedbackClient = $this->getOpenedClient(new ServiceFeedbackClient()); | ||||
|         } | ||||
|  | ||||
|         return $this->feedbackClient; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get service message from origin. | ||||
|      * | ||||
|      * @param \Sly\NotificationPusher\Model\DeviceInterface  $device  Device | ||||
|      * @param \Sly\NotificationPusher\Model\MessageInterface $message Message | ||||
|      * @param \Sly\NotificationPusher\Model\DeviceInterface $device Device | ||||
|      * @param BaseOptionedModel|\Sly\NotificationPusher\Model\MessageInterface $message Message | ||||
|      * | ||||
|      * @return \ZendService\Apple\Apns\Message | ||||
|      */ | ||||
|     public function getServiceMessageFromOrigin(DeviceInterface $device, MessageInterface $message) | ||||
|     public function getServiceMessageFromOrigin(DeviceInterface $device, BaseOptionedModel $message) | ||||
|     { | ||||
|         $badge = ($message->hasOption('badge')) | ||||
|             ? (int) ($message->getOption('badge') + $device->getParameter('badge', 0)) | ||||
|             : 0 | ||||
|             : false | ||||
|         ; | ||||
|  | ||||
|         $sound = $message->getOption('sound', 'bingbong.aiff'); | ||||
|         $contentAvailable = $message->getOption('content-available'); | ||||
|         $category = $message->getOption('category'); | ||||
|  | ||||
|         $alert = new ServiceAlert( | ||||
|             $message->getText(), | ||||
|             $message->getOption('actionLocKey'), | ||||
|             $message->getOption('locKey'), | ||||
|             $message->getOption('locArgs'), | ||||
|             $message->getOption('launchImage') | ||||
|             $message->getOption('launchImage'), | ||||
|             $message->getOption('title'), | ||||
|             $message->getOption('titleLocKey'), | ||||
|             $message->getOption('titleLocArgs') | ||||
|         ); | ||||
|         if ($actionLocKey = $message->getOption('actionLocKey')) { | ||||
|             $alert->setActionLocKey($actionLocKey); | ||||
| @@ -155,18 +191,37 @@ class Apns extends BaseAdapter implements AdapterInterface | ||||
|         if ($launchImage = $message->getOption('launchImage')) { | ||||
|             $alert->setLaunchImage($launchImage); | ||||
|         } | ||||
|         if ($title = $message->getOption('title')) { | ||||
|             $alert->setTitle($title); | ||||
|         } | ||||
|         if ($titleLocKey = $message->getOption('titleLocKey')) { | ||||
|             $alert->setTitleLocKey($titleLocKey); | ||||
|         } | ||||
|         if ($titleLocArgs = $message->getOption('titleLocArgs')) { | ||||
|             $alert->setTitleLocArgs($titleLocArgs); | ||||
|         } | ||||
|  | ||||
|         $serviceMessage = new ServiceMessage(); | ||||
|         $serviceMessage->setId(sha1($device->getToken().$message->getText())); | ||||
|         $serviceMessage->setAlert($alert); | ||||
|         $serviceMessage->setToken($device->getToken()); | ||||
|         $serviceMessage->setBadge($badge); | ||||
|         $serviceMessage->setCustom($message->getOption('custom', array())); | ||||
|         if (false !== $badge) { | ||||
|             $serviceMessage->setBadge($badge); | ||||
|         } | ||||
|         $serviceMessage->setCustom($message->getOption('custom', [])); | ||||
|  | ||||
|         if (null !== $sound) { | ||||
|             $serviceMessage->setSound($sound); | ||||
|         } | ||||
|  | ||||
|         if (null !== $contentAvailable) { | ||||
|             $serviceMessage->setContentAvailable($contentAvailable); | ||||
|         } | ||||
|  | ||||
|         if (null !== $category) { | ||||
|             $serviceMessage->setCategory($category); | ||||
|         } | ||||
|  | ||||
|         return $serviceMessage; | ||||
|     } | ||||
|  | ||||
| @@ -178,12 +233,20 @@ class Apns extends BaseAdapter implements AdapterInterface | ||||
|         return (ctype_xdigit($token) && 64 == strlen($token)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      */ | ||||
|     public function getDefinedParameters() | ||||
|     { | ||||
|         return []; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      */ | ||||
|     public function getDefaultParameters() | ||||
|     { | ||||
|         return array('passPhrase' => null); | ||||
|         return ['passPhrase' => null]; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -191,6 +254,6 @@ class Apns extends BaseAdapter implements AdapterInterface | ||||
|      */ | ||||
|     public function getRequiredParameters() | ||||
|     { | ||||
|         return array('certificate'); | ||||
|         return ['certificate']; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -21,7 +21,7 @@ use Sly\NotificationPusher\PushManager; | ||||
|  * | ||||
|  * @author Cédric Dugat <cedric@dugat.me> | ||||
|  */ | ||||
| abstract class BaseAdapter extends BaseParameteredModel | ||||
| abstract class BaseAdapter extends BaseParameteredModel implements AdapterInterface | ||||
| { | ||||
|     /** | ||||
|      * @var string | ||||
| @@ -43,9 +43,10 @@ abstract class BaseAdapter extends BaseParameteredModel | ||||
|      * | ||||
|      * @param array $parameters Adapter specific parameters | ||||
|      */ | ||||
|     public function __construct(array $parameters = array()) | ||||
|     public function __construct(array $parameters = []) | ||||
|     { | ||||
|         $resolver = new OptionsResolver(); | ||||
|         $resolver->setDefined($this->getDefinedParameters()); | ||||
|         $resolver->setDefaults($this->getDefaultParameters()); | ||||
|         $resolver->setRequired($this->getRequiredParameters()); | ||||
|  | ||||
| @@ -66,7 +67,7 @@ abstract class BaseAdapter extends BaseParameteredModel | ||||
|  | ||||
|     /** | ||||
|      * Return the original response. | ||||
|      *  | ||||
|      * | ||||
|      * @return mixed | ||||
|      */ | ||||
|     public function getResponse() | ||||
|   | ||||
| @@ -11,8 +11,8 @@ | ||||
|  | ||||
| namespace Sly\NotificationPusher\Adapter; | ||||
|  | ||||
| use Sly\NotificationPusher\Model\BaseOptionedModel; | ||||
| use Sly\NotificationPusher\Model\PushInterface; | ||||
| use Sly\NotificationPusher\Model\MessageInterface; | ||||
| use Sly\NotificationPusher\Collection\DeviceCollection; | ||||
| use Sly\NotificationPusher\Exception\PushException; | ||||
|  | ||||
| @@ -29,23 +29,27 @@ use InvalidArgumentException; | ||||
|  * GCM adapter. | ||||
|  * | ||||
|  * @uses \Sly\NotificationPusher\Adapter\BaseAdapter | ||||
|  * @uses \Sly\NotificationPusher\Adapter\AdapterInterface | ||||
|  * | ||||
|  * @author Cédric Dugat <cedric@dugat.me> | ||||
|  */ | ||||
| class Gcm extends BaseAdapter implements AdapterInterface | ||||
| class Gcm extends BaseAdapter | ||||
| { | ||||
|     /** | ||||
|      * @var \Zend\Http\Client | ||||
|      */ | ||||
|     private $httpClient; | ||||
|      | ||||
|  | ||||
|     /** | ||||
|      * @var ServiceClient | ||||
|      */ | ||||
|     private $openedClient; | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      */ | ||||
|     public function supports($token) | ||||
|     { | ||||
|         return (bool) preg_match('/[0-9a-zA-Z\-\_]/i', $token); | ||||
|         return is_string($token) && $token != ''; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -55,7 +59,7 @@ class Gcm extends BaseAdapter implements AdapterInterface | ||||
|      */ | ||||
|     public function push(PushInterface $push) | ||||
|     { | ||||
|         $client        = $this->getOpenedClient(new ServiceClient()); | ||||
|         $client        = $this->getOpenedClient(); | ||||
|         $pushedDevices = new DeviceCollection(); | ||||
|         $tokens        = array_chunk($push->getDevices()->getTokens(), 100); | ||||
|  | ||||
| @@ -81,30 +85,37 @@ class Gcm extends BaseAdapter implements AdapterInterface | ||||
|     /** | ||||
|      * Get opened client. | ||||
|      * | ||||
|      * @param \ZendService\Google\Gcm\Client $client Client | ||||
|      * | ||||
|      * @return \ZendService\Google\Gcm\Client | ||||
|      */ | ||||
|     public function getOpenedClient(ServiceClient $client) | ||||
|     public function getOpenedClient() | ||||
|     { | ||||
|         $client->setApiKey($this->getParameter('apiKey')); | ||||
|          | ||||
|         if ($this->httpClient !== null) { | ||||
|             $client->setHttpClient($this->httpClient); | ||||
|         if (!isset($this->openedClient)) { | ||||
|             $this->openedClient = new ServiceClient(); | ||||
|             $this->openedClient->setApiKey($this->getParameter('apiKey')); | ||||
|  | ||||
|             $newClient = new \Zend\Http\Client( | ||||
|                 null, | ||||
|                 [ | ||||
|                     'adapter' => 'Zend\Http\Client\Adapter\Socket', | ||||
|                     'sslverifypeer' => false | ||||
|                 ] | ||||
|             ); | ||||
|  | ||||
|             $this->openedClient->setHttpClient($newClient); | ||||
|         } | ||||
|  | ||||
|         return $client; | ||||
|         return $this->openedClient; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get service message from origin. | ||||
|      * | ||||
|      * @param array                                 $tokens  Tokens | ||||
|      * @param \Sly\NotificationPusher\Model\MessageInterface $message Message | ||||
|      * @param array $tokens Tokens | ||||
|      * @param BaseOptionedModel|\Sly\NotificationPusher\Model\MessageInterface $message Message | ||||
|      * | ||||
|      * @return \ZendService\Google\Gcm\Message | ||||
|      */ | ||||
|     public function getServiceMessageFromOrigin(array $tokens, MessageInterface $message) | ||||
|     public function getServiceMessageFromOrigin(array $tokens, BaseOptionedModel $message) | ||||
|     { | ||||
|         $data            = $message->getOptions(); | ||||
|         $data['message'] = $message->getText(); | ||||
| @@ -121,12 +132,26 @@ class Gcm extends BaseAdapter implements AdapterInterface | ||||
|         return $serviceMessage; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      */ | ||||
|     public function getDefinedParameters() | ||||
|     { | ||||
|         return [ | ||||
|             'collapse_key', | ||||
|             'delay_while_idle', | ||||
|             'time_to_live', | ||||
|             'restricted_package_name', | ||||
|             'dry_run' | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      */ | ||||
|     public function getDefaultParameters() | ||||
|     { | ||||
|         return array(); | ||||
|         return []; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -134,10 +159,9 @@ class Gcm extends BaseAdapter implements AdapterInterface | ||||
|      */ | ||||
|     public function getRequiredParameters() | ||||
|     { | ||||
|         return array('apiKey'); | ||||
|         return ['apiKey']; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * Get the current Zend Http Client instance. | ||||
|      * | ||||
| @@ -150,7 +174,7 @@ class Gcm extends BaseAdapter implements AdapterInterface | ||||
|  | ||||
|     /** | ||||
|      * Overrides the default Http Client. | ||||
|      *  | ||||
|      * | ||||
|      * @param HttpClient $client | ||||
|      */ | ||||
|     public function setHttpClient(HttpClient $client) | ||||
| @@ -160,12 +184,12 @@ class Gcm extends BaseAdapter implements AdapterInterface | ||||
|  | ||||
|     /** | ||||
|      * Send custom parameters to the Http Adapter without overriding the Http Client. | ||||
|      *  | ||||
|      * | ||||
|      * @param array $config | ||||
|      * | ||||
|      * @throws \InvalidArgumentException | ||||
|      */ | ||||
|     public function setAdapterParameters(array $config = array()) | ||||
|     public function setAdapterParameters(array $config = []) | ||||
|     { | ||||
|         if (!is_array($config) || empty($config)) { | ||||
|             throw new InvalidArgumentException('$config must be an associative array with at least 1 item.'); | ||||
|   | ||||
| @@ -23,7 +23,7 @@ abstract class AbstractCollection | ||||
|      * @var \ArrayIterator | ||||
|      */ | ||||
|     protected $coll; | ||||
|      | ||||
|  | ||||
|     /** | ||||
|      * Get. | ||||
|      * | ||||
| @@ -53,7 +53,7 @@ abstract class AbstractCollection | ||||
|      */ | ||||
|     public function isEmpty() | ||||
|     { | ||||
|         return (bool) $this->count(); | ||||
|         return $this->count() === 0; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -27,7 +27,7 @@ class DeviceCollection extends AbstractCollection implements \IteratorAggregate | ||||
|      * | ||||
|      * @param array $devices Devices | ||||
|      */ | ||||
|     public function __construct(array $devices = array()) | ||||
|     public function __construct(array $devices = []) | ||||
|     { | ||||
|         $this->coll = new \ArrayIterator(); | ||||
|  | ||||
| @@ -59,10 +59,10 @@ class DeviceCollection extends AbstractCollection implements \IteratorAggregate | ||||
|      */ | ||||
|     public function getTokens() | ||||
|     { | ||||
|         $tokens = array(); | ||||
|         $tokens = []; | ||||
|  | ||||
|         foreach ($this as $token => $device) { | ||||
|             $tokens[] = $token; | ||||
|         foreach ($this as $device) { | ||||
|             $tokens[] = $device->getToken(); | ||||
|         } | ||||
|  | ||||
|         return array_unique(array_filter($tokens)); | ||||
|   | ||||
| @@ -23,7 +23,7 @@ use Sly\NotificationPusher\Model\Message; | ||||
| use Sly\NotificationPusher\Model\Push; | ||||
| use Sly\NotificationPusher\Exception\AdapterException; | ||||
|  | ||||
| use Doctrine\Common\Util\Inflector; | ||||
| use Doctrine\Common\Inflector\Inflector; | ||||
|  | ||||
| /** | ||||
|  * PushCommand. | ||||
| @@ -89,7 +89,7 @@ class PushCommand extends Command | ||||
|     { | ||||
|         $adapter     = $this->getReadyAdapter($input, $output); | ||||
|         $pushManager = new PushManager($input->getOption('env')); | ||||
|         $message     = new Message('This is an example.'); | ||||
|         $message     = new Message($input->getArgument('message')); | ||||
|         $push        = new Push($adapter, new Device($input->getArgument('token')), $message); | ||||
|         $pushManager->add($push); | ||||
|  | ||||
| @@ -132,7 +132,7 @@ class PushCommand extends Command | ||||
|         try { | ||||
|             $adapter = new $adapterClass(); | ||||
|         } catch (\Exception $e) { | ||||
|             $adapterData = array(); | ||||
|             $adapterData = []; | ||||
|             preg_match_all('/"(.*)"/i', $e->getMessage(), $matches); | ||||
|  | ||||
|             foreach ($matches[1] as $match) { | ||||
|   | ||||
| @@ -11,8 +11,6 @@ | ||||
|  | ||||
| namespace Sly\NotificationPusher\Exception; | ||||
|  | ||||
| use Sly\NotificationPusher\Exception\ExceptionInterface; | ||||
|  | ||||
| /** | ||||
|  * AdapterException. | ||||
|  * | ||||
|   | ||||
| @@ -11,8 +11,6 @@ | ||||
|  | ||||
| namespace Sly\NotificationPusher\Exception; | ||||
|  | ||||
| use Sly\NotificationPusher\Exception\ExceptionInterface; | ||||
|  | ||||
| /** | ||||
|  * InvalidException. | ||||
|  * | ||||
|   | ||||
| @@ -11,8 +11,6 @@ | ||||
|  | ||||
| namespace Sly\NotificationPusher\Exception; | ||||
|  | ||||
| use Sly\NotificationPusher\Exception\ExceptionInterface; | ||||
|  | ||||
| /** | ||||
|  * PushException. | ||||
|  * | ||||
|   | ||||
| @@ -11,8 +11,6 @@ | ||||
|  | ||||
| namespace Sly\NotificationPusher\Exception; | ||||
|  | ||||
| use Sly\NotificationPusher\Exception\ExceptionInterface; | ||||
|  | ||||
| /** | ||||
|  * RuntimeException. | ||||
|  * | ||||
|   | ||||
| @@ -21,7 +21,7 @@ abstract class BaseOptionedModel | ||||
|     /** | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $options = array(); | ||||
|     protected $options = []; | ||||
|  | ||||
|     /** | ||||
|      * Get options. | ||||
|   | ||||
| @@ -21,7 +21,7 @@ abstract class BaseParameteredModel | ||||
|     /** | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $parameters = array(); | ||||
|     protected $parameters = []; | ||||
|  | ||||
|     /** | ||||
|      * Get parameters. | ||||
|   | ||||
| @@ -29,7 +29,7 @@ class Device extends BaseParameteredModel implements DeviceInterface | ||||
|      * @param string $token      Token | ||||
|      * @param array  $parameters Parameters | ||||
|      */ | ||||
|     public function __construct($token, array $parameters = array()) | ||||
|     public function __construct($token, array $parameters = []) | ||||
|     { | ||||
|         $this->token      = $token; | ||||
|         $this->parameters = $parameters; | ||||
|   | ||||
| @@ -29,7 +29,7 @@ class Message extends BaseOptionedModel implements MessageInterface | ||||
|      * @param string $text    Text | ||||
|      * @param array  $options Options | ||||
|      */ | ||||
|     public function __construct($text, array $options = array()) | ||||
|     public function __construct($text, array $options = []) | ||||
|     { | ||||
|         $this->text    = $text; | ||||
|         $this->options = $options; | ||||
|   | ||||
| @@ -13,8 +13,6 @@ namespace Sly\NotificationPusher\Model; | ||||
|  | ||||
| use Sly\NotificationPusher\Collection\DeviceCollection; | ||||
| use Sly\NotificationPusher\Adapter\AdapterInterface; | ||||
| use Sly\NotificationPusher\Model\DeviceInterface; | ||||
| use Sly\NotificationPusher\Model\MessageInterface; | ||||
| use Sly\NotificationPusher\Exception\AdapterException; | ||||
|  | ||||
| /** | ||||
| @@ -53,20 +51,20 @@ class Push extends BaseOptionedModel implements PushInterface | ||||
|     /** | ||||
|      * Constructor. | ||||
|      * | ||||
|      * @param \Sly\NotificationPusher\Adapter\AdapterInterface  $adapter Adapter | ||||
|      * @param DeviceInterface|DeviceCollection                           $devices Device(s) | ||||
|      * @param \Sly\NotificationPusher\Model\MessageInterface             $message Message | ||||
|      * @param array                                             $options Options | ||||
|      * @param \Sly\NotificationPusher\Adapter\AdapterInterface $adapter Adapter | ||||
|      * @param DeviceInterface|DeviceCollection                 $devices Device(s) | ||||
|      * @param \Sly\NotificationPusher\Model\MessageInterface   $message Message | ||||
|      * @param array                                            $options Options | ||||
|      * | ||||
|      * Options are adapters specific ones, like Apns "badge" or "sound" option for example. | ||||
|      * Of course, they can be more general. | ||||
|      * | ||||
|      * @throws \Sly\NotificationPusher\Exception\AdapterException | ||||
|      */ | ||||
|     public function __construct(AdapterInterface $adapter, $devices, MessageInterface $message, array $options = array()) | ||||
|     public function __construct(AdapterInterface $adapter, $devices, MessageInterface $message, array $options = []) | ||||
|     { | ||||
|         if ($devices instanceof DeviceInterface) { | ||||
|             $devices = new DeviceCollection(array($devices)); | ||||
|             $devices = new DeviceCollection([$devices]); | ||||
|         } | ||||
|  | ||||
|         $this->adapter = $adapter; | ||||
| @@ -90,7 +88,7 @@ class Push extends BaseOptionedModel implements PushInterface | ||||
|             if (false === $adapter->supports($device->getToken())) { | ||||
|                 throw new AdapterException( | ||||
|                     sprintf( | ||||
|                         'Adapter %s does not supports %s token\'s device', | ||||
|                         'Adapter %s does not support %s token\'s device', | ||||
|                         (string) $adapter, | ||||
|                         $device->getToken() | ||||
|                     ) | ||||
|   | ||||
| @@ -25,7 +25,7 @@ interface PushInterface | ||||
|      */ | ||||
|     const STATUS_PENDING = 'pending'; | ||||
|     const STATUS_PUSHED  = 'sent'; | ||||
|      | ||||
|  | ||||
|     /** | ||||
|      * Get Status. | ||||
|      * | ||||
|   | ||||
| @@ -91,6 +91,7 @@ class PushManager extends PushCollection | ||||
|                 ) | ||||
|             ); | ||||
|         } | ||||
|         $adapter->setEnvironment($this->getEnvironment()); | ||||
|  | ||||
|         return $adapter->getFeedback(); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Manish Verma
					Manish Verma