コード例 #1
0
 /**
  * Importer class.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function import()
 {
     $index = 0;
     $batch = [];
     foreach ($this->medicalCenterRepository->all() as $index => $medCenter) {
         $email = $medCenter->email;
         if ($email === '') {
             continue;
         }
         $batch[] = ['email' => compact('email'), 'merge_vars' => ['TOKEN' => $medCenter->token, 'NAME' => $medCenter->name, 'COUNTRY' => $medCenter->country, 'EMAIL' => $medCenter->email]];
     }
     // Subscribe to Newsletter
     $results = $this->newsletter->batchSubscribeTo('TheseEcho', $batch, false, true);
     // Errors
     if ($results['error_count']) {
         return $this->response->make('There are errors ' . print_r($results['errors']) . '.', 405);
     }
     // Success
     return $this->response->make("Subscribed {$index} centers.", 200);
 }
コード例 #2
0
 /**
  * Make sure token is unique or throw an exception.
  *
  * @param $token
  *
  * @return string
  *
  * @throws Exception
  */
 protected function makeUniqueToken($token)
 {
     $tries = 0;
     // Loop while token is not unique
     while ($this->medicalCenter->withTokenExists($token)) {
         $token = $this->makeRandomToken();
         $tries++;
         if ($tries > 30) {
             throw new Exception('Cannot make token unique', 1);
         }
     }
     return $token;
 }
コード例 #3
0
ファイル: ResultsService.php プロジェクト: rleger/TheseEcho
 /**
  * Resolve medical center name.
  *
  * @param $value
  *
  * @return mixed
  */
 public function resolveMedicalCenterIdName($value)
 {
     return $this->medicalCenterRepository->find($value)->name;
 }