From 2b1fe3e59c12064547d6051c91219e70494ab69d Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Thu, 13 Sep 2018 16:41:47 +0900 Subject: [PATCH 1/6] =?UTF-8?q?3.0.x=E3=81=AEresult=20cache=E3=82=92?= =?UTF-8?q?=E7=A7=BB=E6=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Repository/AbstractRepository.php | 4 +--- src/Eccube/Repository/BaseInfoRepository.php | 25 ++++---------------- src/Eccube/Repository/CategoryRepository.php | 6 +---- src/Eccube/Repository/LayoutRepository.php | 10 ++++---- src/Eccube/Repository/PageRepository.php | 25 ++++++++++++++++++++ 5 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/Eccube/Repository/AbstractRepository.php b/src/Eccube/Repository/AbstractRepository.php index 1f135cf0e95..ff83dfe0826 100644 --- a/src/Eccube/Repository/AbstractRepository.php +++ b/src/Eccube/Repository/AbstractRepository.php @@ -46,8 +46,6 @@ public function save($entity) protected function getCacheLifetime() { - // $options = $this->eccubeConfig['doctrine_cache']; - // return $options['result_cache']['lifetime']; - return 0; // FIXME + return 3600; // TODO 設定に切り出すほどでもないので一旦固定で. } } diff --git a/src/Eccube/Repository/BaseInfoRepository.php b/src/Eccube/Repository/BaseInfoRepository.php index 9e3a651e6c8..488bdbe09f9 100644 --- a/src/Eccube/Repository/BaseInfoRepository.php +++ b/src/Eccube/Repository/BaseInfoRepository.php @@ -15,7 +15,6 @@ use Eccube\Entity\BaseInfo; use Symfony\Bridge\Doctrine\RegistryInterface; -use Symfony\Component\HttpKernel\KernelInterface; /** * BaseInfoRepository @@ -25,43 +24,29 @@ */ class BaseInfoRepository extends AbstractRepository { - /** - * @var KernelInterface - */ - protected $kernel; - /** * BaseInfoRepository constructor. * * @param RegistryInterface $registry - * @param KernelInterface $kernel */ - public function __construct(RegistryInterface $registry, KernelInterface $kernel) + public function __construct(RegistryInterface $registry) { parent::__construct($registry, BaseInfo::class); - $this->kernel = $kernel; } /** * @param int $id * * @return BaseInfo - * - * @throws \Doctrine\ORM\NoResultException - * @throws \Doctrine\ORM\NonUniqueResultException */ public function get($id = 1) { - $qb = $this->createQueryBuilder('e') - ->where('e.id = :id') - ->setParameter('id', $id); + $BaseInfo = $this->find($id); - if (!$this->kernel->isDebug()) { - $qb->setCacheable(true); + if (null === $BaseInfo) { + throw new \Exception('BaseInfo not found. id = '. $id); } - return $qb->getQuery() - ->useResultCache(true, $this->getCacheLifetime()) - ->getSingleResult(); + return $this->find($id); } } diff --git a/src/Eccube/Repository/CategoryRepository.php b/src/Eccube/Repository/CategoryRepository.php index a42a890f1d0..80bb5024960 100644 --- a/src/Eccube/Repository/CategoryRepository.php +++ b/src/Eccube/Repository/CategoryRepository.php @@ -72,10 +72,6 @@ public function getTotalCount() */ public function getList(Category $Parent = null, $flat = false) { - // TODO::doctrine_cache is not implement - // $options = $this->eccubeConfig['doctrine_cache']; - // $lifetime = $options['result_cache']['lifetime']; - $qb = $this->createQueryBuilder('c1') ->select('c1, c2, c3, c4, c5') ->leftJoin('c1.Children', 'c2') @@ -94,7 +90,7 @@ public function getList(Category $Parent = null, $flat = false) $qb->where('c1.Parent IS NULL'); } $Categories = $qb->getQuery() - // ->useResultCache(true, $lifetime) TODO::doctrine_cache is not implement + ->useResultCache(true, $this->getCacheLifetime()) ->getResult(); if ($flat) { diff --git a/src/Eccube/Repository/LayoutRepository.php b/src/Eccube/Repository/LayoutRepository.php index 23f42f9dbc9..184bdcb2b19 100644 --- a/src/Eccube/Repository/LayoutRepository.php +++ b/src/Eccube/Repository/LayoutRepository.php @@ -13,8 +13,8 @@ namespace Eccube\Repository; -use Eccube\Entity\Layout; use Doctrine\ORM\NoResultException; +use Eccube\Entity\Layout; use Symfony\Bridge\Doctrine\RegistryInterface; /** @@ -30,18 +30,20 @@ public function __construct(RegistryInterface $registry) parent::__construct($registry, Layout::class); } - public function get($layout_id) + public function get($id) { try { $Layout = $this->createQueryBuilder('l') ->select('l, bp, b') ->leftJoin('l.BlockPositions', 'bp') ->leftJoin('bp.Block', 'b') - ->where('l.id = :layout_id') + ->where('l.id = :id') ->orderBy('bp.block_row', 'ASC') - ->setParameter('layout_id', $layout_id) + ->setParameter('id', $id) ->getQuery() + ->useResultCache(true, $this->getCacheLifetime()) ->getSingleResult(); + } catch (NoResultException $e) { return null; } diff --git a/src/Eccube/Repository/PageRepository.php b/src/Eccube/Repository/PageRepository.php index 0c0999b8720..2cbe2351d55 100644 --- a/src/Eccube/Repository/PageRepository.php +++ b/src/Eccube/Repository/PageRepository.php @@ -66,6 +66,31 @@ public function __construct(RegistryInterface $registry, EccubeConfig $eccubeCon $this->templateDefaultRealDir = $container->getParameter('eccube_theme_src_dir'); } + /** + * @param $route + * @return Page + */ + public function getPageByRoute($route) + { + $qb = $this->createQueryBuilder('p'); + + try { + $Page = $qb + ->select(['p', 'pl', 'l']) + ->leftJoin('p.PageLayouts', 'pl') + ->leftJoin('pl.Layout', 'l') + ->where('p.url = :url') + ->setParameter('url', $route) + ->getQuery() + ->useResultCache(true, $this->getCacheLifetime()) + ->getSingleResult(); + } catch (\Exception $e) { + return $this->newPage(); + } + + return $Page; + } + /** * @param string $url * From 2b34c9809586b20ec84b42e874bdb96f63b321eb Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Thu, 13 Sep 2018 17:05:34 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A5=E3=81=AE=E5=89=8A=E9=99=A4=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Content/BlockController.php | 17 +++---- .../Admin/Content/LayoutController.php | 15 +++++-- .../Admin/Content/NewsController.php | 12 ++++- .../Admin/Content/PageController.php | 16 ++++--- .../Admin/Product/CategoryController.php | 13 +++++- .../Admin/Setting/Shop/ShopController.php | 3 +- src/Eccube/Entity/News.php | 1 + src/Eccube/Repository/NewsRepository.php | 20 +++++---- src/Eccube/Util/CacheUtil.php | 44 +++++++++++++++++++ 9 files changed, 111 insertions(+), 30 deletions(-) diff --git a/src/Eccube/Controller/Admin/Content/BlockController.php b/src/Eccube/Controller/Admin/Content/BlockController.php index c463dc71232..e596288eaf8 100644 --- a/src/Eccube/Controller/Admin/Content/BlockController.php +++ b/src/Eccube/Controller/Admin/Content/BlockController.php @@ -21,6 +21,7 @@ use Eccube\Form\Type\Admin\BlockType; use Eccube\Repository\BlockRepository; use Eccube\Repository\Master\DeviceTypeRepository; +use Eccube\Util\CacheUtil; use Eccube\Util\StringUtil; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\Filesystem\Filesystem; @@ -80,7 +81,7 @@ public function index(Request $request) * @Route("/%eccube_admin_route%/content/block/{id}/edit", requirements={"id" = "\d+"}, name="admin_content_block_edit") * @Template("@admin/Content/block_edit.twig") */ - public function edit(Request $request, $id = null, Environment $twig, FileSystem $fs) + public function edit(Request $request, $id = null, Environment $twig, FileSystem $fs, CacheUtil $cacheUtil) { $DeviceType = $this->deviceTypeRepository ->find(DeviceType::DEVICE_TYPE_PC); @@ -153,9 +154,9 @@ public function edit(Request $request, $id = null, Environment $twig, FileSystem } } - // twigキャッシュの削除 - $cacheDir = $this->getParameter('kernel.cache_dir').'/twig'; - $fs->remove($cacheDir); + // キャッシュの削除 + $cacheUtil->clearTwigCache(); + $cacheUtil->clearDoctrineCache(); $event = new EventArgs( [ @@ -181,7 +182,7 @@ public function edit(Request $request, $id = null, Environment $twig, FileSystem /** * @Route("/%eccube_admin_route%/content/block/{id}/delete", requirements={"id" = "\d+"}, name="admin_content_block_delete", methods={"DELETE"}) */ - public function delete(Request $request, Block $Block, Filesystem $fs) + public function delete(Request $request, Block $Block, Filesystem $fs, CacheUtil $cacheUtil) { $this->isTokenValid(); @@ -210,9 +211,9 @@ public function delete(Request $request, Block $Block, Filesystem $fs) $this->addSuccess('admin.common.delete_complete', 'admin'); - // twigキャッシュの削除 - $cacheDir = $this->getParameter('kernel.cache_dir').'/twig'; - $fs->remove($cacheDir); + // キャッシュの削除 + $cacheUtil->clearTwigCache(); + $cacheUtil->clearDoctrineCache(); } return $this->redirectToRoute('admin_content_block'); diff --git a/src/Eccube/Controller/Admin/Content/LayoutController.php b/src/Eccube/Controller/Admin/Content/LayoutController.php index a7f4ef53736..3f10c80a682 100644 --- a/src/Eccube/Controller/Admin/Content/LayoutController.php +++ b/src/Eccube/Controller/Admin/Content/LayoutController.php @@ -25,6 +25,7 @@ use Eccube\Repository\PageRepository; use Eccube\Repository\ProductRepository; use Eccube\Repository\Master\DeviceTypeRepository; +use Eccube\Util\CacheUtil; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -123,7 +124,7 @@ public function index() * * @return RedirectResponse */ - public function delete(Layout $Layout) + public function delete(Layout $Layout, CacheUtil $cacheUtil) { $this->isTokenValid(); @@ -139,6 +140,9 @@ public function delete(Layout $Layout) $this->addSuccess('admin.common.delete_complete', 'admin'); + // キャッシュの削除 + $cacheUtil->clearDoctrineCache(); + return $this->redirectToRoute('admin_content_layout'); } @@ -147,7 +151,7 @@ public function delete(Layout $Layout) * @Route("/%eccube_admin_route%/content/layout/{id}/edit", requirements={"id" = "\d+"}, name="admin_content_layout_edit") * @Template("@admin/Content/layout.twig") */ - public function edit(Request $request, $id = null, $previewPageId = null) + public function edit(Request $request, $id = null, $previewPageId = null, CacheUtil $cacheUtil) { if (is_null($id)) { $Layout = new Layout(); @@ -190,6 +194,9 @@ public function edit(Request $request, $id = null, $previewPageId = null) $data = $request->request->all(); $this->blockPositionRepository->register($data, $Blocks, $UnusedBlocks, $Layout); + // キャッシュの削除 + $cacheUtil->clearDoctrineCache(); + // プレビューモード if ($this->isPreview) { // プレビューする画面を取得 @@ -267,11 +274,11 @@ public function viewBlock(Request $request, Twig $twig) /** * @Route("/%eccube_admin_route%/content/layout/{id}/preview", requirements={"id" = "\d+"}, name="admin_content_layout_preview") */ - public function preview(Request $request, $id) + public function preview(Request $request, $id, CacheUtil $cacheUtil) { $form = $request->get('admin_layout'); $this->isPreview = true; - return $this->edit($request, $id, $form['Page']); + return $this->edit($request, $id, $form['Page'], $cacheUtil); } } diff --git a/src/Eccube/Controller/Admin/Content/NewsController.php b/src/Eccube/Controller/Admin/Content/NewsController.php index fd2f0c84c5c..b6d9c7c0367 100644 --- a/src/Eccube/Controller/Admin/Content/NewsController.php +++ b/src/Eccube/Controller/Admin/Content/NewsController.php @@ -19,6 +19,7 @@ use Eccube\Event\EventArgs; use Eccube\Form\Type\Admin\NewsType; use Eccube\Repository\NewsRepository; +use Eccube\Util\CacheUtil; use Knp\Component\Pager\Paginator; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\HttpFoundation\Request; @@ -90,7 +91,7 @@ public function index(Request $request, $page_no = 1, Paginator $paginator) * * @return array|\Symfony\Component\HttpFoundation\RedirectResponse */ - public function edit(Request $request, $id = null) + public function edit(Request $request, $id = null, CacheUtil $cacheUtil) { if ($id) { $News = $this->newsRepository->find($id); @@ -134,6 +135,9 @@ public function edit(Request $request, $id = null) $this->addSuccess('admin.common.save_complete', 'admin'); + // キャッシュの削除 + $cacheUtil->clearDoctrineCache(); + return $this->redirectToRoute('admin_content_news_edit', ['id' => $News->getId()]); } @@ -153,7 +157,7 @@ public function edit(Request $request, $id = null) * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - public function delete(Request $request, News $News) + public function delete(Request $request, News $News, CacheUtil $cacheUtil) { $this->isTokenValid(); @@ -168,6 +172,10 @@ public function delete(Request $request, News $News) $this->addSuccess('admin.common.delete_complete', 'admin'); log_info('新着情報削除完了', [$News->getId()]); + + // キャッシュの削除 + $cacheUtil->clearDoctrineCache(); + } catch (\Exception $e) { $message = trans('admin.common.delete_error_foreign_key', ['%name%' => $News->getTitle()]); $this->addError($message, 'admin'); diff --git a/src/Eccube/Controller/Admin/Content/PageController.php b/src/Eccube/Controller/Admin/Content/PageController.php index 720f71ee870..9a09a360261 100644 --- a/src/Eccube/Controller/Admin/Content/PageController.php +++ b/src/Eccube/Controller/Admin/Content/PageController.php @@ -22,12 +22,14 @@ use Eccube\Repository\Master\DeviceTypeRepository; use Eccube\Repository\PageLayoutRepository; use Eccube\Repository\PageRepository; +use Eccube\Util\CacheUtil; use Eccube\Util\StringUtil; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Bundle\FrameworkBundle\Routing\Router; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\RouterInterface; use Twig\Environment; class PageController extends AbstractController @@ -89,7 +91,7 @@ public function index(Request $request) * @Route("/%eccube_admin_route%/content/page/{id}/edit", requirements={"id" = "\d+"}, name="admin_content_page_edit") * @Template("@admin/Content/page_edit.twig") */ - public function edit(Request $request, $id = null, Environment $twig, Router $router) + public function edit(Request $request, $id = null, Environment $twig, RouterInterface $router, CacheUtil $cacheUtil) { if (null === $id) { $Page = $this->pageRepository->newPage(); @@ -222,9 +224,9 @@ public function edit(Request $request, $id = null, Environment $twig, Router $ro $this->addSuccess('admin.common.save_complete', 'admin'); - // twig キャッシュの削除. - $cacheDir = $this->getParameter('kernel.cache_dir').'/twig'; - $fs->remove($cacheDir); + // キャッシュの削除 + $cacheUtil->clearTwigCache(); + $cacheUtil->clearDoctrineCache(); return $this->redirectToRoute('admin_content_page_edit', ['id' => $Page->getId()]); } @@ -251,7 +253,7 @@ public function edit(Request $request, $id = null, Environment $twig, Router $ro /** * @Route("/%eccube_admin_route%/content/page/{id}/delete", requirements={"id" = "\d+"}, name="admin_content_page_delete", methods={"DELETE"}) */ - public function delete(Request $request, $id = null) + public function delete(Request $request, $id = null, CacheUtil $cacheUtil) { $this->isTokenValid(); @@ -286,6 +288,10 @@ public function delete(Request $request, $id = null) $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_CONTENT_PAGE_DELETE_COMPLETE, $event); $this->addSuccess('admin.common.delete_complete', 'admin'); + + // キャッシュの削除 + $cacheUtil->clearTwigCache(); + $cacheUtil->clearDoctrineCache(); } return $this->redirectToRoute('admin_content_page'); diff --git a/src/Eccube/Controller/Admin/Product/CategoryController.php b/src/Eccube/Controller/Admin/Product/CategoryController.php index 0ae662be950..50d883eaa75 100644 --- a/src/Eccube/Controller/Admin/Product/CategoryController.php +++ b/src/Eccube/Controller/Admin/Product/CategoryController.php @@ -21,6 +21,7 @@ use Eccube\Form\Type\Admin\CategoryType; use Eccube\Repository\CategoryRepository; use Eccube\Service\CsvExportService; +use Eccube\Util\CacheUtil; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -61,7 +62,7 @@ public function __construct( * @Route("/%eccube_admin_route%/product/category/{id}/edit", requirements={"id" = "\d+"}, name="admin_product_category_edit") * @Template("@admin/Product/category.twig") */ - public function index(Request $request, $parent_id = null, $id = null) + public function index(Request $request, $parent_id = null, $id = null, CacheUtil $cacheUtil) { if ($parent_id) { /** @var Category $Parent */ @@ -137,6 +138,9 @@ public function index(Request $request, $parent_id = null, $id = null) $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_PRODUCT_CATEGORY_INDEX_COMPLETE, $event); $this->addSuccess('admin.common.save_complete', 'admin'); + + $cacheUtil->clearDoctrineCache(); + if ($Parent) { return $this->redirectToRoute('admin_product_category_show', ['parent_id' => $Parent->getId()]); } else { @@ -162,6 +166,8 @@ public function index(Request $request, $parent_id = null, $id = null) $this->addSuccess('admin.common.save_complete', 'admin'); + $cacheUtil->clearDoctrineCache(); + if ($Parent) { return $this->redirectToRoute('admin_product_category_show', ['parent_id' => $Parent->getId()]); } else { @@ -198,7 +204,7 @@ public function index(Request $request, $parent_id = null, $id = null) /** * @Route("/%eccube_admin_route%/product/category/{id}/delete", requirements={"id" = "\d+"}, name="admin_product_category_delete", methods={"DELETE"}) */ - public function delete(Request $request, $id) + public function delete(Request $request, $id, CacheUtil $cacheUtil) { $this->isTokenValid(); @@ -226,6 +232,9 @@ public function delete(Request $request, $id) $this->addSuccess('admin.common.delete_complete', 'admin'); log_info('カテゴリ削除完了', [$id]); + + $cacheUtil->clearDoctrineCache(); + } catch (\Exception $e) { log_info('カテゴリ削除エラー', [$id, $e]); diff --git a/src/Eccube/Controller/Admin/Setting/Shop/ShopController.php b/src/Eccube/Controller/Admin/Setting/Shop/ShopController.php index 6a629fab658..0e11cd1e73c 100644 --- a/src/Eccube/Controller/Admin/Setting/Shop/ShopController.php +++ b/src/Eccube/Controller/Admin/Setting/Shop/ShopController.php @@ -96,7 +96,8 @@ public function index(Request $request, CacheUtil $cacheUtil) $event ); - $cacheUtil->clearCache(); + // キャッシュの削除 + $cacheUtil->clearDoctrineCache(); $this->addSuccess('admin.common.save_complete', 'admin'); diff --git a/src/Eccube/Entity/News.php b/src/Eccube/Entity/News.php index f9c9eb3afb3..2ab8ca5787f 100644 --- a/src/Eccube/Entity/News.php +++ b/src/Eccube/Entity/News.php @@ -24,6 +24,7 @@ * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255) * @ORM\HasLifecycleCallbacks() * @ORM\Entity(repositoryClass="Eccube\Repository\NewsRepository") + * @ORM\Cache(usage="NONSTRICT_READ_WRITE") */ class News extends AbstractEntity { diff --git a/src/Eccube/Repository/NewsRepository.php b/src/Eccube/Repository/NewsRepository.php index 0efc3b0e03b..61f2fdc2d5c 100644 --- a/src/Eccube/Repository/NewsRepository.php +++ b/src/Eccube/Repository/NewsRepository.php @@ -13,6 +13,8 @@ namespace Eccube\Repository; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Criteria; use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; use Eccube\Entity\News; @@ -71,17 +73,19 @@ public function getQueryBuilderAll() } /** - * @return mixed + * @return News[]|ArrayCollection */ public function getList() { - $qb = $this->createQueryBuilder('n'); - $qb->where('n.publish_date <= :date') - ->andWhere('n.visible = TRUE') - ->setParameter('date', new \DateTime()) - ->orderBy('n.publish_date', 'DESC') - ->addOrderBy('n.id', 'DESC'); + // second level cacheを効かせるためfindByで取得 + $Results = $this->findBy(['visible' => true], ['publish_date' => 'DESC', 'id' => 'DESC']); + + // 公開日時前のNewsをフィルター + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->lte('publish_date', new \DateTime())); + + $News = new ArrayCollection($Results); - return $qb->getQuery()->getResult(); + return $News->matching($criteria); } } diff --git a/src/Eccube/Util/CacheUtil.php b/src/Eccube/Util/CacheUtil.php index 41900b003c0..386f86e1674 100644 --- a/src/Eccube/Util/CacheUtil.php +++ b/src/Eccube/Util/CacheUtil.php @@ -85,6 +85,50 @@ public function forceClearCache(PostResponseEvent $event) return $output->fetch(); } + /** + * Doctrineのキャッシュを削除します. + * APP_ENV=prodの場合のみ実行されます. + * + * @param null $env + * @return string + * @throws \Exception + */ + public function clearDoctrineCache() + { + if ($this->kernel->getEnvironment() !== 'prod') { + return; + } + $console = new Application($this->kernel); + $console->setAutoExit(false); + + $command = [ + 'command' => 'cache:pool:clear', + 'pools' => ['doctrine.app_cache_pool'], + '--no-ansi' => true, + ]; + + $input = new ArrayInput($command); + + $output = new BufferedOutput( + OutputInterface::VERBOSITY_DEBUG, + true + ); + + $console->run($input, $output); + + return $output->fetch(); + } + + /** + * Twigキャッシュを削除します. + */ + public function clearTwigCache() + { + $cacheDir = $this->kernel->getCacheDir().'/twig'; + $fs = new Filesystem(); + $fs->remove($cacheDir); + } + /** * キャッシュを削除する. * From de2e4bfc8576bf94d77ac2b0746bb9ced2aac1c1 Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Thu, 13 Sep 2018 17:06:32 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=E3=82=AB=E3=83=BC=E3=83=88=E3=83=96?= =?UTF-8?q?=E3=83=AD=E3=83=83=E3=82=AF=E3=81=AE=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/services.yaml | 3 +++ src/Eccube/Resource/template/default/Block/cart.twig | 3 +++ src/Eccube/Resource/template/default/Block/header.twig | 4 ++-- src/Eccube/Service/CartService.php | 6 +++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/config/eccube/services.yaml b/app/config/eccube/services.yaml index 8fabac62760..088488f8066 100644 --- a/app/config/eccube/services.yaml +++ b/app/config/eccube/services.yaml @@ -45,6 +45,9 @@ services: lazy: true public: true + Ecccube\Service\CartService: + lazy: true + Eccube\Service\SystemService: lazy: true public: true diff --git a/src/Eccube/Resource/template/default/Block/cart.twig b/src/Eccube/Resource/template/default/Block/cart.twig index 98b02cca439..21f07936c63 100644 --- a/src/Eccube/Resource/template/default/Block/cart.twig +++ b/src/Eccube/Resource/template/default/Block/cart.twig @@ -8,6 +8,9 @@ http://www.lockon.co.jp/ For the full copyright and license information, please view the LICENSE file that was distributed with this source code. #} +{% set Carts = get_all_carts() %} +{% set totalPrice = get_carts_total_price() %} +{% set totalQuantity = get_carts_total_quantity() %}