本文整理汇总了PHP中Eccube\Application::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::log方法的具体用法?PHP Application::log怎么用?PHP Application::log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Eccube\Application
的用法示例。
在下文中一共展示了Application::log方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moveRank
/**
* @param ProductCategory $TargetProductCategory
* @param $position
* @return bool
* @throws \Doctrine\DBAL\ConnectionException
*/
public function moveRank(ProductCategory $TargetProductCategory, $position)
{
$repos = $this->_em->getRepository('\\Eccube\\Entity\\ProductCategory');
$this->_em->getConnection()->beginTransaction();
try {
$oldRank = $TargetProductCategory->getRank();
// 最大値取得
$qb = $repos->createQueryBuilder('pc');
$max = $qb->select($qb->expr()->max('pc.rank'))->where($qb->expr()->eq('pc.category_id', $TargetProductCategory->getCategoryId()))->getQuery()->getSingleScalarResult();
$position = $max - ($position - 1);
$position = max(1, $position);
$TargetProductCategory->setRank($position);
$status = true;
if ($position != $oldRank) {
// 他のItemのランクを調整する
if ($position < $oldRank) {
// down
$this->_em->createQueryBuilder()->update('\\Eccube\\Entity\\ProductCategory', 'pc')->set('pc.rank', 'pc.rank + 1')->where('pc.rank <= :oldRank AND pc.rank >= :rank AND pc.category_id = :category_id AND pc.product_id != :product_id')->setParameter('oldRank', $oldRank)->setParameter('rank', $position)->setParameter('category_id', $TargetProductCategory->getCategoryId())->setParameter('product_id', $TargetProductCategory->getProductId())->getQuery()->execute();
} else {
// up
$this->_em->createQueryBuilder()->update('\\Eccube\\Entity\\ProductCategory', 'pc')->set('pc.rank', 'pc.rank - 1')->where('pc.rank >= :oldRank AND pc.rank <= :rank AND pc.category_id = :category_id AND pc.product_id != :product_id')->setParameter('oldRank', $oldRank)->setParameter('rank', $position)->setParameter('category_id', $TargetProductCategory->getCategoryId())->setParameter('product_id', $TargetProductCategory->getProductId())->getQuery()->execute();
}
$this->_em->persist($TargetProductCategory);
$this->_em->flush();
}
$this->_em->getConnection()->commit();
return $status;
} catch (\Exception $e) {
$this->_em->getConnection()->rollback();
$this->_em->close();
$this->app->log($e);
}
return false;
}
示例2: confirm
/**
* 購入処理
*/
public function confirm(Application $app, Request $request)
{
$cartService = $app['eccube.service.cart'];
// カートチェック
if (!$cartService->isLocked()) {
// カートが存在しない、カートがロックされていない時はエラー
return $app->redirect($app->url('cart'));
}
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
if (!$Order) {
$app->addError('front.shopping.order.error');
return $app->redirect($app->url('shopping_error'));
}
if ('POST' !== $request->getMethod()) {
return $app->redirect($app->url('cart'));
}
// form作成
$form = $app['eccube.service.shopping']->getShippingForm($Order);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
// トランザクション制御
$em = $app['orm.em'];
$em->getConnection()->beginTransaction();
try {
// 商品公開ステータスチェック、商品制限数チェック、在庫チェック
$check = $app['eccube.service.shopping']->isOrderProduct($em, $Order);
if (!$check) {
$em->getConnection()->rollback();
$app->addError('front.shopping.stock.error');
return $app->redirect($app->url('shopping_error'));
}
// 受注情報、配送情報を更新
$app['eccube.service.shopping']->setOrderUpdate($Order, $data);
// 在庫情報を更新
$app['eccube.service.shopping']->setStockUpdate($em, $Order);
if ($app->isGranted('ROLE_USER')) {
// 会員の場合、購入金額を更新
$app['eccube.service.shopping']->setCustomerUpdate($Order, $app->user());
}
$em->flush();
$em->getConnection()->commit();
} catch (\Exception $e) {
$em->getConnection()->rollback();
$app->log($e);
$app->addError('front.shopping.system.error');
return $app->redirect($app->url('shopping_error'));
}
// カート削除
$app['eccube.service.cart']->clear()->save();
// メール送信
$app['eccube.service.mail']->sendOrderMail($Order);
// 受注IDをセッションにセット
$app['session']->set($this->sessionOrderKey, $Order->getId());
// 送信履歴を保存.
$MailTemplate = $app['eccube.repository.mail_template']->find(1);
$body = $app->renderView($MailTemplate->getFileName(), array('header' => $MailTemplate->getHeader(), 'footer' => $MailTemplate->getFooter(), 'Order' => $Order));
$MailHistory = new MailHistory();
$MailHistory->setSubject('[' . $app['eccube.repository.base_info']->get()->getShopName() . '] ' . $MailTemplate->getSubject())->setMailBody($body)->setMailTemplate($MailTemplate)->setSendDate(new \DateTime())->setOrder($Order);
$app['orm.em']->persist($MailHistory);
$app['orm.em']->flush($MailHistory);
// 完了画面表示
return $app->redirect($app->url('shopping_complete'));
}
return $app->render('Shopping/index.twig', array('form' => $form->createView(), 'Order' => $Order));
}
示例3: getRequestApi
/**
* APIリクエスト処理
*
* @param Request $request
* @param $authKey
* @param string $url
* @param Application $app
* @return array
*/
private function getRequestApi(Request $request, $authKey, $url, $app)
{
$curl = curl_init($url);
$options = array(CURLOPT_HTTPHEADER => array('Authorization: ' . base64_encode($authKey), 'x-eccube-store-url: ' . base64_encode($request->getSchemeAndHttpHost() . $request->getBasePath()), 'x-eccube-store-version: ' . base64_encode(Constant::VERSION)), CURLOPT_HTTPGET => true, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_FAILONERROR => true, CURLOPT_CAINFO => \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath());
curl_setopt_array($curl, $options);
/// オプション値を設定
$result = curl_exec($curl);
$info = curl_getinfo($curl);
$message = curl_error($curl);
$info['message'] = $message;
curl_close($curl);
$app->log('http get_info', $info);
return array($result, $info);
}
示例4: getRequestApi
/**
* APIリクエスト処理
*
* @param Request $request
* @param $authKey
* @param string $url
* @param Application $app
* @return array
*/
private function getRequestApi(Request $request, $authKey, $url, $app)
{
$curl = curl_init($url);
$options = array(CURLOPT_HTTPHEADER => array('Authorization: ' . base64_encode($authKey), 'x-eccube-store-url: ' . base64_encode($request->getSchemeAndHttpHost() . $request->getBasePath()), 'x-eccube-store-version: ' . base64_encode(Constant::VERSION)), CURLOPT_HTTPGET => true, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_FAILONERROR => true);
curl_setopt_array($curl, $options);
/// オプション値を設定
$certFile = $app['config']['root_dir'] . '/app/config/eccube/' . $this->certFileName;
if (file_exists($certFile)) {
// php5.6でサーバ上に適切な証明書がなければhttps通信エラーが発生するため、
// http://curl.haxx.se/ca/cacert.pem を利用して通信する
curl_setopt($curl, CURLOPT_CAINFO, $certFile);
}
$result = curl_exec($curl);
$info = curl_getinfo($curl);
$message = curl_error($curl);
$info['message'] = $message;
curl_close($curl);
$app->log('http get_info', $info);
return array($result, $info);
}
示例5: customer
/**
* お客様情報の変更(非会員)
*/
public function customer(Application $app, Request $request)
{
if ($request->isXmlHttpRequest()) {
try {
$data = $request->request->all();
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
$pref = $app['eccube.repository.master.pref']->findOneBy(array('name' => $data['customer_pref']));
if (!$pref) {
$response = new Response(json_encode('NG'), 500);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$Order->setName01($data['customer_name01'])->setName02($data['customer_name02'])->setCompanyName($data['customer_company_name'])->setTel01($data['customer_tel01'])->setTel02($data['customer_tel02'])->setTel03($data['customer_tel03'])->setZip01($data['customer_zip01'])->setZip02($data['customer_zip02'])->setZipCode($data['customer_zip01'] . $data['customer_zip02'])->setPref($pref)->setAddr01($data['customer_addr01'])->setAddr02($data['customer_addr02'])->setEmail($data['customer_email']);
// 配送先を更新
$app['orm.em']->flush();
// 受注関連情報を最新状態に更新
$app['orm.em']->refresh($Order);
$response = new Response(json_encode('OK'));
$response->headers->set('Content-Type', 'application/json');
} catch (\Exception $e) {
$app->log($e);
$response = new Response(json_encode('NG'), 500);
$response->headers->set('Content-Type', 'application/json');
}
return $response;
}
}
示例6: confirm
/**
* 購入処理
*/
public function confirm(Application $app, Request $request)
{
$cartService = $app['eccube.service.cart'];
// カートチェック
if (!$cartService->isLocked()) {
// カートが存在しない、カートがロックされていない時はエラー
log_info('カートが存在しません');
return $app->redirect($app->url('cart'));
}
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
if (!$Order) {
log_info('購入処理中の受注情報がないため購入エラー');
$app->addError('front.shopping.order.error');
return $app->redirect($app->url('shopping_error'));
}
if ('POST' !== $request->getMethod()) {
return $app->redirect($app->url('cart'));
}
// form作成
$builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order);
$event = new EventArgs(array('builder' => $builder, 'Order' => $Order), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CONFIRM_INITIALIZE, $event);
$form = $builder->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
log_info('購入処理開始', array($Order->getId()));
// トランザクション制御
$em = $app['orm.em'];
$em->getConnection()->beginTransaction();
try {
// お問い合わせ、配送時間などのフォーム項目をセット
$app['eccube.service.shopping']->setFormData($Order, $data);
// 購入処理
$app['eccube.service.shopping']->processPurchase($Order);
$em->flush();
$em->getConnection()->commit();
log_info('購入処理完了', array($Order->getId()));
} catch (ShoppingException $e) {
log_error('購入エラー', array($e->getMessage()));
$em->getConnection()->rollback();
$app->log($e);
$app->addError($e->getMessage());
return $app->redirect($app->url('shopping_error'));
} catch (\Exception $e) {
log_error('予期しないエラー', array($e->getMessage()));
$em->getConnection()->rollback();
$app->log($e);
$app->addError('front.shopping.system.error');
return $app->redirect($app->url('shopping_error'));
}
// カート削除
$app['eccube.service.cart']->clear()->save();
$event = new EventArgs(array('form' => $form, 'Order' => $Order), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CONFIRM_PROCESSING, $event);
if ($event->getResponse() !== null) {
log_info('イベントレスポンス返却', array($Order->getId()));
return $event->getResponse();
}
// 受注IDをセッションにセット
$app['session']->set($this->sessionOrderKey, $Order->getId());
// メール送信
$MailHistory = $app['eccube.service.shopping']->sendOrderMail($Order);
$event = new EventArgs(array('form' => $form, 'Order' => $Order, 'MailHistory' => $MailHistory), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CONFIRM_COMPLETE, $event);
if ($event->getResponse() !== null) {
log_info('イベントレスポンス返却', array($Order->getId()));
return $event->getResponse();
}
// 完了画面表示
return $app->redirect($app->url('shopping_complete'));
}
log_info('購入チェックエラー', array($Order->getId()));
return $app->render('Shopping/index.twig', array('form' => $form->createView(), 'Order' => $Order));
}
示例7: confirm
/**
* 購入処理
*/
public function confirm(Application $app, Request $request)
{
$cartService = $app['eccube.service.cart'];
// カートチェック
if (!$cartService->isLocked()) {
// カートが存在しない、カートがロックされていない時はエラー
return $app->redirect($app->url('cart'));
}
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
if (!$Order) {
$app->addError('front.shopping.order.error');
return $app->redirect($app->url('shopping_error'));
}
// form作成
$form = $app['eccube.service.shopping']->getShippingForm($Order);
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
$data = $form->getData();
// トランザクション制御
$em = $app['orm.em'];
$em->getConnection()->beginTransaction();
try {
// 商品公開ステータスチェック、商品制限数チェック、在庫チェック
$check = $app['eccube.service.shopping']->isOrderProduct($em, $Order);
if (!$check) {
$em->getConnection()->rollback();
$em->close();
$app->addError('front.shopping.stock.error');
return $app->redirect($app->url('shopping_error'));
}
// 受注情報、配送情報を更新
$app['eccube.service.shopping']->setOrderUpdate($Order, $data);
// 在庫情報を更新
$app['eccube.service.shopping']->setStockUpdate($em, $Order);
if ($app->isGranted('ROLE_USER')) {
// 会員の場合、購入金額を更新
$app['eccube.service.shopping']->setCustomerUpdate($Order, $app->user());
}
$em->getConnection()->commit();
$em->flush();
$em->close();
} catch (\Exception $e) {
$em->getConnection()->rollback();
$em->close();
$app->log($e);
$app->addError('front.shopping.system.error');
return $app->redirect($app->url('shopping_error'));
}
// カート削除
$app['eccube.service.cart']->clear()->save();
// メール送信
$app['eccube.service.mail']->sendOrderMail($Order);
// 受注IDをセッションにセット
$app['session']->set($this->sessionOrderKey, $Order->getId());
// 完了画面表示
return $app->redirect($app->url('shopping_complete'));
} else {
return $app->render('Shopping/index.twig', array('form' => $form->createView(), 'Order' => $Order));
}
}
return $app->redirect($app->url('cart'));
}