RMS\PushNotificationsBundle\Service\OS\AndroidGCMNotification::__construct PHP Method

__construct() public method

Constructor
public __construct ( string $apiKey, boolean $useMultiCurl, integer $timeout, Psr\Log\LoggerInterface $logger, Buzz\Client\AbstractCurl $client = null, boolean $dryRun = false )
$apiKey string
$useMultiCurl boolean
$timeout integer
$logger Psr\Log\LoggerInterface
$client Buzz\Client\AbstractCurl (optional)
$dryRun boolean
    public function __construct($apiKey, $useMultiCurl, $timeout, $logger, AbstractCurl $client = null, $dryRun = false)
    {
        $this->useDryRun = $dryRun;
        $this->apiKey = $apiKey;
        if (!$client) {
            $client = $useMultiCurl ? new MultiCurl() : new Curl();
        }
        $client->setTimeout($timeout);
        $this->browser = new Browser($client);
        $this->browser->getClient()->setVerifyPeer(false);
        $this->logger = $logger;
    }

Usage Example

 public function __construct($container)
 {
     $logger = $container->get('logger');
     $em = $container->get('doctrine')->getManager();
     $appId = $container->get('keosu_core.curapp')->getCurApp();
     $app = $em->getRepository('KeosuCoreBundle:App')->find($appId);
     $googleGcmApiKey = $app->getConfigPackages()[KeosuGadgetPushNotificationBundle::PACKAGE_NAME]['googleGcmApiKey'];
     $googleUseMultiCurl = $app->getConfigPackages()[KeosuGadgetPushNotificationBundle::PACKAGE_NAME]['googleUseMultiCurl'];
     if ($googleGcmApiKey === null) {
         throw new \LogicException('Can\'t send message because google gcm api key in not defined');
     }
     parent::__construct($googleGcmApiKey, $googleUseMultiCurl, 60, $logger);
 }