Skip to content

Commit

Permalink
fix a collision issue between this plugin and pricebyweight
Browse files Browse the repository at this point in the history
  • Loading branch information
CupNoodles committed Mar 18, 2021
1 parent 7652e30 commit da835dd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,17 @@ public function boot()
// Push extension views into $partialPath since this isn't a formwidget
AdminController::extend(function ($controller) {
if( in_array('~/app/admin/views/orders', $controller->partialPath)){
array_unshift($controller->partialPath, '~/extensions/cupnoodles/ordermenuedit/views');
array_unshift($controller->viewPath, '~/extensions/cupnoodles/ordermenuedit/views/orders');
array_unshift($controller->partialPath, 'extensions/cupnoodles/ordermenuedit/views/');
array_unshift($controller->viewPath, 'extensions/cupnoodles/ordermenuedit/views/orders');
}
// if priceByWeight is installed, you may get a mild race condition on these partialPaths (pricebyweight also has a views/orders/form/order_menu.blade.php)
if (($key = array_search('~/extensions/cupnoodles/pricebyweight/views', $controller->partialPath)) !== false) {
unset($controller->partialPath[$key]);
}
if (($key = array_search('~/extensions/cupnoodles/pricebyweight/views/orders', $controller->viewPath)) !== false) {
unset($controller->viewPath[$key]);
}

});

// Enable save buttons on Order View
Expand All @@ -71,7 +79,7 @@ public function boot()
});


// Change the edit link on Orders List View to cupnoodles/ordermenuedit/edit{id} so that the form submits to the extended controller
// Change the edit link on Orders List View to cupnoodles/ordermenuedit/edit/{id} so that the form submits to the extended controller
Orders::extend(function ($controller){
if($controller->listConfig['list']['model'] == 'Admin\Models\Orders_model'){
$controller->listConfig['list']['configFile'] = 'extensions/cupnoodles/ordermenuedit/models/config/orders_model';
Expand Down

0 comments on commit da835dd

Please sign in to comment.