Example #1
0
 /**
  * @param string $username
  * @param string $password
  * @param string $apiKey
  * @return $this
  */
 public function setAuthAccess($username = '', $password = '', $apiKey = '')
 {
     $this->username = $this->appService->deCrypt($username);
     $this->password = $this->appService->deCrypt($password);
     $this->apiKey = $this->appService->deCrypt($apiKey);
     return $this;
 }
Example #2
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($options['app_service']) {
         $this->appService = $options['app_service'];
     }
     $builder->add('api_username', TextType::class, ['attr' => ['class' => 'form-control']])->add('api_password', PasswordType::class, ['attr' => ['class' => 'form-control']])->add('api_key', TextType::class, ['attr' => ['class' => 'form-control']])->add('user_id', HiddenType::class, [])->add('club_id', HiddenType::class, [])->add('weezevent_api_log_id', HiddenType::class, ['required' => false])->add('date_register', HiddenType::class, ['required' => false]);
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
         $log = $event->getData();
         $password = $log['api_password'];
         $apiUsername = $log['api_username'];
         $apiKey = $log['api_key'];
         if ($this->appService) {
             if ($password) {
                 $log['api_password'] = $this->appService->deCrypt($password);
             }
             if ($apiUsername) {
                 $log['api_username'] = $this->appService->deCrypt($apiUsername);
             }
             if ($apiKey) {
                 $log['api_key'] = $this->appService->deCrypt($apiKey);
             }
         }
         $event->setData($log);
     });
     $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
         $log = $event->getData();
         $password = $log['api_password'];
         $apiUsername = $log['api_username'];
         $apiKey = $log['api_key'];
         if ($this->appService) {
             if ($password) {
                 $log['api_password'] = $this->appService->crypt($password);
             }
             if ($apiUsername) {
                 $log['api_username'] = $this->appService->crypt($apiUsername);
             }
             if ($apiKey) {
                 $log['api_key'] = $this->appService->crypt($apiKey);
             }
             $event->setData($log);
         } else {
             $event->setData([]);
         }
     });
 }