当前位置: 首页>>代码示例>>PHP>>正文


PHP ConfigQuery::getAdminCacheHomeStatsTTL方法代码示例

本文整理汇总了PHP中Thelia\Model\ConfigQuery::getAdminCacheHomeStatsTTL方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigQuery::getAdminCacheHomeStatsTTL方法的具体用法?PHP ConfigQuery::getAdminCacheHomeStatsTTL怎么用?PHP ConfigQuery::getAdminCacheHomeStatsTTL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thelia\Model\ConfigQuery的用法示例。


在下文中一共展示了ConfigQuery::getAdminCacheHomeStatsTTL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadStatsAjaxAction

 public function loadStatsAjaxAction()
 {
     if (null !== ($response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW))) {
         return $response;
     }
     $cacheExpire = ConfigQuery::getAdminCacheHomeStatsTTL();
     /** @var AdapterInterface $cacheAdapter */
     $cacheAdapter = $this->container->get('thelia.cache');
     $month = (int) $this->getRequest()->query->get('month', date('m'));
     $year = (int) $this->getRequest()->query->get('year', date('Y'));
     $cacheKey = self::STATS_CACHE_KEY . "_" . $month . "_" . $year;
     $cacheItem = $cacheAdapter->getItem($cacheKey);
     // force flush
     if ($this->getRequest()->query->get('flush', "0")) {
         $cacheAdapter->deleteItem($cacheItem);
     }
     if (!$cacheItem->isHit()) {
         $data = $this->getStatus($month, $year);
         $cacheItem->set(json_encode($data));
         $cacheItem->expiresAfter($cacheExpire);
         if ($cacheExpire) {
             $cacheAdapter->save($cacheItem);
         }
     }
     return $this->jsonResponse($cacheItem->get());
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:26,代码来源:HomeController.php

示例2: loadStatsAjaxAction

 public function loadStatsAjaxAction()
 {
     if (null !== ($response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW))) {
         return $response;
     }
     $cacheExpire = ConfigQuery::getAdminCacheHomeStatsTTL();
     $cacheContent = false;
     $month = (int) $this->getRequest()->query->get('month', date('m'));
     $year = (int) $this->getRequest()->query->get('year', date('Y'));
     if ($cacheExpire) {
         $context = "_" . $month . "_" . $year;
         $cacheKey = self::STATS_CACHE_KEY . $context;
         $cacheDriver = new FilesystemCache($this->getCacheDir());
         if (!$this->getRequest()->query->get('flush', "0")) {
             $cacheContent = $cacheDriver->fetch($cacheKey);
         } else {
             $cacheDriver->delete($cacheKey);
         }
     }
     if ($cacheContent === false) {
         $data = new \stdClass();
         $data->title = $this->getTranslator()->trans("Stats on %month/%year", ['%month' => $month, '%year' => $year]);
         /* sales */
         $saleSeries = new \stdClass();
         $saleSeries->color = self::testHexColor('sales_color', '#adadad');
         $saleSeries->data = OrderQuery::getMonthlySaleStats($month, $year);
         /* new customers */
         $newCustomerSeries = new \stdClass();
         $newCustomerSeries->color = self::testHexColor('customers_color', '#f39922');
         $newCustomerSeries->data = CustomerQuery::getMonthlyNewCustomersStats($month, $year);
         /* orders */
         $orderSeries = new \stdClass();
         $orderSeries->color = self::testHexColor('orders_color', '#5cb85c');
         $orderSeries->data = OrderQuery::getMonthlyOrdersStats($month, $year);
         /* first order */
         $firstOrderSeries = new \stdClass();
         $firstOrderSeries->color = self::testHexColor('first_orders_color', '#5bc0de');
         $firstOrderSeries->data = OrderQuery::getFirstOrdersStats($month, $year);
         /* cancelled orders */
         $cancelledOrderSeries = new \stdClass();
         $cancelledOrderSeries->color = self::testHexColor('cancelled_orders_color', '#d9534f');
         $cancelledOrderSeries->data = OrderQuery::getMonthlyOrdersStats($month, $year, array(5));
         $data->series = array($saleSeries, $newCustomerSeries, $orderSeries, $firstOrderSeries, $cancelledOrderSeries);
         $cacheContent = json_encode($data);
         if ($cacheExpire) {
             $cacheDriver->save($cacheKey, $cacheContent, $cacheExpire);
         }
     }
     return $this->jsonResponse($cacheContent);
 }
开发者ID:margery,项目名称:thelia,代码行数:50,代码来源:HomeController.php


注:本文中的Thelia\Model\ConfigQuery::getAdminCacheHomeStatsTTL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。