php Thelia-Log-Tlog类(方法)实例源码

下面列出了php Thelia-Log-Tlog 类(方法)源码代码实例,从而了解它的用法。

作者:alex6353    项目:theli   
protected function updateToVersion($version, Database $database, Tlog $logger)
 {
     if (file_exists(THELIA_ROOT . '/setup/update/' . $version . '.sql')) {
         $logger->debug(sprintf('inserting file %s', $version . '$sql'));
         $database->insertSql(null, array(THELIA_ROOT . '/setup/update/' . $version . '.sql'));
         $logger->debug(sprintf('end inserting file %s', $version . '$sql'));
     }
     ConfigQuery::write('thelia_version', $version);
 }

作者:Alban-i    项目:Paylin   
/**
  * Returns the module-specific logger, initializing it if required.
  *
  * @return Tlog a Tlog instance
  */
 public function getLogger()
 {
     if ($this->log == null) {
         $this->log = Tlog::getNewInstance();
         $logFilePath = $this->getLogFilePath();
         $this->log->setPrefix("#LEVEL: #DATE #HOUR: ");
         $this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile");
         $this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath);
     }
     return $this->log;
 }

作者:Asena    项目:thelia-FreeShippin   
public function createRuleAction()
 {
     if (null !== ($response = $this->checkAuth(array(), array('FreeShipping'), AccessManager::CREATE))) {
         return $response;
     }
     $ruleCreationForm = new FreeShippingRuleCreationForm($this->getRequest());
     $message = false;
     try {
         $form = $this->validateForm($ruleCreationForm);
         $event = $this->createEventInstance($form->getData());
         $this->areaId = $form->get('area')->getData();
         if (null === $this->getExistingObject()) {
             $this->dispatch(FreeShippingEvents::FREE_SHIPPING_RULE_CREATE, $event);
             return $this->generateSuccessRedirect($ruleCreationForm);
         } else {
             throw new \Exception("A rule with this area already exist");
         }
     } catch (FormValidationException $e) {
         $message = sprintf("Please check your input: %s", $e->getMessage());
     } catch (PropelException $e) {
         $message = $e->getMessage();
     } catch (\Exception $e) {
         $message = sprintf("Sorry, an error occured: %s", $e->getMessage() . " " . $e->getFile());
     }
     if ($message !== false) {
         \Thelia\Log\Tlog::getInstance()->error(sprintf("Error during free shipping rule creation process : %s.", $message));
         $ruleCreationForm->setErrorMessage($message);
         $this->getParserContext()->addForm($ruleCreationForm)->setGeneralError($message);
     }
     // Redirect
     return $this->generateRedirectFromRoute('admin.module.configure', array(), array('module_code' => 'FreeShipping'));
 }

作者:theli    项目:cor   
protected function logAlertMessage($message, $failSafe = false)
 {
     Tlog::getInstance()->addAlert($message);
     if (!$failSafe && $this->debugEnabled) {
         throw new \InvalidArgumentException($message);
     }
 }

作者:alex6353    项目:theli   
public function updateStatus(OrderEvent $event)
 {
     $order = $event->getOrder();
     $paidStatusId = OrderStatusQuery::create()->filterByCode(OrderStatus::CODE_PAID)->select('Id')->findOne();
     if ($order->hasVirtualProduct() && $event->getStatus() == $paidStatusId) {
         $contact_email = ConfigQuery::read('store_email');
         if ($contact_email) {
             $message = MessageQuery::create()->filterByName('mail_virtualproduct')->findOne();
             if (false === $message) {
                 throw new \Exception("Failed to load message 'mail_virtualproduct'.");
             }
             $order = $event->getOrder();
             $customer = $order->getCustomer();
             $this->parser->assign('customer_id', $customer->getId());
             $this->parser->assign('order_id', $order->getId());
             $this->parser->assign('order_ref', $order->getRef());
             $this->parser->assign('order_date', $order->getCreatedAt());
             $this->parser->assign('update_date', $order->getUpdatedAt());
             $message->setLocale($order->getLang()->getLocale());
             $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
             // Build subject and body
             $message->buildMessage($this->parser, $instance);
             $this->mailer->send($instance);
             Tlog::getInstance()->debug("Virtual product download message sent to customer " . $customer->getEmail());
         } else {
             $customer = $order->getCustomer();
             Tlog::getInstance()->debug("Virtual product download message no contact email customer_id", $customer->getId());
         }
     }
 }

