I am trying to override the translations in the default FOSUserBundle.en.yml. I have my User bundle as a child of the FOSUserBundle using the getParent method and I copied the FOSUserBundle.en.yml into the translations folder of the child bundle and nothing is being overridden. Can someone help me find out why this is?
I know I have to be missing something because I was able to override the layout.html.twig file easily doing the same thing.
I tried using php app/console cache:clear and that did not help.
It turned out that the translation file was overriding but the FOSUserBundle was after the child bundle in the AppKernel file. Because of how translations work the translation file from the FOSUserBundle was being loaded after the childs translation file, in turn overriding the child.
All I had to do was move the child bundle in the AppKernel file after the parent. This way it was the last translation file to be loaded.
Here is the documentation page I found this at:
http://symfony.com/doc/current/cookbook/bundles/override.html#override-translations
I've run into this before as well. Try manually deleting your cache/dev directory. I'm guessing your talking about the dev environment as cache:clear without parameters defaults to dev.
Related
Actually I'm a newbie to prestashop,
and I have changes in the following file in these locations
classes/Product.php
src/PrestaShopBundle/Controller/Admin/ProductController.php
src/PrestaShopBundle/Resources/views/Admin/Product/form.html.twig
I have created a module named as My Kit while this module is configured all these changes should work..If the module is set to be disabled these changes should not affect in front end(I mean in admin panel)
For this I've created an override folder in my_kit module and place all those above mentioned files into this my_kit\override path..
like
my_kit\override\classes/Product.php
my_kit\override\src/PrestaShopBundle/Controller/Admin/ProductController.php
my_kit\override\src/PrestaShopBundle/Resources/views/Admin/Product/form.html.twig
But it won't work for me :(
how should I do this one..
Someone help me out of this..
You can use php default copy function in your main file install function like below.
public function install()
{
copy(_PS_ROOT_DIR_."/modules/your module name/classes/Product.php",_PS_ROOT_DIR_."/override/classes/Product.php");
unlink(_PS_ROOT_DIR_."/cache/class_index.php");//because you need to delete this file after override
//Do same like this all other file.
}
Thanks,
I'm not really sure how you will work around the part with the custom module (maybe when the module is not configured, you will leave the override classes only defined, and when its configured, you will put the changes there)... still changes in the core files should be done like this - for the Product class:
Make a new file in (basefolder)/override/classes/Product.php
Define the class ass:
class Product extends ProductCore
Do your changes. (override functions, or adding new ones)
You can't override classes from src folder
PrestaShop 1.7 introduces the use of namespaces with its new
architecture, and in short, anything that has namespaces cannot be
overridden. The legacy architecture can still be overridden, though.
But in general, we advise against overriding code. It is better to
extend it. Also, overrides are currently forbidden in the
Symfony-based pages (namely, the Product page and the Modules page).
http://build.prestashop.com/news/prestashop-1-7-faq/#is-there-any-change-planned-to-the-override-system
If you want to override PrestaShop's classes and controllers, you can do it as in previous versions
http://doc.prestashop.com/display/PS16/Overriding+default+behaviors
i want to override the Friendsofsymfony Userbundle Templates. I found already the documentation:
http://symfony.com/doc/master/bundles/FOSUserBundle/overriding_templates.html
But i guess its not working in symfony3. The structur of the bundle is diffrent.
I think in the original its bundle/FOS/UserBundle/Ressources/views.
By me its vendor/friendsofsymfony/user-bundle/Resources/views.
I already try to copy this structur to the app folder. But it still not working.
thx for reading and maybe helping
See the Symfony documentation about overriding bundle templates:
When the AcmeBlogBundle:Blog:index.html.twig is rendered, Symfony actually looks in two different locations for the template:
app/Resources/AcmeBlogBundle/views/Blog/index.html.twig
src/Acme/BlogBundle/Resources/views/Blog/index.html.twig
To override the bundle template, just copy the index.html.twig template from the bundle to app/Resources/AcmeBlogBundle/views/Blog/index.html.twig (the app/Resources/AcmeBlogBundle directory won't exist, so you'll need to create it). You're now free to customize the template.
I just want to know can we change the Default directory structure i.e Bundle inside a Bundle like that and default Bundle directory Acme to something else.
Acme is just a dummy vendor name. Replace it with your own when creating your own bundles.
can we change the Default directory structure i.e Bundle inside a Bundle
What do you mean with 'bundle inside a bundle'? You want to create a AcmeDemoBundleFooBundle? No, that isn't possible.
As said in the comments. If you want to rename a bundle vendor, you need to do this manually. There is no script/command for that. (sidenote: The PHP grammar is much to flexible to write a good refactoring tool, that's why it don't exists or don't work)
You don't only have to rename the vendor name, you need to make sure all configuration is correct and uses the new vendor instead of Acme. This doc article is talking about removing bundles, but it can also be used as a checklist for savelly removing the bundle on a safe way.
Esy, delete your folder "Acme" with its content. Then though terminal call
php app/console generate:Bundle --namespace="Main\DefaultBundle
And you will get "Main" instead of "Acme"
Also you need clear appKenrel and other config files from your old configurations.
I am creating a custom plugin, and am trying to keep all related model files contained within the plugin directory structure. However, when I build the model, some files get dropped into lib/model/doctrine/... and others in plugins/userPlugin/lib/model/... . According to Doctrine docs I can add a "package" option to the schema.yml file, and generated model files will be created in the location as defined by my dot-notation entry, for example:
# plugins/userPlugin/config/doctrine/schema.yml
connection: store-rw-user
options:
# Fully expect resulting model files to be dropped in this directory (vs the main model dir)
package: userPlugin.lib.model.doctrine
....
As mentioned, this config setup still results in model files being dropped into the main lib/model/doctrine directory. I even tried this, to no avail:
# plugins/userPlugin/config/doctrine/schema.yml
connection: store-rw-user
options:
package: userPlugin
package_custom_path: /tmp/userPlugin
....
Just wanted to see if the files were dropped in the /tmp directory, but they were not.
Before I start tearing apart the source code, I figured I would ask first, to see if there is something I am missing.
It's perfectly normal to get model files in your project directory after building. The purpose of this is to let you customize the plugin model on per-project basis, because the classes inside these files inherit from the classes defined in the plugin's files. I use plugins too, and most of the time, all the code I write resides in the plugin's model files.
I am trying to auto-load classes from the "lib" directory inside of one specific module directory.
I have tried everything but to no avail...
One of the classes I would like to load is a class called visUser which inherits from myUser I have already made a factory.yml file in myapplication/modules/mymodule/conf but it doesn't load...
I am doing something wrong? or module level configuration files are not suported?
I am using symfony 1.2 with propel.
Factories are an application specific file and cannot be overloaded on the module level. It's a weird idea anyway.
Read the config handlers file to see what files are supported on the modules level configuration (symfony/lib/config/config/config_handlers.yml).