Important
You are browsing the documentation for version 4.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.
See our Release Process documentation for more information on the currently supported and upcoming releases.
RouteModel¶
Abstraction of route
Basic usage:
1 var route = new RouteModel({
2 // route specification
3 routeName: 'oro_api_comment_get_items',
4 routeQueryParameterNames: ['page', 'limit'],
5
6 // required parameters for route path
7 relationId: 123,
8 relationClass: 'Some_Class',
9
10 // default query parameter
11 limit: 10
12 });
13
14 // returns api/rest/latest/relation/Some_Class/123/comment?limit=10
15 route.getUrl();
16
17 // returns api/rest/latest/relation/Some_Class/123/comment?limit=10&page=2
18 route.getUrl({page: 2})
Augment: BaseModel
routeModel._cachedRouteName : String¶
Route name cache prepared for
Kind: instance property of RouteModel
routeModel._requiredParametersCache : Array.<String>¶
Cached required parameters
Kind: instance property of RouteModel
routeModel.defaults : Object¶
Kind: instance property of RouteModel
routeModel.routeName : string¶
Name of the route
Kind: instance property of RouteModel
routeModel.routeQueryParameterNames : Array.<string>¶
List of acceptable query parameter names for this route
Kind: instance property of RouteModel
routeModel.getRequiredParameters() ⇒ Array.<string>¶
Return list of parameter names required by this route (Route parameters are required to build valid url, all query parameters assumed as filters and are not required)
E.g., for route api/rest/latest/<relationClass>/<relationId/comments This function will return [‘relationClass’, ‘relationId’]
Kind: instance method of RouteModel
routeModel.getAcceptableParameters() ⇒ Array.<string>¶
Return list of parameter names accepted by this route. Includes both query and route parameters
E.g., for route api/rest/latest/<relationClass>/<relationId/comments?page=<page>&limit=<limit> this function will return [‘relationClass’, ‘relationId’, ‘page’, ‘limit’]
Kind: instance method of RouteModel
routeModel.getUrl([parameters]) ⇒ string¶
Returns url defined by this model
Kind: instance method of RouteModel Returns: string - route url
Param |
Type |
Description |
---|---|---|
[parameters] |
Object |
parameters to override |
routeModel.validateParameters([parameters]) ⇒ boolean¶
Validates parameters list
Kind: instance method of RouteModel Returns: boolean - true, if parameters are valid
Param |
Type |
Description |
---|---|---|
[parameters] |
Object |
parameters to build url |