Exemplo n.º 1
0
 /**
  * @param array $events
  */
 public function dispatch(array $events)
 {
     foreach ($events as $event) {
         $eventName = $this->getEventName($event);
         $this->event->fire($eventName, $event);
         $this->log->debug("{$eventName} was fired");
     }
 }
Exemplo n.º 2
0
 function loger($level, $file, $line, $string, $ar = NULL)
 {
     // если системный level ниже notice, то при включеном KINT_DUMP, ставим уровень notice
     if ($GLOBALS['KINT_DUMP'] && $this->agiconfig['verbosity_level'] < 2) {
         $this->agiconfig['verbosity_level'] = 2;
     }
     if ($this->agiconfig['verbosity_level'] < $level) {
         return;
     }
     if ($GLOBALS['KINT_DUMP']) {
         ~d("{$level} | {$file} | {$line}");
         if (!is_null($string)) {
             d($string);
         }
         if (!is_null($ar)) {
             d($ar);
         }
         return;
     }
     if (!is_null($string)) {
         $this->agi->verbose($string);
     }
     if (!is_null($ar)) {
         $this->agi->verbose($ar);
     }
     if ((int) $this->agiconfig['logging_write_file'] === 1) {
         $logger = new Writer(new Logger('local'));
         $logger->useFiles($this->config['logs_patch']);
         if (!is_null($ar)) {
             $string .= "\n";
             $string .= var_export($string, true);
         }
         switch ($level) {
             case 'error':
                 $logger->error("[" . $this->uniqueid . "] [{$file}] [{$line}]: -- {$string}");
                 break;
             case 'warning':
                 $logger->warning("[" . $this->uniqueid . "] [{$file}] [{$line}]: -- {$string}");
                 break;
             case 'notice':
                 $logger->notice("[" . $this->uniqueid . "] [{$file}] [{$line}]: -- {$string}");
                 break;
             case 'info':
                 $logger->info("[" . $this->uniqueid . "] [{$file}] [{$line}]:  {$string}");
                 break;
             default:
                 $logger->debug("[" . $this->uniqueid . "] [{$file}] [{$line}]: {$string}");
                 break;
         }
     }
 }
Exemplo n.º 3
0
 protected function findProfile()
 {
     $adapter_profile = $this->getAdapterProfile();
     $ProfileModel = $this->config['db']['profilemodel'];
     $UserModel = $this->config['db']['usermodel'];
     $user = NULL;
     // Have they logged in with this provider before?
     $profile_builder = call_user_func_array("{$ProfileModel}::where", array('provider', $this->provider));
     $profile = $profile_builder->where('identifier', $adapter_profile->identifier)->first();
     if ($profile) {
         // ok, we found an existing user
         $user = $profile->user()->first();
         $this->logger->debug('Anvard: found a profile, id=' . $profile->id);
     } elseif ($adapter_profile->email) {
         $this->logger->debug('Anvard: could not find profile, looking for email');
         // ok it's a new profile ... can we find the user by email?
         $user_builder = call_user_func_array("{$UserModel}::where", array('email', $adapter_profile->email));
         $user = $user_builder->first();
     }
     // If we haven't found a user, we need to create a new one
     if (!$user) {
         $this->logger->debug('Anvard: did not find user, creating');
         $user = new $UserModel();
         // map in anything from the profile that we want in the User
         $map = $this->config['db']['profiletousermap'];
         foreach ($map as $apkey => $ukey) {
             $user->{$ukey} = $adapter_profile->{$apkey};
         }
         $values = $this->config['db']['uservalues'];
         foreach ($values as $key => $value) {
             if (is_callable($value)) {
                 $user->{$key} = $value($user, $adapter_profile);
             } else {
                 $user->{$key} = $value;
             }
         }
         // @todo this is all very custom ... how to fix?
         $user->username = $adapter_profile->email;
         $user->displayname = $adapter_profile->firstName . " " . $adapter_profile->lastName;
         $user->email = $adapter_profile->email;
         $user->password = uniqid();
         $user->password_confirmation = $user->password;
         $rules = $this->config['db']['userrules'];
         $result = $user->save($rules);
         // will bowman
         $user->saveRoles(array(\Setting::get('users.default_role_id')));
         if (!$result) {
             $this->logger->error('Anvard: FAILED TO SAVE USER');
             return NULL;
         }
     }
     if (!$profile) {
         // If we didn't find the profile, we need to create a new one
         $profile = $this->createProfileFromAdapterProfile($adapter_profile, $user);
     } else {
         // If we did find a profile, make sure we update any changes to the source
         $profile = $this->applyAdapterProfileToExistingProfile($adapter_profile, $profile);
     }
     $result = $profile->save();
     if (!$result) {
         $this->logger->error('Anvard: FAILED TO SAVE PROFILE');
         return NULL;
     }
     $this->logger->info('Anvard: succesful login!');
     return $profile;
 }
Exemplo n.º 4
0
 /**
  * @param Request $request
  * @param Writer  $logger
  * @param         $payFastData
  */
 protected function updateOrderStatus(Request $request, Writer $logger, $payFastData)
 {
     $order = Order::where('invoice_no', $request->input('m_payment_id'))->first();
     switch ($payFastData['payment_status']) {
         case self::STATUS_COMPLETE:
             $logger->debug(self::PAYMENT_STATUS_COMPLETE);
             $order->status = strtolower(self::STATUS_COMPLETE);
             break;
         case self::STATUS_FAILED:
             $logger->error(self::PAYMENT_STATUS_FAILED);
             $order->status = strtolower(self::STATUS_FAILED);
             break;
         case self::STATUS_PENDING:
             $logger->debug(self::PAYMENT_STATUS_PENDING);
             $order->status = strtolower(self::STATUS_PENDING);
             break;
         default:
             $logger->error(self::PAYMENT_STATUS_DEFAULT);
             $order->status = self::ERROR;
             break;
     }
     $order->save();
 }