|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * BINSHOPS | Best In Shops |
| 4 | + * |
| 5 | + * @author BINSHOPS | Best In Shops |
| 6 | + * @copyright BINSHOPS | Best In Shops |
| 7 | + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) |
| 8 | + * Best In Shops eCommerce Solutions Inc. |
| 9 | + * |
| 10 | + */ |
| 11 | + |
| 12 | +require_once dirname(__FILE__) . '/../AbstractRESTController.php'; |
| 13 | +require_once dirname(__FILE__) . '/../../classes/RESTMainMenu.php'; |
| 14 | +require_once dirname(__FILE__) . '/../../classes/RESTProductLazyArray.php'; |
| 15 | + |
| 16 | +use PrestaShop\PrestaShop\Adapter\Category\CategoryProductSearchProvider; |
| 17 | +use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; |
| 18 | +use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; |
| 19 | +use PrestaShop\PrestaShop\Core\Product\Search\SortOrder; |
| 20 | + |
| 21 | +/** |
| 22 | + * Description: This class bootstraps the main page of the application |
| 23 | + * */ |
| 24 | + |
| 25 | +class BinshopsrestLightbootstrapModuleFrontController extends AbstractRESTController |
| 26 | +{ |
| 27 | + protected $banner; |
| 28 | + |
| 29 | + protected function processGetRequest() |
| 30 | + { |
| 31 | + $messageCode = 200; |
| 32 | + $mainMenu = Module::getInstanceByName('ps_mainmenu'); |
| 33 | + |
| 34 | + $restMenu = new RESTMainMenu(); |
| 35 | + |
| 36 | + $menuItems = $restMenu->renderMenu($this->context, $mainMenu); |
| 37 | + |
| 38 | + if (Tools::getValue('menu_with_images', false)){ |
| 39 | + foreach ($menuItems as $key => $item) { |
| 40 | + $retriever = new \PrestaShop\PrestaShop\Adapter\Image\ImageRetriever( |
| 41 | + $this->context->link |
| 42 | + ); |
| 43 | + $category = new Category( |
| 44 | + Tools::substr($item['page_identifier'], -1), |
| 45 | + $this->context->language->id |
| 46 | + ); |
| 47 | + if (Tools::getValue('menu_with_images', 'all') === "single"){ |
| 48 | + $menuItems[$key]['image']['src'] =$this->context->link->getImageLink( |
| 49 | + urlencode($item['slug']), |
| 50 | + ($category->id . '-' . $category->id_image), |
| 51 | + $this->getImageType('large') |
| 52 | + ); |
| 53 | + }else{ |
| 54 | + $menuItems[$key]['images'] = $retriever->getImage( |
| 55 | + $category, |
| 56 | + $category->id_image |
| 57 | + ); |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + $psdata = array(); |
| 63 | + $psdata['menuItems'] = $menuItems; |
| 64 | + |
| 65 | + $this->ajaxRender(json_encode([ |
| 66 | + 'success' => true, |
| 67 | + 'code' => $messageCode, |
| 68 | + 'psdata' => $psdata |
| 69 | + ])); |
| 70 | + die; |
| 71 | + } |
| 72 | + |
| 73 | + protected function processPostRequest() |
| 74 | + { |
| 75 | + $this->ajaxRender(json_encode([ |
| 76 | + 'success' => true, |
| 77 | + 'message' => 'POST not supported on this path' |
| 78 | + ])); |
| 79 | + die; |
| 80 | + } |
| 81 | + |
| 82 | + protected function processPutRequest() |
| 83 | + { |
| 84 | + $this->ajaxRender(json_encode([ |
| 85 | + 'success' => true, |
| 86 | + 'message' => 'put not supported on this path' |
| 87 | + ])); |
| 88 | + die; |
| 89 | + } |
| 90 | + |
| 91 | + protected function processDeleteRequest() |
| 92 | + { |
| 93 | + $this->ajaxRender(json_encode([ |
| 94 | + 'success' => true, |
| 95 | + 'message' => 'delete not supported on this path' |
| 96 | + ])); |
| 97 | + die; |
| 98 | + } |
| 99 | +} |
0 commit comments