isLoaded) { throw new \RuntimeException('Do not add the "extra" loader twice'); } $routes = new RouteCollection(); $lcShopRoutes = array( 'address' => "Address", "cart" => "Cart", "credit_config" => "CreditConfig", "document_nelivery_note" => "DocumentDeliveryNote", "document_quotation" => "DocumentQuotation", "document_invoice" => "DocumentInvoice", "merchant" => "Merchant", "merchant_config" => "MerchantConfig", /*"order"=>"Order"*/ "point_sale" => "PointSale", "tax_rate" => "TaxRate", "product" => "Products" ); $actions = [ 'index' => 'indexAction', 'edit' => 'editAction', 'delete' => 'deleteAction', 'show' => 'showAction' ]; foreach ($lcShopRoutes as $entity => $controller) { foreach ($actions as $actionName => $action) { if ($actionName == 'edit' || $actionName == 'delete' || $actionName == "show") { $path = '/' . $entity . '/' . $actionName . '/{id}'; } else { $path = '/' . $entity . '/' . $actionName; } $defaults = [ '_controller' => 'Lc\ShopBundle\Controller\\' . $controller . 'Controller::' . $action ]; $requirements = [ 'parameter' => '\d+', ]; $route = new Route($path, $defaults, $requirements); $routeName = 'lc_shop_' . $entity . '_' . $actionName; $routes->add($routeName, $route); } } $this->isLoaded = true; return $routes; } public function supports($resource, $type = null) { return 'crud' === $type; } }