作者:lopes-vincen    项目:Predic   
public function updateStatus(OrderEvent $event)
 {
     $order = $event->getOrder();
     $Predict = new Predict();
     if ($order->isSent() && $order->getDeliveryModuleId() == $Predict->getModuleModel()->getId()) {
         $contact_email = ConfigQuery::read('store_email');
         if ($contact_email) {
             $message = MessageQuery::create()->filterByName('mail_predict')->findOne();
             if (false === $message) {
                 throw new \Exception(Translator::getInstance()->trans("Failed to load message '%mail_tpl_name'.", ["%mail_tpl_name" => "mail_predict"], Predict::MESSAGE_DOMAIN));
             }
             $order = $event->getOrder();
             $customer = $order->getCustomer();
             $this->parser->assign('customer_id', $customer->getId());
             $this->parser->assign('order_ref', $order->getRef());
             $this->parser->assign('order_date', $order->getCreatedAt());
             $this->parser->assign('order_id', $order->getId());
             $this->parser->assign('update_date', $order->getUpdatedAt());
             $this->parser->assign('package', $order->getDeliveryRef());
             $message->setLocale($order->getLang()->getLocale());
             $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
             // Build subject and body
             $message->buildMessage($this->parser, $instance);
             $this->mailer->send($instance);
             Tlog::getInstance()->debug("Predict shipping message sent to customer " . $customer->getEmail());
         } else {
             $customer = $order->getCustomer();
             Tlog::getInstance()->debug("Predict shipping message no contact email customer_id", $customer->getId());
         }
     }
 }

作者:bcbr    项目:LegacyProductAttribute   
public function addItem()
 {
     $request = $this->getRequest();
     $cartAdd = $this->getAddCartForm($request);
     $message = null;
     try {
         $form = $this->validateForm($cartAdd);
         $cartEvent = $this->getCartEvent();
         $cartEvent->bindForm($form);
         $this->getDispatcher()->dispatch(TheliaEvents::CART_ADDITEM, $cartEvent);
         $this->afterModifyCart();
         if ($this->getRequest()->isXmlHttpRequest()) {
             $this->changeViewForAjax();
         } else {
             if (null !== ($response = $this->generateSuccessRedirect($cartAdd))) {
                 return $response;
             }
         }
     } catch (PropelException $e) {
         Tlog::getInstance()->error(sprintf("Failed to add item to cart with message : %s", $e->getMessage()));
         $message = $this->getTranslator()->trans("Failed to add this article to your cart, please try again", [], Front::MESSAGE_DOMAIN);
     } catch (FormValidationException $e) {
         $message = $e->getMessage();
     }
     if ($message) {
         $cartAdd->setErrorMessage($message);
         $this->getParserContext()->addForm($cartAdd);
     }
 }

作者:NandoKstroNe    项目:theli   
public function updateStatus(OrderEvent $event)
 {
     $order = $event->getOrder();
     $colissimo = new Colissimo();
     if ($order->isSent() && $order->getDeliveryModuleId() == $colissimo->getModuleModel()->getId()) {
         $contact_email = ConfigQuery::getStoreEmail();
         if ($contact_email) {
             $message = MessageQuery::create()->filterByName('mail_colissimo')->findOne();
             if (false === $message) {
                 throw new \Exception("Failed to load message 'order_confirmation'.");
             }
             $order = $event->getOrder();
             $customer = $order->getCustomer();
             $this->parser->assign('customer_id', $customer->getId());
             $this->parser->assign('order_ref', $order->getRef());
             $this->parser->assign('order_date', $order->getCreatedAt());
             $this->parser->assign('update_date', $order->getUpdatedAt());
             $this->parser->assign('package', $order->getDeliveryRef());
             $message->setLocale($order->getLang()->getLocale());
             $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::getStoreName());
             // Build subject and body
             $message->buildMessage($this->parser, $instance);
             $this->mailer->send($instance);
             Tlog::getInstance()->debug("Colissimo shipping message sent to customer " . $customer->getEmail());
         } else {
             $customer = $order->getCustomer();
             Tlog::getInstance()->debug("Colissimo shipping message no contact email customer_id", $customer->getId());
         }
     }
 }

