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

[3n]-[Core]-[1656]-アセットのあるプラグインがインストールできない #129

Open
ndquocphong opened this issue Jul 13, 2018 · 5 comments
Assignees
Labels

Comments

@ndquocphong
Copy link

ndquocphong commented Jul 13, 2018

概要(Overview)

While install a plugin which have asset, an error occurred

期待する内容(Expect) or 要望 (Requirement)

  • Install plugin success although it have asset
  • Need define the way work with asset on plugin
  • Correct parameter plugin_html_realdir and plugin_temp_realdir at eccube.yaml

再現手順(Procedure)

  1. Place asset into Resource/asset directory
SamplePlugin
  ├── Resource
  │   ├── assets
  │   │   ├── css
  │   │   │   └── xxxx.css
  │   │   ├── img
  │   │   │   ├── xxxx.gif
  │   │   │   ├── xxxx.jpg
  │   │   │   └── xxxx.png
  │   │   └── js
  │   │       └── xxxx.js
  1. Run command php bin/console eccube:plugin:install --code=SamplePlugin
  2. Error occurred
[Symfony\Component\Filesystem\Exception\IOException]
Failed to create "/PATH/TO/WEB_ROOT/src/Eccube/Repository/Master/plugin/SamplePlugin/assets"

環境 (environment)

  • EC-CUBE: 3.n
  • PHP: 7.1
  • DB:
    • MySQL 5.7

関連情報 (Ref)

Exception trace:

 Symfony\Component\Filesystem\Filesystem->mkdir() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/filesystem/Filesystem.php:571
 Symfony\Component\Filesystem\Filesystem->mirror() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/src/Eccube/Service/PluginService.php:1010
 Eccube\Service\PluginService->copyAssets() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/src/Eccube/Service/PluginService.php:195
 Eccube\Service\PluginService->install() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/src/Eccube/Command/PluginInstallCommand.php:43
 Eccube\Command\PluginInstallCommand->execute() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/console/Command/Command.php:252
 Symfony\Component\Console\Command\Command->run() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/console/Application.php:964
 Symfony\Component\Console\Application->doRunCommand() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/framework-bundle/Console/Application.php:86
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/console/Application.php:248
 Symfony\Component\Console\Application->doRun() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/framework-bundle/Console/Application.php:74
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/bin/console:37
@ndquocphong ndquocphong changed the title [3n]-[1656]-Unable install plugin which have asset [3n]-[Core]-[1656]-Unable install plugin which have asset Jul 13, 2018
@nhpkhanh-lk
Copy link

概要(Overview)

アセットがあるプラグインをインストールしたら、エラーが出る。

期待する内容(Expect) or 要望 (Requirement)

  • アセットのあるプラグインがインストールできること。
  • アセットの管理し方(コビーして、どこに保存する?)を定義する。
  • eccube.yamlでの plugin_html_realdirplugin_temp_realdir のパラメーターを修正する。

再現手順(Procedure)

  1. Resource/assetディレクトリにアセットを入れる
SamplePlugin
---Resource
------asset
---------xxx.js
---------xxx.css
  1. コマンド php bin/console eccube:plugin:install --code=SamplePluginを実行
  2. エラー
[Symfony\Component\Filesystem\Exception\IOException]
Failed to create "/PATH/TO/WEB_ROOT/src/Eccube/Repository/Master/plugin/SamplePlugin/assets"

環境 (environment)

  • EC-CUBE: 3.n
  • PHP: 7.1
  • DB:
    • MySQL 5.7

関連情報 (Ref)

