Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

プラグインのテンプレートを上書きできるように対応 #4527

Merged
merged 3 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added app/template/plugin/.gitkeep
Empty file.
Binary file added codeception/_data/plugins/Template-1.0.0.tgz
Binary file not shown.
29 changes: 29 additions & 0 deletions codeception/_support/Page/Admin/CacheManagePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Page\Admin;

class CacheManagePage extends AbstractAdminPageStyleGuide
{
public static function go($I)
{
$page = new self($I);

return $page->goPage('/content/cache', 'キャッシュ管理コンテンツ管理');
}

public function キャッシュ削除()
{
$this->tester->click('//*[@id="page_admin_content_cache"]/div[1]/div[3]/form/div/div/div/div/div[2]/div[2]/div/button');
}
}
35 changes: 35 additions & 0 deletions codeception/acceptance/EA10PluginCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Eccube\Common\EccubeConfig;
use Eccube\Entity\Plugin;
use Eccube\Repository\PluginRepository;
use Page\Admin\CacheManagePage;
use Page\Admin\PluginLocalInstallPage;
use Page\Admin\PluginManagePage;
use Page\Admin\PluginSearchPage;
Expand Down Expand Up @@ -401,6 +402,40 @@ public function test_install_error(\AcceptanceTester $I)
$Horizon->インストール();
}

/**
* @see https://github.com/EC-CUBE/ec-cube/pull/4527
*/
public function test_template_overwrite(\AcceptanceTester $I)
{
$plugin = new Local_Plugin($I, 'Template');
$plugin->インストール();
$plugin->有効化();

// テンプレートの確認
$I->amOnPage('/template');
$I->see('hello');

// テンプレートをapp/template/plugin/[Plugin Code]に設置
$dir = $this->config->get('eccube_theme_app_dir').'/plugin/Template';
$fs = new \Symfony\Component\Filesystem\Filesystem();
$fs->mkdir($dir);
$fs->dumpFile($dir.'/index.twig', 'bye');

// キャッシュ削除すると反映される
$page = CacheManagePage::go($I);
$page->キャッシュ削除();

// 上書きされていることを確認
$I->amOnPage('/template');
$I->see('bye');

$I->amOnPage('/'.$this->config->get('eccube_admin_route').'/store/plugin');
$plugin->無効化();
$plugin->削除();

$fs->remove($dir);
}

private function publishPlugin($fileName)
{
copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName);
Expand Down
7 changes: 7 additions & 0 deletions src/Eccube/DependencyInjection/EccubeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,15 @@ protected function configurePlugins(ContainerBuilder $container)
protected function configureTwigPaths(ContainerBuilder $container, $enabled, $pluginDir)
{
$paths = [];
$projectDir = $container->getParameter('kernel.project_dir');

foreach ($enabled as $code) {
// app/template/plugin/[plugin code]
$dir = $projectDir.'/app/template/plugin/'.$code;
if (file_exists($dir)) {
$paths[$dir] = $code;
}
// app/Plugin/[plugin code]/Resource/template
$dir = $pluginDir.'/'.$code.'/Resource/template';
if (file_exists($dir)) {
$paths[$dir] = $code;
Expand Down