作者:alex6353    项目:theli   
public function delete(ModuleDeleteEvent $event)
 {
     if (null !== ($module = ModuleQuery::create()->findPk($event->getModuleId()))) {
         $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME);
         $con->beginTransaction();
         try {
             if (null === $module->getFullNamespace()) {
                 throw new \LogicException(Translator::getInstance()->trans('Cannot instanciante module "%name%": the namespace is null. Maybe the model is not loaded ?', array('%name%' => $module->getCode())));
             }
             try {
                 $instance = $module->createInstance();
                 $instance->setContainer($this->container);
                 $path = $module->getAbsoluteBaseDir();
                 $instance->destroy($con, $event->getDeleteData());
                 $fs = new Filesystem();
                 $fs->remove($path);
             } catch (\ReflectionException $ex) {
                 // Happens probably because the module directory has been deleted.
                 // Log a warning, and delete the database entry.
                 Tlog::getInstance()->addWarning(Translator::getInstance()->trans('Failed to create instance of module "%name%" when trying to delete module. Module directory has probably been deleted', array('%name%' => $module->getCode())));
             }
             $module->delete($con);
             $con->commit();
             $event->setModule($module);
             $this->cacheClear($event->getDispatcher());
         } catch (\Exception $e) {
             $con->rollBack();
             throw $e;
         }
     }
 }

作者:thelia-module    项目:DealerTea   
public function updateOrCreateLinkAction($id)
 {
     // Check current user authorization
     if (null !== ($response = $this->checkAuth(AdminResources::MODULE, DealerTeam::getModuleCode(), AccessManager::CREATE))) {
         return $response;
     }
     $retour = [];
     $code = 200;
     $con = Propel::getConnection();
     $con->beginTransaction();
     try {
         $data = ['id' => $id];
         $tempOption = $this->getRequest()->request->get("option_id");
         $dafyDealer = [];
         foreach ($tempOption as $option) {
             $data["dealer_option_id"] = $option;
             $temp = $this->getService()->createFromArray($data);
             if ($temp) {
                 $dafyDealer[] = $temp->toArray();
             }
         }
         $con->commit();
         $retour["data"] = $dafyDealer;
     } catch (\Exception $e) {
         $con->rollBack();
         // Any other error
         Tlog::getInstance()->addError($e->getMessage());
         $code = $e->getCode();
         if ($code == 0) {
             $code = 500;
         }
         $retour["message"] = $e->getMessage();
     }
     return JsonResponse::create($retour, $code);
 }

作者:badela    项目:theli   
public function subscribeAction()
 {
     $errorMessage = false;
     $newsletterForm = new NewsletterForm($this->getRequest());
     try {
         $form = $this->validateForm($newsletterForm);
         $event = new NewsletterEvent($form->get('email')->getData(), $this->getRequest()->getSession()->getLang()->getLocale());
         if (null !== ($customer = $this->getSecurityContext()->getCustomerUser())) {
             $event->setFirstname($customer->getFirstname());
             $event->setLastname($customer->getLastname());
         } else {
             $event->setFirstname($form->get('firstname')->getData());
             $event->setLastname($form->get('lastname')->getData());
         }
         $this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $event);
     } catch (\Exception $e) {
         $errorMessage = $e->getMessage();
         Tlog::getInstance()->error(sprintf('Error during newsletter subscription : %s', $errorMessage));
     }
     // If Ajax Request
     if ($this->getRequest()->isXmlHttpRequest()) {
         $response = new JsonResponse();
         if ($errorMessage) {
             $response = $response->setContent(array("success" => false, "message" => $errorMessage));
         } else {
             $response = $response->setContent(array("success" => true, "message" => $this->getTranslator()->trans("Thanks for signing up! We'll keep you posted whenever we have any new updates.")));
         }
         return $response;
     } else {
         $newsletterForm->setErrorMessage($errorMessage);
         $this->getParserContext()->addForm($newsletterForm)->setGeneralError($errorMessage);
     }
 }

