Atwix / phpstorm-plugin-feedback

6 stars 0 forks source link

Compare Template With Original #2

Closed sprankhub closed 1 year ago

sprankhub commented 1 year ago

The "Compare *.phtml templates overridden in the Magento 2 module" is awesome. However, currently, it only covers one very specific case, right? According to the user guide, it only shows when the template is overridden via layout XML specifically. However, this feature would be much more helpful if it showed the difference of templates if they are overridden by the theme. If my theme e.g. overrides Magent_Catalog::catalog/product/list.phtml, I would love to have one or two actions:

bohdan-harniuk commented 1 year ago

Hello, @sprankhub ! Comparison from overridden template in the custom theme with the original template is already covered. By the way, it is a great idea to allow user choosing comparison with the original template or with the parent theme. Thank you!

sprankhub commented 1 year ago

Hmm it is supposed to be shown on a right-click inside the overridden template, right? It is not showing for me. Any idea what might be strange? One thing I could think of is that our theme is not inside app/design, but inside a local Composer path repository.

bohdan-harniuk commented 1 year ago

Yes, that is it!

Could you please share any sample how it is specified via local composer path repository? I will add support for such cases.

Regards,

sprankhub commented 1 year ago

Oh, good guess then :)

Okay first, you need to configure a Composer local path repository in your root composer.json:

"repositories": {
    "local-modules": {
        "type": "path",
        "url": "./local-modules/*/*"
    }
}

Then, instead of having your theme under app/design/Vendor/Theme, you would have the theme under local-modules/Vendor/Theme.

To use it, you would require it e.g. via composer require vendor/theme dev-main --update-with-dependencies.

What Composer does then is to symlink the module into the vendor directory:

    > ll vendor/vendor/
lrwxrwxrwx 1 simon www-data 24 Nov 18 13:08 theme -> ../../local-modules/Vendor/Theme//

If you need any more information, let me know.

It might be unrelated, but for us, it is essential that all potential code generation features work with such local Composer path repositories.

bohdan-harniuk commented 1 year ago

Is it used only for themes?

sprankhub commented 1 year ago

No, the mechanism is 100% the same for modules :)

bohdan-harniuk commented 1 year ago

But why do you use this mechanism? Why don't just use app/code and app/design directories?

As for solution, what do you think, if you will be able to choose custom source and design directories?

sprankhub commented 1 year ago

Because I like to define my dependencies properly and let Composer take care of the dependency resolution :)

Choosing custom directories would work, but is not that nice to set up. Plus, it would blow up the settings for nothing. Wouldn't it be possible for you to screen the root composer.json for path repositories and take all given url properties into account? For legacy projects, it might also be that some modules are under app/code and others are under local-modules. So both should work IMHO.

bohdan-harniuk commented 1 year ago

I will try to do so. Firstly, I need to get it working for the real project to understand how it works and if for all users it will be configured in the constant/same way. If it is not, it is better to allow user choose specific modules and themes directory as it is rare setup (not default).

So, it will not require any additional configurations for the default setup.

sprankhub commented 1 year ago

Thanks. If you need any help setting it up or any more information, feel free to ping me :)

bohdan-harniuk commented 1 year ago

Okay, thank you!

bohdan-harniuk commented 1 year ago

Hello, @sprankhub!

We've developed next mentioned here features:

  1. compare overridden in the theme template with the parent theme override
  2. composer local paths support + auto-detection

It is now submitted for the internal testing. It will be available in the upcoming release.

Regards,