DruxtRouterStore
DruxtRouterStore
Vuex module, registered under the druxtRouter namespace.
The druxtRouter Vuex module.
Provides a Vuex state object, mutations and actions for interacting with the Drupal JSON:API.
- druxtRouter
- action
- get(path) ⇒
object - getRoute(path) ⇒
object getEntity(context, query) ⇒objectgetResources(app, payload) ⇒Array.<object>
- get(path) ⇒
- state :
object - mutation
- action
get(path) ⇒ object
Get route and redirect information.
- Dispatches
druxtRouter/getRouteaction. - Sets the active route.
- Sets the active redirect.
Vuex Action => Mutates state propertyroute
Kind: action method of druxtRouter
Returns: object - The route and redirect information.
| Param | Type | Description |
|---|---|---|
| path | string | The router path. |
Example
const { redirect, route } = await this.$store.dispatch('druxtRouter/get', '/')
getRoute(path) ⇒ object
Get Route.
- Executes query against Drupal Decoupled router.
- Caches result in the Vuex store.
- Returns cached result from Vuex store when available.
Vuex Action => Mutates state propertyroute
Kind: action method of druxtRouter
Returns: object - The route object.
| Param | Type | Description |
|---|---|---|
| path | string | The route path. |
Example
const route = await this.$store.dispatch('druxtRouter/getRoute', '/')
getEntity(context, query) ⇒ object
objectDeprecated in druxt-router:0.18.0, removed from druxt-router:2.0.0. Use the DruxtStore druxt/getResource action instead.
Get Entity.
- Executes query against Drupal JSON:API.
- Caches result in the Vuex store.
- Returns cached result from Vuex store when available.
Vuex Action => Mutates state propertyentities
Kind: action method of druxtRouter
Returns: object - The Drupal entity JSON:API resource data.
See
| Param | Type | Description |
|---|---|---|
| context | object | The Vuex action context. |
| context.commit | function | Commits mutations to the store. |
| context.state | object | The Vuex module state. |
| query | object | The JSON:API resource query. |
Example
const entity = await this.$store.dispatch('druxtRouter/getEntity', { type: 'node--article', id })
getResources(app, payload) ⇒ Array.<object>
Array.<object>Deprecated in druxt-router:0.18.0, removed from druxt-router:2.0.0. Use the DruxtStore druxt/getCollection action instead.
Get multiple resources.
Vuex Action
Kind: action method of druxtRouter
Returns: Array.<object> - Array of Drupal JSON:API resource data.
See
| Param | Type | Description |
|---|---|---|
| app | object | The Nuxt app context. |
| payload | getResourcesContext | The action parameters. |
Example
// Load currently published Articles.
const query = new DrupalJsonApiParams()
query.addFilter('status', '1')
const resources = await this.$store.dispatch('druxtRouter/getResources', {
resource: 'node--article',
query
})
state : object
Vuex State object.
Read only: true
Properties
| Name | Type | Description |
|---|---|---|
| entities | object | Drupal entity store. |
| redirect | boolean | object | Active redirect. |
| route | object | Active route. |
| routes | object | Route store. |
setRedirect
Sets the active redirect.
Kind: mutation method of druxtRouter
| Param | Type | Description |
|---|---|---|
| state | object | The Vuex state object. |
| redirect | object | The Redirect object. |
Example
this.$store.commit('druxtRouter/setRedirect', redirect)
addRoute
Adds the supplied route to the Vuex state object.
Kind: mutation method of druxtRouter
| Param | Type | Description |
|---|---|---|
| state | object | The Vuex state object. |
| payload | addRoutePayload | The mutation payload. |
Example
this.$store.commit('druxtRouter/addRoute', { path, route })
setRoute
Sets the active route by path.
Kind: mutation method of druxtRouter
| Param | Type | Description |
|---|---|---|
| state | object | The Vuex state object. |
| path | string | The route path |
Example
this.$store.commit('druxtRouter/setRoute', '/')
addEntity
Deprecated in druxt-router:0.18.0, removed from druxt-router:2.0.0. Use the DruxtStore druxt/addResource mutation instead.
Adds specified Drupal entity JSON:API resource data to the Vuex state object.
Kind: mutation method of druxtRouter
See
| Param | Type | Description |
|---|---|---|
| state | object | The Vuex state object. |
| entity | object | The Drupal entity JSON:API resource data. |
Example
this.$store.commit('druxtRouter/addEntity', entity)
addRoutePayload : object
Parameters for the addRoute mutation.
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| path | string | The route path. |
| route | object | The route object. |
Example
{
path: '/',
route: {}
}
getResourcesContext : object
Parameters for the getResources action.
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| resource | string | The JSON:API resource type. |
| query | string | object | A JSON:API query string or object. |
Example
{
resource: 'node--article',
query: new DrupalJsonApiParams().addFilter('status', '1')
}