Hello.
Anyone who programs in symfony 2 has come across a situation where you need to override some kind of third-party bundle file. Whether it's a Twig template, a controller or a translation file.
If the bundle that you customize has at least some complicated file nesting system, then redefining them becomes not a very interesting task.
For example?An e-commerce Sylius project can be illustrative, in which to override, say, the product display template /vendor/sylius/sylius/src/Sylius/Bundle/WebBundle/Resources/views/Frontend/Product/show.html.twig will have to create the whole the app / Resources / SyliusWebBundle / views / Frontend / Product folder hierarchy manually to finally put the show.html.twig file there.
Actually, in order to automate this operation, a plugin for Sublime Text 3 was born, which I want to share with Symfony2 developers.
Opportunities
The plugin can copy the current active file from the bundle in the vendors folder to the selected bundle from the
src folder after pressing
Ctrl + Shift + O.')
Currently, it is possible to copy templates, translations, php files, any files from the Resources / public folder. Templates and translations can be copied to either the bundle or the corresponding location in the
app directory.
Restrictions
- at the moment the plugin can work only with files from libraries designed according to the PSR-0 standard and located in the
vendor folder;
- tested only in Sublime Text 3 under Ubuntu;
- the
plugin is not yet adopted in PackageControl.io, so you have to put it by hand ( there is an instruction) already adopted, you can
install it directly from Sublime Text 3.
Plans
- Support for bundles designed according to the PSR-4 standard;
- Recursive folder override;
-
Automatic substitution of the correct namespace in the copied file has already been implemented;
- And
another .
For what I made the publication on Habré?
There is a painful (not only for me, right?) Problem, and I want to share it with a solution that might already be useful to someone.
Thanks for attention.
I will be glad to any response - feedback, advice, pool request.
Links-
Plugin on Package Control ;
- Plugin code on
github.com ;
-
TODO.md.UPD:
Since the publication of this article in the sandbox, the plugin has been adopted in
packagecontrol.io , has learned to prescribe the new namespace in an inherited php file and inherit from the old class.