Exception trace:

 Symfony\Component\Filesystem\Filesystem->mkdir() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/filesystem/Filesystem.php:571
 Symfony\Component\Filesystem\Filesystem->mirror() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/src/Eccube/Service/PluginService.php:1010
 Eccube\Service\PluginService->copyAssets() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/src/Eccube/Service/PluginService.php:195
 Eccube\Service\PluginService->install() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/src/Eccube/Command/PluginInstallCommand.php:43
 Eccube\Command\PluginInstallCommand->execute() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/console/Command/Command.php:252
 Symfony\Component\Console\Command\Command->run() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/console/Application.php:964
 Symfony\Component\Console\Application->doRunCommand() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/framework-bundle/Console/Application.php:86
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/console/Application.php:248
 Symfony\Component\Console\Application->doRun() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/framework-bundle/Console/Application.php:74
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /home/travis/build/eccubevn/related-product-plugin/ec-cube/bin/console:37

@ryo-endo
Copy link

@ndquocphong Please, try this patch.

Index: src/Eccube/Service/PluginService.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/Eccube/Service/PluginService.php	(date 1531992579000)
+++ src/Eccube/Service/PluginService.php	(date 1531996537504)
@@ -1007,7 +1007,7 @@
         // プラグインにリソースファイルがあれば所定の位置へコピー
         if (file_exists($assetsDir)) {
             $file = new Filesystem();
-            $file->mirror($assetsDir, $this->eccubeConfig['plugin_html_realdir'].$pluginCode.'/assets');
+            $file->mirror($assetsDir, $this->eccubeConfig['plugin_html_realdir'].'/'.$pluginCode.'/assets');
         }
     }
 
Index: app/config/eccube/packages/eccube.yaml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- app/config/eccube/packages/eccube.yaml	(date 1531992579000)
+++ app/config/eccube/packages/eccube.yaml	(date 1531996537624)
@@ -47,7 +47,7 @@
     eccube_max_total_fee: 9999999999
     eccube_mltext_len: 1000
     eccube_mtext_len: 200
-    plugin_html_realdir: /PATH/TO/WEB_ROOT/src/Eccube/Repository/Master/plugin/
+    plugin_html_realdir: '%kernel.project_dir%/html/plugin'
     plugin_html_urlpath: /plugin/ # asset 使う
     plugin_realdir: '%kernel.project_dir%/app/Plugin'
     plugin_temp_realdir: /PATH/TO/WEB_ROOT/src/Eccube/Repository/Master/upload/temp_plugin/ # upload_tmp_dir に任せればよい?

@ndquocphong
Copy link
Author

ndquocphong commented Jul 23, 2018

Hi @ryo-endo, at my understand, we need consistent asset paths of plugin:

app/config/eccube/packages/eccube.yaml:

plugin_html_realdir: '%kernel.project_dir%/html/plugin'

app/config/eccube/packages/framework.yaml:

framework:
    assets:
        packages:
            plugin: '/html/template/plugin'

If two paths are different, then when copy asset from plugin to asset path, we can not get it in twig via:

{{ asset('/path/to/assets.js', 'plugin') }}

Thank you to review

@nhpkhanh-lk nhpkhanh-lk changed the title [3n]-[Core]-[1656]-Unable install plugin which have asset [3n]-[Core]-[1656]-アセットがあるプラグインをインストールできない Jul 23, 2018
@nhpkhanh-lk nhpkhanh-lk changed the title [3n]-[Core]-[1656]-アセットがあるプラグインをインストールできない [3n]-[Core]-[1656]-アセットのあるプラグインがインストールできない Jul 23, 2018
@ryo-endo
Copy link

ryo-endo commented Oct 4, 2018

lqdung [20 hours ago]
Examle: related product plugin:
You cannot use eccube_html_plugin_dir in eccube.yaml
https://github.com/eccubevn/related-product-plugin/blob/experimental/sf/PluginManager.php#L115

lqdung [20 hours ago]
because you need use asset('relatedproduct/assets/js/related_product_plugin.js', 'plugin')
https://github.com/eccubevn/related-product-plugin/blob/experimental/sf/Resource/template/asset/asset.twig#L2

@chihiro-adachi
Copy link

@ndquocphong

以下でどうでしょうか?

- {{ asset('/path/to/assets.js', 'plugin') }}
+ {{ asset('path/to/assets.js', 'plugin') }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants