Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit f5b2d7b

Browse files
Merge pull request #8 from tpsnghiale/4.2
Fix upgrade plugin sitekit for ec-cube 4.2
2 parents efcdfc2 + 74529cb commit f5b2d7b

22 files changed

+319
-53
lines changed

.github/workflows/main.yml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: CI for SiteKit42
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
tags:
7+
- '*'
8+
paths:
9+
- '**'
10+
- '!*.md'
11+
pull_request:
12+
branches:
13+
- '*'
14+
paths:
15+
- '**'
16+
- '!*.md'
17+
jobs:
18+
run-on-linux:
19+
name: Run on Linux
20+
runs-on: ${{ matrix.operating-system }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
operating-system: [ ubuntu-18.04 ]
25+
php: [ '7.4', '8.0', '8.1' ]
26+
db: [ 'mysql', 'mysql8', 'pgsql' ]
27+
eccube_version: [ '4.2' ]
28+
plugin_code: [ 'SiteKit42' ]
29+
include:
30+
- db: mysql
31+
database_url: mysql://root:password@127.0.0.1:3306/eccube_db
32+
database_server_version: 5.7
33+
database_charset: utf8mb4
34+
- db: mysql8
35+
database_url: mysql://root:password@127.0.0.1:3308/eccube_db
36+
database_server_version: 8
37+
database_charset: utf8mb4
38+
- db: pgsql
39+
database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db
40+
database_server_version: 14
41+
database_charset: utf8
42+
services:
43+
mysql:
44+
image: mysql:5.7
45+
env:
46+
MYSQL_ROOT_PASSWORD: password
47+
MYSQL_DATABASE: ${{ matrix.dbname }}
48+
ports:
49+
- 3306:3306
50+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
51+
mysql8:
52+
image: mysql:8
53+
env:
54+
MYSQL_ROOT_PASSWORD: password
55+
MYSQL_DATABASE: ${{ matrix.dbname }}
56+
ports:
57+
- 3308:3306
58+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
59+
postgres:
60+
image: postgres:14
61+
env:
62+
POSTGRES_USER: postgres
63+
POSTGRES_PASSWORD: password
64+
POSTGRES_DB: ${{ matrix.dbname }}
65+
ports:
66+
- 5432:5432
67+
# needed because the postgres container does not provide a healthcheck
68+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
69+
mailcatcher:
70+
image: schickling/mailcatcher
71+
ports:
72+
- 1080:1080
73+
- 1025:1025
74+
steps:
75+
- run: sudo apt-get purge -y hhvm
76+
- name: Checkout
77+
uses: actions/checkout@v2
78+
79+
- name: Setup PHP
80+
uses: nanasess/setup-php@master
81+
with:
82+
php-version: ${{ matrix.php }}
83+
84+
- name: Archive Plugin
85+
env:
86+
PLUGIN_CODE: ${{ matrix.plugin_code }}
87+
run: |
88+
tar cvzf ${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz ./*
89+
- name: Checkout EC-CUBE
90+
uses: actions/checkout@v2
91+
with:
92+
repository: 'EC-CUBE/ec-cube'
93+
ref: ${{ matrix.eccube_version }}
94+
path: 'ec-cube'
95+
96+
- name: Get Composer Cache Directory
97+
id: composer-cache
98+
run: |
99+
echo "::set-output name=dir::$(composer config cache-files-dir)"
100+
- uses: actions/cache@v1
101+
with:
102+
path: ${{ steps.composer-cache.outputs.dir }}
103+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
104+
restore-keys: |
105+
${{ runner.os }}-composer-
106+
- name: Install to composer
107+
working-directory: 'ec-cube'
108+
run: composer install --no-interaction -o --apcu-autoloader
109+
110+
- name: Setup EC-CUBE
111+
env:
112+
APP_ENV: 'test'
113+
APP_DEBUG: 0
114+
DATABASE_URL: ${{ matrix.database_url }}
115+
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
116+
DATABASE_CHARSET: ${{ matrix.database_charset }}
117+
working-directory: 'ec-cube'
118+
run: |
119+
bin/console doctrine:database:create
120+
bin/console doctrine:schema:create
121+
bin/console eccube:fixtures:load
122+
- name: Setup Plugin
123+
env:
124+
APP_ENV: 'test'
125+
APP_DEBUG: 0
126+
DATABASE_URL: ${{ matrix.database_url }}
127+
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
128+
DATABASE_CHARSET: ${{ matrix.database_charset }}
129+
PLUGIN_CODE: ${{ matrix.plugin_code }}
130+
working-directory: 'ec-cube'
131+
run: |
132+
composer require google/apiclient:^2.4
133+
bin/console eccube:plugin:install --code=${PLUGIN_CODE} --path=${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz
134+
bin/console cache:clear --no-warmup
135+
bin/console eccube:plugin:enable --code=${PLUGIN_CODE}
136+
- name: Run PHPUnit
137+
env:
138+
APP_ENV: 'test'
139+
APP_DEBUG: 0
140+
DATABASE_URL: ${{ matrix.database_url }}
141+
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
142+
DATABASE_CHARSET: ${{ matrix.database_charset }}
143+
PLUGIN_CODE: ${{ matrix.plugin_code }}
144+
working-directory: 'ec-cube'
145+
run: |
146+
bin/console cache:clear --no-warmup
147+
bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests
148+
149+
- name: Disable Plugin
150+
working-directory: 'ec-cube'
151+
env:
152+
APP_ENV: 'test'
153+
APP_DEBUG: 0
154+
DATABASE_URL: ${{ matrix.database_url }}
155+
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
156+
DATABASE_CHARSET: ${{ matrix.database_charset }}
157+
PLUGIN_CODE: ${{ matrix.plugin_code }}
158+
run: bin/console eccube:plugin:disable --code=${PLUGIN_CODE}
159+
160+
- name: Uninstall Plugin
161+
env:
162+
APP_ENV: 'test'
163+
APP_DEBUG: 0
164+
DATABASE_URL: ${{ matrix.database_url }}
165+
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
166+
DATABASE_CHARSET: ${{ matrix.database_charset }}
167+
PLUGIN_CODE: ${{ matrix.plugin_code }}
168+
working-directory: 'ec-cube'
169+
run: bin/console eccube:plugin:uninstall --code=${PLUGIN_CODE}

Controller/Admin/ConfigController.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Plugin\SiteKit\Controller\Admin;
14+
namespace Plugin\SiteKit42\Controller\Admin;
1515

1616
use Eccube\Controller\AbstractController;
1717
use Eccube\Entity\Member;
@@ -22,10 +22,10 @@
2222
use Google_Service_SiteVerification;
2323
use Google_Service_Webmasters;
2424
use GuzzleHttp\Client;
25-
use Plugin\SiteKit\Entity\IdToken;
26-
use Plugin\SiteKit\Repository\IdTokenRepository;
27-
use Plugin\SiteKit\Service\Google_Site_Kit_Client;
28-
use Plugin\SiteKit\Service\Google_Site_Kit_Proxy_Client;
25+
use Plugin\SiteKit42\Entity\IdToken;
26+
use Plugin\SiteKit42\Repository\IdTokenRepository;
27+
use Plugin\SiteKit42\Service\Google_Site_Kit_Client;
28+
use Plugin\SiteKit42\Service\Google_Site_Kit_Proxy_Client;
2929
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
3030
use Symfony\Component\Filesystem\Filesystem;
3131
use Symfony\Component\HttpFoundation\Request;
@@ -66,8 +66,8 @@ public function __construct(BaseInfoRepository $baseInfoRepository, IdTokenRepos
6666
}
6767

6868
/**
69-
* @Route("/%eccube_admin_route%/site_kit/config", name="site_kit_admin_config")
70-
* @Template("@SiteKit/admin/config.twig")
69+
* @Route("/%eccube_admin_route%/site_kit/config", name="site_kit42_admin_config")
70+
* @Template("@SiteKit42/admin/config.twig")
7171
*/
7272
public function index(Request $request)
7373
{
@@ -86,7 +86,7 @@ public function index(Request $request)
8686
[],
8787
UrlGeneratorInterface::ABSOLUTE_URL),
8888
'return_uri' => $this->generateUrl(
89-
'site_kit_admin_config',
89+
'site_kit42_admin_config',
9090
[],
9191
UrlGeneratorInterface::ABSOLUTE_URL),
9292
'analytics_redirect_uri' => $this->generateUrl(
@@ -120,7 +120,7 @@ public function analyticsCallback()
120120

121121
public function siteVerification()
122122
{
123-
$file = $this->eccubeConfig['plugin_data_realdir'].'/SiteKit/google-site-verification.txt';
123+
$file = $this->eccubeConfig['plugin_data_realdir'].'/SiteKit42/google-site-verification.txt';
124124
if (file_exists($file)) {
125125
$verificationToken = file_get_contents($file);
126126
return new Response($verificationToken);
@@ -145,7 +145,7 @@ public function actionCallback(Request $request, CacheUtil $cacheUtil, SystemSer
145145
$token = $request->get('googlesitekit_verification_token');
146146
$filesystem = new Filesystem();
147147
$filesystem->dumpFile(
148-
$this->eccubeConfig['plugin_data_realdir'].'/SiteKit/google-site-verification.txt',
148+
$this->eccubeConfig['plugin_data_realdir'].'/SiteKit42/google-site-verification.txt',
149149
'google-site-verification: '.$token
150150
);
151151

@@ -155,11 +155,11 @@ public function actionCallback(Request $request, CacheUtil $cacheUtil, SystemSer
155155
$yaml = Yaml::dump([
156156
'site_kit_google_site_verification' => [
157157
'path' => '/'.$token,
158-
'controller' => 'Plugin\SiteKit\Controller\Admin\ConfigController::siteVerification',
158+
'controller' => 'Plugin\SiteKit42\Controller\Admin\ConfigController::siteVerification',
159159
]
160160
]);
161161
$filesystem->dumpFile(
162-
$this->eccubeConfig['plugin_data_realdir'].'/SiteKit/routes.yaml',
162+
$this->eccubeConfig['plugin_data_realdir'].'/SiteKit42/routes.yaml',
163163
$yaml);
164164

165165
$cacheUtil->clearCache();
@@ -213,7 +213,7 @@ public function actionCallback(Request $request, CacheUtil $cacheUtil, SystemSer
213213

214214
/**
215215
* @Route("/%eccube_admin_route%/cube_kit/callback", name="site_kit_callback")
216-
* @Template("@SiteKit/admin/config.twig")
216+
* @Template("@SiteKit42/admin/config.twig")
217217
*
218218
* @param Request $request
219219
*

Controller/Admin/DashboardController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Plugin\SiteKit\Controller\Admin;
14+
namespace Plugin\SiteKit42\Controller\Admin;
1515

1616
use Eccube\Controller\AbstractController;
17-
use Plugin\SiteKit\Service\Google_Site_Kit_Proxy_Client;
17+
use Plugin\SiteKit42\Service\Google_Site_Kit_Proxy_Client;
1818
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
1919
use Symfony\Component\Routing\Annotation\Route;
2020
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -36,13 +36,13 @@ public function __construct(Google_Site_Kit_Proxy_Client $siteKitClient)
3636

3737
/**
3838
* @Route("/%eccube_admin_route%/site_kit/dashboard", name="site_kit_dashboard")
39-
* @Template("@SiteKit/admin/dashboard.twig")
39+
* @Template("@SiteKit42/admin/dashboard.twig")
4040
*/
4141
public function showGoogleSearchData()
4242
{
4343
$Member = $this->getUser();
4444
if (is_null($Member->getIdToken())) {
45-
return $this->redirectToRoute('site_kit_admin_config');
45+
return $this->redirectToRoute('site_kit42_admin_config');
4646
}
4747

4848
$jsonQuery = $this->getJsonFromGoogleSearchData('query');

Entity/BaseInfoTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Plugin\SiteKit\Entity;
14+
namespace Plugin\SiteKit42\Entity;
1515

1616
use Doctrine\ORM\Mapping as ORM;
1717
use Eccube\Annotation\EntityExtension;

Entity/IdToken.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Plugin\SiteKit\Entity;
14+
namespace Plugin\SiteKit42\Entity;
1515

1616
use Doctrine\ORM\Mapping as ORM;
1717
use Eccube\Entity\Member;
@@ -20,7 +20,7 @@
2020
* Class IdToken
2121
*
2222
* @ORM\Table(name="plg_site_kit_id_token")
23-
* @ORM\Entity(repositoryClass="Plugin\SiteKit\Repository\IdTokenRepository")
23+
* @ORM\Entity(repositoryClass="Plugin\SiteKit42\Repository\IdTokenRepository")
2424
*/
2525
class IdToken
2626
{

Entity/MemberTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Plugin\SiteKit\Entity;
14+
namespace Plugin\SiteKit42\Entity;
1515

1616
use Doctrine\ORM\Mapping as ORM;
1717
use Eccube\Annotation\EntityExtension;
@@ -22,7 +22,7 @@
2222
trait MemberTrait
2323
{
2424
/**
25-
* @ORM\OneToOne(targetEntity="Plugin\SiteKit\Entity\IdToken", mappedBy="Member")
25+
* @ORM\OneToOne(targetEntity="Plugin\SiteKit42\Entity\IdToken", mappedBy="Member")
2626
*/
2727
private $IdToken;
2828

Event.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Plugin\SiteKit;
3+
namespace Plugin\SiteKit42;
44

55
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
66

Form/Type/Admin/ConfigType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace Plugin\SiteKit\Form\Type\Admin;
3+
namespace Plugin\SiteKit42\Form\Type\Admin;
44

5-
use Plugin\SiteKit\Entity\Config;
5+
use Plugin\SiteKit42\Entity\Config;
66
use Symfony\Component\Form\AbstractType;
77
use Symfony\Component\Form\Extension\Core\Type\TextType;
88
use Symfony\Component\Form\FormBuilderInterface;

Nav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Plugin\SiteKit;
14+
namespace Plugin\SiteKit42;
1515

1616
use Eccube\Common\EccubeNav;
1717

PluginManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Plugin\SiteKit;
14+
namespace Plugin\SiteKit42;
1515

1616

1717
use Eccube\Plugin\AbstractPluginManager;
@@ -24,7 +24,7 @@ class PluginManager extends AbstractPluginManager
2424
public function install(array $meta, ContainerInterface $container)
2525
{
2626
$fs = new Filesystem();
27-
$routeYaml = $container->getParameter('plugin_data_realdir').'/SiteKit/routes.yaml';
27+
$routeYaml = $container->getParameter('plugin_data_realdir').'/SiteKit42/routes.yaml';
2828
if (!$fs->exists($routeYaml)) {
2929
$fs->dumpFile($routeYaml, '');
3030
}
@@ -33,7 +33,7 @@ public function install(array $meta, ContainerInterface $container)
3333
public function update(array $meta, ContainerInterface $container)
3434
{
3535
$fs = new Filesystem();
36-
$routeYaml = $container->getParameter('plugin_data_realdir').'/SiteKit/routes.yaml';
36+
$routeYaml = $container->getParameter('plugin_data_realdir').'/SiteKit42/routes.yaml';
3737
if (!$fs->exists($routeYaml)) {
3838
$fs->dumpFile($routeYaml, '');
3939
}

0 commit comments

Comments
 (0)