From 40e99f49a8848f93e4c1697a5d42dcc1763e0c44 Mon Sep 17 00:00:00 2001 From: lqdung Date: Tue, 11 Jul 2017 11:12:05 +0700 Subject: [PATCH 1/4] Change session rule as core --- Controller/Admin/RelatedProductController.php | 13 +++++++++++-- Utils/Version.php | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Controller/Admin/RelatedProductController.php b/Controller/Admin/RelatedProductController.php index 901eef1..8e3c9b8 100644 --- a/Controller/Admin/RelatedProductController.php +++ b/Controller/Admin/RelatedProductController.php @@ -11,6 +11,7 @@ namespace Plugin\RelatedProduct\Controller\Admin; use Eccube\Application; +use Plugin\RelatedProduct\Utils\Version; use Symfony\Component\HttpFoundation\Request; /** @@ -42,8 +43,12 @@ public function searchProduct(Application $app, Request $request, $page_no = nul 'id' => $request->get('id'), ); if ($categoryId = $request->get('category_id')) { - $Category = $app['eccube.repository.category']->find($categoryId); - $searchData['category_id'] = $Category; + $searchData['category_id'] = $app['eccube.repository.category']->find($categoryId); + + // New rule for session + if (Version::isSupportNewSession()) { + $searchData['category_id'] = $categoryId; + } } $session->set('eccube.plugin.related_product.product.search', $searchData); $session->set('eccube.plugin.related_product.product.search.page_no', $page_no); @@ -56,6 +61,10 @@ public function searchProduct(Application $app, Request $request, $page_no = nul } } + if (!empty($searchData['category_id']) && Version::isSupportNewSession()) { + $searchData['category_id'] = $app['eccube.repository.category']->find($searchData['category_id']); + } + $qb = $app['eccube.repository.product']->getQueryBuilderBySearchDataForAdmin($searchData); /** @var \Knp\Component\Pager\Pagination\SlidingPagination $pagination */ diff --git a/Utils/Version.php b/Utils/Version.php index b85b295..978a4a1 100644 --- a/Utils/Version.php +++ b/Utils/Version.php @@ -20,7 +20,7 @@ class Version /** * Check version to support get instance function. (monolog, new style, ...) * - * @return bool|int|mixed|void + * @return bool */ public static function isSupportGetInstanceFunction() { @@ -29,7 +29,7 @@ public static function isSupportGetInstanceFunction() /** * Check version to support get new hookpoint function. (monolog, new style, ...) * - * @return bool|int|mixed|void + * @return bool */ public static function isSupportNewHookpoint() { @@ -38,10 +38,20 @@ public static function isSupportNewHookpoint() /** * Check version to support new log function. * - * @return bool|int|mixed|void + * @return boo */ public static function isSupportLogFunction() { return version_compare(Constant::VERSION, '3.0.12', '>='); } + + /** + * Check version to support new session function. + * + * @return bool + */ + public static function isSupportNewSession() + { + return version_compare(Constant::VERSION, '3.0.15', '>='); + } } From 7fb8043af15339b52630c5e1862e030995a80cef Mon Sep 17 00:00:00 2001 From: lqdung Date: Wed, 12 Jul 2017 10:22:50 +0700 Subject: [PATCH 2/4] Remove check version --- Controller/Admin/RelatedProductController.php | 10 ++-------- Utils/Version.php | 12 +----------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/Controller/Admin/RelatedProductController.php b/Controller/Admin/RelatedProductController.php index 8e3c9b8..bb82d87 100644 --- a/Controller/Admin/RelatedProductController.php +++ b/Controller/Admin/RelatedProductController.php @@ -11,7 +11,6 @@ namespace Plugin\RelatedProduct\Controller\Admin; use Eccube\Application; -use Plugin\RelatedProduct\Utils\Version; use Symfony\Component\HttpFoundation\Request; /** @@ -43,12 +42,7 @@ public function searchProduct(Application $app, Request $request, $page_no = nul 'id' => $request->get('id'), ); if ($categoryId = $request->get('category_id')) { - $searchData['category_id'] = $app['eccube.repository.category']->find($categoryId); - - // New rule for session - if (Version::isSupportNewSession()) { - $searchData['category_id'] = $categoryId; - } + $searchData['category_id'] = $categoryId; } $session->set('eccube.plugin.related_product.product.search', $searchData); $session->set('eccube.plugin.related_product.product.search.page_no', $page_no); @@ -61,7 +55,7 @@ public function searchProduct(Application $app, Request $request, $page_no = nul } } - if (!empty($searchData['category_id']) && Version::isSupportNewSession()) { + if (!empty($searchData['category_id'])) { $searchData['category_id'] = $app['eccube.repository.category']->find($searchData['category_id']); } diff --git a/Utils/Version.php b/Utils/Version.php index 978a4a1..00cf1bf 100644 --- a/Utils/Version.php +++ b/Utils/Version.php @@ -38,20 +38,10 @@ public static function isSupportNewHookpoint() /** * Check version to support new log function. * - * @return boo + * @return bool */ public static function isSupportLogFunction() { return version_compare(Constant::VERSION, '3.0.12', '>='); } - - /** - * Check version to support new session function. - * - * @return bool - */ - public static function isSupportNewSession() - { - return version_compare(Constant::VERSION, '3.0.15', '>='); - } } From 9478261248a46dd9153e1db8987f8691676a38d9 Mon Sep 17 00:00:00 2001 From: lqdung Date: Wed, 12 Jul 2017 10:42:19 +0700 Subject: [PATCH 3/4] Add test travis --- .travis.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 629f099..7af5c3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,12 +25,9 @@ env: # ec-cube 3.0.9 - ECCUBE_VERSION=3.0.9 DB=mysql USER=root DBNAME=myapp_test DBPASS=' ' DBUSER=root - ECCUBE_VERSION=3.0.9 DB=pgsql USER=postgres DBNAME=myapp_test DBPASS=password DBUSER=postgres - # ec-cube 3.0.10 - - ECCUBE_VERSION=3.0.10 DB=mysql USER=root DBNAME=myapp_test DBPASS=' ' DBUSER=root - - ECCUBE_VERSION=3.0.10 DB=pgsql USER=postgres DBNAME=myapp_test DBPASS=password DBUSER=postgres # ec-cube 3.0.11 - - ECCUBE_VERSION=3.0.11 DB=mysql USER=root DBNAME=myapp_test DBPASS=' ' DBUSER=root - - ECCUBE_VERSION=3.0.11 DB=pgsql USER=postgres DBNAME=myapp_test DBPASS=password DBUSER=postgres + - ECCUBE_VERSION=3.0.13 DB=mysql USER=root DBNAME=myapp_test DBPASS=' ' DBUSER=root + - ECCUBE_VERSION=3.0.13 DB=pgsql USER=postgres DBNAME=myapp_test DBPASS=password DBUSER=postgres matrix: fast_finish: true include: @@ -50,10 +47,6 @@ matrix: env: ECCUBE_VERSION=3.0.9 DB=mysql USER=root DBNAME=myapp_test DBPASS=' ' DBUSER=root - php: 7.0 env: ECCUBE_VERSION=3.0.9 DB=pgsql USER=postgres DBNAME=myapp_test DBPASS=password DBUSER=postgres - - php: 7.0 - env: ECCUBE_VERSION=3.0.10 DB=mysql USER=root DBNAME=myapp_test DBPASS=' ' DBUSER=root - - php: 7.0 - env: ECCUBE_VERSION=3.0.10 DB=pgsql USER=postgres DBNAME=myapp_test DBPASS=password DBUSER=postgres install: - gem install mime-types -v 2.99.1 From e508a886b5a966613d506103ce2461297beaab30 Mon Sep 17 00:00:00 2001 From: lqdung Date: Mon, 17 Jul 2017 09:13:26 +0700 Subject: [PATCH 4/4] Update minor version --- config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yml b/config.yml index 10efe72..0b640b3 100644 --- a/config.yml +++ b/config.yml @@ -1,6 +1,6 @@ name: 関連商品プラグイン code: RelatedProduct -version: 1.0.0 +version: 1.0.1 service: - RelatedProductServiceProvider orm.path: