Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace Lc\ShopBundle\Routing;
  3. use Lc\ShopBundle\Model\Address;
  4. use Symfony\Component\Config\Loader\Loader;
  5. use Symfony\Component\Routing\Route;
  6. use Symfony\Component\Routing\RouteCollection;
  7. class CrudLoader extends Loader
  8. {
  9. private $isLoaded = false;
  10. public function load($resource, $type = null)
  11. {
  12. if (true === $this->isLoaded) {
  13. throw new \RuntimeException('Do not add the "extra" loader twice');
  14. }
  15. $routes = new RouteCollection();
  16. $lcShopRoutes = array(
  17. 'address' => "Address",
  18. "cart" => "Cart",
  19. "credit_config" => "CreditConfig",
  20. "document_nelivery_note" => "DocumentDeliveryNote",
  21. "document_quotation" => "DocumentQuotation",
  22. "document_invoice" => "DocumentInvoice",
  23. "merchant" => "Merchant",
  24. "merchant_config" => "MerchantConfig",
  25. /*"order"=>"Order"*/
  26. "point_sale" => "PointSale",
  27. "tax_rate" => "TaxRate",
  28. "product" => "Products"
  29. );
  30. $actions = [
  31. 'index' => 'indexAction',
  32. 'edit' => 'editAction',
  33. 'delete' => 'deleteAction',
  34. 'show' => 'showAction'
  35. ];
  36. foreach ($lcShopRoutes as $entity => $controller) {
  37. foreach ($actions as $actionName => $action) {
  38. if ($actionName == 'edit' || $actionName == 'delete' || $actionName == "show") {
  39. $path = '/' . $entity . '/' . $actionName . '/{id}';
  40. } else {
  41. $path = '/' . $entity . '/' . $actionName;
  42. }
  43. $defaults = [
  44. '_controller' => 'Lc\ShopBundle\Controller\\' . $controller . 'Controller::' . $action
  45. ];
  46. $requirements = [
  47. 'parameter' => '\d+',
  48. ];
  49. $route = new Route($path, $defaults, $requirements);
  50. $routeName = 'lc_shop_' . $entity . '_' . $actionName;
  51. $routes->add($routeName, $route);
  52. }
  53. }
  54. $this->isLoaded = true;
  55. return $routes;
  56. }
  57. public function supports($resource, $type = null)
  58. {
  59. return 'crud' === $type;
  60. }
  61. }