本文整理汇总了PHP中Thelia\Log\Tlog类的典型用法代码示例。如果您正苦于以下问题:PHP Tlog类的具体用法?PHP Tlog怎么用?PHP Tlog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tlog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateToVersion
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);
}
示例2: getLogger
/**
* 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;
}
示例3: createRuleAction
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'));
}
示例4: logAlertMessage
protected function logAlertMessage($message, $failSafe = false)
{
Tlog::getInstance()->addAlert($message);
if (!$failSafe && $this->debugEnabled) {
throw new \InvalidArgumentException($message);
}
}
示例5: updateStatus
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());
}
}
}
示例6: updateStatus
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());
}
}
}
示例7: addItem
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);
}
}
示例8: updateStatus
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());
}
}
}
示例9: delete
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;
}
}
}
示例10: updateOrCreateLinkAction
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);
}
示例11: subscribeAction
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);
}
}
示例12: subscribeAction
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);
}
}
示例13: setUpBeforeClass
public static function setUpBeforeClass()
{
self::$logger = Tlog::getInstance();
self::$logger->setDestinations("Thelia\\Log\\Destination\\TlogDestinationText");
self::$logger->setLevel(Tlog::DEBUG);
self::$logger->setFiles("*");
}
示例14: parseResults
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;
}
示例15: append
/**
* 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));
}
}