作者:GuiminZHO    项目:theli   
public function subscribeAction()
 {
     $errorMessage = false;
     $newsletterForm = $this->createForm(FrontForm::NEWSLETTER);
     try {
         $form = $this->validateForm($newsletterForm);
         $event = new NewsletterEvent($form->get('email')->getData(), $this->getRequest()->getSession()->getLang()->getLocale());
         /** @var Customer $customer */
         if (null !== ($customer = $this->getSecurityContext()->getCustomerUser())) {
             $event->setFirstname($customer->getFirstname())->setLastname($customer->getLastname());
         } else {
             $event->setFirstname($form->get('firstname')->getData())->setLastname($form->get('lastname')->getData());
         }
         $this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $event);
         // If a success URL is defined in the form, redirect to it, otherwise use the defaut view
         if ($newsletterForm->hasSuccessUrl() && !$this->getRequest()->isXmlHttpRequest()) {
             return $this->generateSuccessRedirect($newsletterForm);
         }
     } catch (\Exception $e) {
         $errorMessage = $e->getMessage();
         Tlog::getInstance()->error(sprintf('Error during newsletter subscription : %s', $errorMessage));
         $newsletterForm->setErrorMessage($errorMessage);
     }
     // If Ajax Request
     if ($this->getRequest()->isXmlHttpRequest()) {
         return new JsonResponse(["success" => $errorMessage ? false : true, "message" => $errorMessage ? $errorMessage : $this->getTranslator()->trans("Thanks for signing up! We'll keep you posted whenever we have any new updates.", [], Front::MESSAGE_DOMAIN)], $errorMessage ? 500 : 200);
     }
     $this->getParserContext()->setGeneralError($errorMessage)->addForm($newsletterForm);
     // If an error URL is defined in the form, redirect to it, otherwise use the defaut view
     if ($errorMessage && $newsletterForm->hasErrorUrl()) {
         return $this->generateErrorRedirect($newsletterForm);
     }
 }

作者:alex6353    项目:theli   
public static function setUpBeforeClass()
 {
     self::$logger = Tlog::getInstance();
     self::$logger->setDestinations("Thelia\\Log\\Destination\\TlogDestinationText");
     self::$logger->setLevel(Tlog::DEBUG);
     self::$logger->setFiles("*");
 }

作者:badela    项目:theli   
public function parseResults(LoopResult $results)
 {
     $results = parent::parseResults($results);
     foreach ($results as $loopResultRow) {
         $accessoryProductId = $loopResultRow->get('ID');
         \Thelia\Log\Tlog::getInstance()->notice($this->accessoryId);
         $loopResultRow->set("ID", $this->accessoryId[$accessoryProductId])->set("POSITION", $this->accessoryPosition[$accessoryProductId])->set("ACCESSORY_ID", $accessoryProductId);
     }
     return $results;
 }

作者:badela    项目:theli   
/**
  * A simple helper to insert an entry in the admin log
  *
  * @param $resource
  * @param $action
  * @param $message
  * @param Request       $request
  * @param UserInterface $adminUser
  * @param bool          $withRequestContent
  */
 public static function append($resource, $action, $message, Request $request, UserInterface $adminUser = null, $withRequestContent = true)
 {
     $log = new AdminLog();
     $log->setAdminLogin($adminUser !== null ? $adminUser->getUsername() : '<no login>')->setAdminFirstname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getFirstname() : '<no first name>')->setAdminLastname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getLastname() : '<no last name>')->setResource($resource)->setAction($action)->setMessage($message)->setRequest($request->toString($withRequestContent));
     try {
         $log->save();
     } catch (\Exception $ex) {
         Tlog::getInstance()->err("Failed to insert new entry in AdminLog: {ex}", array('ex' => $ex));
     }
 }

作者:marger    项目:theli   
protected function renderTemplate()
 {
     $destinations = array();
     $destination_directories = Tlog::getInstance()->getDestinationsDirectories();
     foreach ($destination_directories as $dir) {
         $this->loadDefinedDestinations($dir, $destinations);
     }
     $active_destinations = explode(";", ConfigQuery::read(Tlog::VAR_DESTINATIONS, Tlog::DEFAUT_DESTINATIONS));
     return $this->render('system-logs', array('ip_address' => $this->getRequest()->getClientIp(), 'destinations' => $destinations, 'active_destinations' => $active_destinations));
 }

