-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from EC-CUBE/feature/1.0.0
1.0.0対応
- Loading branch information
Showing
39 changed files
with
2,596 additions
and
868 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# for php-coveralls | ||
#src_dir: src | ||
coverage_clover: coverage.clover | ||
json_path: coveralls-upload.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
language: php | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
|
||
env: | ||
# plugin code | ||
global: | ||
PLUGIN_CODE=RelatedProduct | ||
matrix: | ||
# ec-cube master | ||
- ECCUBE_VERSION=master DB=mysql USER=root DBNAME=myapp_test DBPASS=' ' DBUSER=root | ||
- ECCUBE_VERSION=master DB=pgsql USER=postgres DBNAME=myapp_test DBPASS=password DBUSER=postgres | ||
- ECCUBE_VERSION=master DB=sqlite | ||
# 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 | ||
matrix: | ||
fast_finish: true | ||
include: | ||
exclude: | ||
allow_failures: | ||
- php: 5.3 | ||
env: ECCUBE_VERSION=master DB=sqlite | ||
- php: 5.4 | ||
env: ECCUBE_VERSION=master DB=sqlite | ||
- php: 5.5 | ||
env: ECCUBE_VERSION=master DB=sqlite | ||
- php: 5.6 | ||
env: ECCUBE_VERSION=master DB=sqlite | ||
- php: 7.0 | ||
env: ECCUBE_VERSION=master DB=sqlite | ||
- php: 7.0 | ||
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 | ||
- gem install mailcatcher | ||
|
||
before_script: | ||
# archive plugin | ||
- tar cvzf ${HOME}/${PLUGIN_CODE}.tar.gz ./* | ||
# clone ec-cube | ||
- git clone https://github.com/EC-CUBE/ec-cube.git | ||
- cd ec-cube | ||
# checkout version | ||
- sh -c "if [ ! '${ECCUBE_VERSION}' = 'master' ]; then git checkout -b ${ECCUBE_VERSION} refs/tags/${ECCUBE_VERSION}; fi" | ||
# update composer | ||
- composer selfupdate | ||
- composer install --dev --no-interaction -o | ||
# install ec-cube | ||
- sh -c "if [ '$DB' = 'mysql' ]; then sh ./eccube_install.sh mysql none; fi" | ||
- sh -c "if [ '$DB' = 'pgsql' ]; then sh ./eccube_install.sh pgsql none; fi" | ||
- sh -c "if [ '$DB' = 'sqlite' ]; then sh ./eccube_install.sh sqlite3 none; fi" | ||
# install plugin | ||
- php app/console plugin:develop install --path=${HOME}/${PLUGIN_CODE}.tar.gz | ||
# enable plugin | ||
- php app/console plugin:develop enable --code=${PLUGIN_CODE} | ||
# mail catcher | ||
- mailcatcher | ||
|
||
script: | ||
# exec phpunit on ec-cube | ||
- phpunit app/Plugin/${PLUGIN_CODE}/Tests | ||
- if [[ $TRAVIS_PHP_VERSION =~ ^[7] ]]; then ./vendor/bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist --coverage-clover=coverage.clover ; fi | ||
|
||
after_script: | ||
# disable plugin | ||
- php app/console plugin:develop disable --code=${PLUGIN_CODE} | ||
# uninstall plugin | ||
- php app/console plugin:develop uninstall --code=${PLUGIN_CODE} | ||
# re install plugin | ||
- php app/console plugin:develop install --code=${PLUGIN_CODE} | ||
# re enable plugin | ||
- php app/console plugin:develop enable --code=${PLUGIN_CODE} | ||
|
||
after_success: | ||
# for coveralls | ||
- if [[ $TRAVIS_PHP_VERSION =~ ^[7] ]]; then php vendor/bin/coveralls -v -x coverage.clover ; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,101 @@ | ||
<?php | ||
/* | ||
* This file is part of EC-CUBE | ||
* | ||
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. | ||
* http://www.lockon.co.jp/ | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
* This file is part of the Related Product plugin | ||
* | ||
* Copyright (C) 2016 LOCKON CO.,LTD. All Rights Reserved. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Plugin\RelatedProduct\Controller\Admin; | ||
|
||
use Eccube\Application; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* Class RelatedProductController. | ||
*/ | ||
class RelatedProductController | ||
{ | ||
public function searchProduct(Application $app, Request $request) | ||
/** | ||
* search product modal. | ||
* | ||
* @param Application $app | ||
* @param Request $request | ||
* @param int $page_no | ||
* | ||
* @return \Symfony\Component\HttpFoundation\Response | ||
*/ | ||
public function searchProduct(Application $app, Request $request, $page_no = null) | ||
{ | ||
if ($request->isXmlHttpRequest()) { | ||
if (!$request->isXmlHttpRequest()) { | ||
return null; | ||
} | ||
|
||
$pageCount = $app['config']['default_page_count']; | ||
$session = $app['session']; | ||
if ('POST' === $request->getMethod()) { | ||
log_info('get search data with parameters ', array('id' => $request->get('id'), 'category_id' => $request->get('category_id'))); | ||
$page_no = 1; | ||
$searchData = array( | ||
'id' => $request->get('id'), | ||
); | ||
if ($categoryId = $request->get('category_id')) { | ||
$Category = $app['eccube.repository.category']->find($categoryId); | ||
$searchData['category_id'] = $Category; | ||
} | ||
$session->set('eccube.plugin.related_product.product.search', $searchData); | ||
$session->set('eccube.plugin.related_product.product.search.page_no', $page_no); | ||
} else { | ||
$searchData = (array) $session->get('eccube.plugin.related_product.product.search'); | ||
if (is_null($page_no)) { | ||
$page_no = intval($session->get('eccube.plugin.related_product.product.search.page_no')); | ||
} else { | ||
$session->set('eccube.plugin.related_product.product.search.page_no', $page_no); | ||
} | ||
} | ||
|
||
/** @var $Products \Eccube\Entity\Product[] */ | ||
$Products = $app['eccube.repository.product'] | ||
->getQueryBuilderBySearchDataForAdmin($searchData) | ||
->getQuery() | ||
->getResult(); | ||
$qb = $app['eccube.repository.product']->getQueryBuilderBySearchDataForAdmin($searchData); | ||
|
||
// 表示されている商品は検索結果に含めない | ||
$productId = $request->get('product_id'); | ||
$ProductsData = array(); | ||
$count = count($Products); | ||
$i = 0; | ||
for($i = 0; $i < $count; $i++) { | ||
$Product = $Products[$i]; | ||
if ($Product->getId() != $productId) { | ||
$ProductsData[] = $Product; | ||
} | ||
if ($i >= 10) { | ||
break; | ||
} | ||
} | ||
/** @var \Knp\Component\Pager\Pagination\SlidingPagination $pagination */ | ||
$pagination = $app['paginator']()->paginate( | ||
$qb, | ||
$page_no, | ||
$pageCount, | ||
array('wrap-queries' => true) | ||
); | ||
|
||
$message = ''; | ||
if ($count > $i) { | ||
$message = '検索結果の上限を超えています。検索条件を設定してください。'; | ||
} | ||
$paths = array(); | ||
$paths[] = $app['config']['template_admin_realdir']; | ||
$app['twig.loader']->addLoader(new \Twig_Loader_Filesystem($paths)); | ||
|
||
return $app->renderView( | ||
'RelatedProduct/Resource/template/Admin/modal_result.twig', | ||
array( | ||
'Products' => $ProductsData, | ||
'message' => $message, | ||
) | ||
); | ||
return $app->render('RelatedProduct/Resource/template/admin/modal_result.twig', array( | ||
'pagination' => $pagination, | ||
)); | ||
} | ||
|
||
/** | ||
* get product information. | ||
* | ||
* @param Application $app | ||
* @param Request $request | ||
* | ||
* @return \Symfony\Component\HttpFoundation\Response | ||
*/ | ||
public function getProduct(Application $app, Request $request) | ||
{ | ||
if (!$request->isXmlHttpRequest()) { | ||
return null; | ||
} | ||
|
||
$productId = $request->get('product_id'); | ||
$index = $request->get('index'); | ||
$Product = $app['eccube.repository.product']->find($productId); | ||
|
||
return $app->render('RelatedProduct/Resource/template/admin/product.twig', array( | ||
'Product' => $Product, | ||
'index' => $index, | ||
)); | ||
} | ||
} | ||
} |
Oops, something went wrong.