Exemplo n.º 1
0
 /**
  * Attempt to instantiate the filter if it exists and has not been ignored.
  *
  * @return null|\Assetic\Filter\FilterInterface
  */
 public function getInstance()
 {
     if (!($class = $this->getClassName())) {
         $this->log->error(sprintf('"%s" will not be applied to asset "%s" due to an invalid filter name.', $this->filter, $this->resource->getRelativePath()));
     }
     if ($this->ignored or is_null($class) or !$this->processRequirements()) {
         return;
     }
     // If the class returned is already implements Assetic\Filter\FilterInterface then
     // we can set the instance directly and not worry about using reflection.
     if ($class instanceof FilterInterface) {
         $instance = $class;
     } else {
         $reflection = new ReflectionClass($class);
         // If no constructor is available on the filters class then we'll instantiate
         // the filter without passing in any arguments.
         if (!$reflection->getConstructor()) {
             $instance = $reflection->newInstance();
         } else {
             $instance = $reflection->newInstanceArgs($this->arguments);
         }
     }
     // Spin through each of the before filtering callbacks and fire each one. We'll
     // pass in an instance of the filter to the callback.
     foreach ($this->before as $callback) {
         if (is_callable($callback)) {
             call_user_func($callback, $instance);
         }
     }
     return $instance;
 }
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 errorResponse($message) : bool
 {
     $this->error = $message;
     $this->logger->error($message);
     return false;
 }
Exemplo n.º 4
0
 /**
  * adds url and session to logs
  * @param string $message
  * @param array  $context
  */
 public function error($message, array $context = [])
 {
     $context['url'] = request()->url();
     $context['session'] = session()->all();
     parent::error($message, $context);
 }
 /**
  * Handle the event.
  *
  * @param $fileName
  */
 public function handle($fileName)
 {
     if (!file_exists($fileName) || false === @unlink($fileName)) {
         $this->writer->error("Could not delete {$fileName} temporary blade template");
     }
 }
Exemplo n.º 6
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.º 7
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();
 }