作者:Mertiozy    项目:CmCI   
/**
  * @throws \Exception
  */
 public function receiveResponse()
 {
     $request = $this->getRequest();
     $order_id = $request->get('reference');
     if (is_numeric($order_id)) {
         $order_id = (int) $order_id;
     }
     /*
      * Configure log output
      */
     $log = Tlog::getInstance();
     $log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile");
     $log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, THELIA_ROOT . "log" . DS . "log-cmcic.txt");
     $log->info("accessed");
     $order = OrderQuery::create()->findPk($order_id);
     /*
      * Retrieve HMac for CGI2
      */
     $config = Config::read(CmCIC::JSON_CONFIG_PATH);
     $hashable = sprintf(CmCIC::CMCIC_CGI2_FIELDS, $config['CMCIC_TPE'], $request->get('date'), $request->get('montant'), $request->get('reference'), $request->get('texte-libre'), $config['CMCIC_VERSION'], $request->get('code-retour'), $request->get('cvx'), $request->get('vld'), $request->get('brand'), $request->get('status3ds'), $request->get('numauto'), $request->get('motifrefus'), $request->get('originecb'), $request->get('bincb'), $request->get('hpancb'), $request->get('ipclient'), $request->get('originetr'), $request->get('veres'), $request->get('pares'));
     $mac = CmCIC::computeHmac($hashable, CmCIC::getUsableKey($config["CMCIC_KEY"]));
     $response = CmCIC::CMCIC_CGI2_MACNOTOK . $hashable;
     if ($mac === strtolower($request->get('MAC'))) {
         $code = $request->get("code-retour");
         $msg = null;
         $status = OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_PAID);
         $event = new OrderEvent($order);
         $event->setStatus($status->getId());
         switch ($code) {
             case "payetest":
                 $msg = "The test payment of the order " . $order->getRef() . " has been successfully released. ";
                 $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event);
                 break;
             case "paiement":
                 $msg = "The payment of the order " . $order->getRef() . " has been successfully released. ";
                 $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event);
                 break;
             case "Annulation":
                 $msg = "Error during the paiement: " . $this->getRequest()->get("motifrefus");
                 break;
             default:
                 $log->error("Error while receiving response from CMCIC: code-retour not valid");
                 throw new \Exception(Translator::getInstance()->trans("An error occured, no valid code-retour"));
         }
         if (!empty($msg)) {
             $log->info($msg);
         }
         $response = CmCIC::CMCIC_CGI2_MACOK;
     }
     /*
      * Get log back to previous state
      */
     $log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationRotatingFile");
     return Response::create(sprintf(CmCIC::CMCIC_CGI2_RECEIPT, $response), 200, array("Content-type" => "text/plain", "Pragma" => "nocache"));
 }

作者:NandoKstroNe    项目:theli   
/**
  *
  * @return \Thelia\Log\Tlog
  */
 public static function getInstance()
 {
     if (self::$instance == false) {
         self::$instance = new Tlog();
         // On doit placer les initialisations à ce level pour pouvoir
         // utiliser la classe Tlog dans les classes de base (Cnx, BaseObj, etc.)
         // Les placer dans le constructeur provoquerait une boucle
         self::$instance->init();
     }
     return self::$instance;
 }

作者:alex6353    项目:theli   
/**
  * Initialize a module-specific logger.
  *
  * @return Tlog a Tlog instance
  */
 protected function getLog()
 {
     if ($this->log == null) {
         $this->log = Tlog::getNewInstance();
         $logFilePath = sprintf(THELIA_ROOT . "log" . DS . "%s.log", strtolower($this->getModuleCode()));
         $this->log->setPrefix("#LEVEL: #DATE #HOUR: ");
         $this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile");
         $this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath);
     }
     return $this->log;
 }

作者:vigourouxjulie    项目:theli   
/**
  * Send email to notify customer that files for virtual products are available
  *
  * @param OrderEvent $event
  * @throws \Exception
  */
 public function sendEmail(OrderEvent $event)
 {
     $order = $event->getOrder();
     // Be sure that we have a document to download
     $virtualProductCount = OrderProductQuery::create()->filterByOrderId($order->getId())->filterByVirtual(true)->filterByVirtualDocument(null, Criteria::NOT_EQUAL)->count();
     if ($virtualProductCount > 0) {
         $customer = $order->getCustomer();
         $this->mailer->sendEmailToCustomer('mail_virtualproduct', $customer, ['customer_id' => $customer->getId(), 'order_id' => $order->getId(), 'order_ref' => $order->getRef(), 'order_date' => $order->getCreatedAt(), 'update_date' => $order->getUpdatedAt()]);
     } else {
         Tlog::getInstance()->warning("Virtual product download message not sent to customer: there's nothing to downnload");
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号