protected function execute(InputInterface $input, OutputInterface $output)
 {
     /* @var $notification \Civix\CoreBundle\Service\Notification */
     $notification = $this->getContainer()->get('civix_core.notification');
     /* @var $em \Doctrine\ORM\EntityManager */
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     $users = $em->getRepository('CivixCoreBundle:User')->findAll();
     /* @var $user \Civix\CoreBundle\Entity\User */
     foreach ($users as $user) {
         if ($user->getAndroidDevice()) {
             $endpoint = new Notification\AndroidEndpoint();
             $endpoint->setToken($user->getAndroidDevice())->setUser($user);
             $notification->handleEndpoint($endpoint);
             $output->writeln("<comment>Added android endpoint for user:</comment> {$user->getUsername()}");
         }
         if ($user->getIosDevice()) {
             $endpoint = new Notification\IOSEndpoint();
             $endpoint->setToken($user->getIosDevice())->setUser($user);
             $notification->handleEndpoint($endpoint);
             $output->writeln("<comment>Added ios endpoint for user:</comment> {$user->getUsername()}");
         }
     }
 }
예제 #2
0
 /**
  * @group notification
  */
 public function testPlatformMessage()
 {
     $endpoint = new IOSEndpoint();
     $this->assertEquals($endpoint->getPlatformMessage('test_message', 'test_type', null), '{"APNS":"{\\"aps\\":{\\"alert\\":\\"test_message\\",\\"entity\\":\\"null\\",' . '\\"type\\":\\"test_type\\",\\"sound\\":\\"default\\"}}"}');
 }
 public function getUser()
 {
     $this->__load();
     return parent::getUser();
 }