jd440 Posted August 11, 2012 Share Posted August 11, 2012 Dans le cas d'un multi-shop, est il possible et prévu de pouvoir overrider seulement pour certaine boutique? Link to comment Share on other sites More sharing options...
coeos.pro Posted August 11, 2012 Share Posted August 11, 2012 pas à ma connaissance, mais il suffit de rajouter dans l'override une condition pour appliquer le contenu d'une fonction en fonction de l'id_shop Link to comment Share on other sites More sharing options...
jd440 Posted August 11, 2012 Author Share Posted August 11, 2012 Merci c'est ce que je pensais. ou overrider l'autoload avec condition? Link to comment Share on other sites More sharing options...
coeos.pro Posted August 11, 2012 Share Posted August 11, 2012 oui c'est possible mais à mon avis le plus simple, rapide et efficace est de mettre if($id_shop == 2){... Link to comment Share on other sites More sharing options...
jd440 Posted August 12, 2012 Author Share Posted August 12, 2012 comme ceci? if ((int)Context::getContext()->shop->id == 2) { class IndexController extends IndexControllerCore { [...] } } else { class IndexController extends IndexControllerCore { [...] } } Link to comment Share on other sites More sharing options...
coeos.pro Posted August 12, 2012 Share Posted August 12, 2012 (edited) non si tu créés 2 class de même nom il y a tout à parier que ça va bugger, essaye plutôt : class IndexController extends IndexControllerCore { public function LaFonctionQueJOverride() { if ((int)Context::getContext()->shop->id == 2) { ... } else { ... } } } sinon Shop::getContextShopID() renvoi aussi l'id du shop (si tu es dans Shop::CONTEXT_SHOP) Edited August 12, 2012 by coeos.pro (see edit history) Link to comment Share on other sites More sharing options...
jd440 Posted August 12, 2012 Author Share Posted August 12, 2012 le truc c'est que j'ai plein de fonction en override ce qui devrais dire qu'il faut mettre un if dans chaque fonction class IndexController extends IndexControllerCore { public function Init() { if ((int)Context::getContext()->shop->id == 2) { ... } } public function InitContent() { if ((int)Context::getContext()->shop->id == 2) { ... } } public assignScenes() { if ((int)Context::getContext()->shop->id == 2) { ... } } } et que malheureusment ca fonctionne pas si me met le if avant lest fonctions: class IndexController extends IndexControllerCore { if ((int)Context::getContext()->shop->id == 2) { public function Init() { ... } public function InitContent() { ... } public assignScenes() { ... } } } Link to comment Share on other sites More sharing options...
coeos.pro Posted August 12, 2012 Share Posted August 12, 2012 non il faut que le if soit dans la fonction, comme tu l'a mis dans ton premier exemple (de ton dernier message) Link to comment Share on other sites More sharing options...
jd440 Posted August 13, 2012 Author Share Posted August 13, 2012 Merci c'est effectivement ce que j'ai tester mais Du coup j'ai autant de fonction que d'ovverride chaque fonction commence par un condition. Et si la condition est pas remplit, le systeme va lire, charger le fichier override + toute les fonction pour rien? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now