DruxtSchema
DruxtSchema
The DruxtSchema class.
Builds Druxt Schema objects using Drupal JSON:API Entity Form and View Display mode data.
Kind: global class
- DruxtSchema
- new DruxtSchema(baseUrl, [options])
- .druxt :
DruxtClient - .get() ⇒
object - .getSchema(config, [options]) ⇒
Schema
new DruxtSchema(baseUrl, [options])
DruxtSchema constructor.
- Validates module options.
- Sets up options.
- Sets up a DruxtClient instance.
| Param | Type | Default | Description |
|---|---|---|---|
| baseUrl | string | The Drupal base URL. | |
| [options] | object | Druxt Router options. | |
| [options.axios] | object | Axios instance settings. | |
| [options.endpoint] | string | "jsonapi" | The JSON:API endpoint. |
Example
const schema = new DruxtSchema('https://example.com', {})
.druxt : DruxtClient
Instance of the Druxt Client.
Kind: instance property of DruxtSchema
See: DruxtClient
.get() ⇒ object
Gets all available schemas for Entity Views and Form modes.
Kind: instance method of DruxtSchema
Returns: object - The JSON:API Resource index and processed schemas.
Example
const { schemas } = await schema.get()
.getSchema(config, [options]) ⇒ Schema
Gets a matching schema as per the provided configuration.
Kind: instance method of DruxtSchema
Returns: Schema - The generated Schema.
See: Schema
| Param | Type | Description |
|---|---|---|
| config | SchemaConfiguration | The Schema configuration object. |
| config.entityType | string | The Drupal Entity type. |
| config.bundle | string | The Entity bundle. |
| [options] | object | (Optional) Additional Schema generation options, e.g. preloaded JSON:API resource data. |
Example
const config = {
entityType: 'node',
bundle: 'page'
}
const schema = await schema.getSchema(config)
SchemaConfiguration : object
Druxt Schema configuration object.
Kind: global typedef
See: SchemaConfiguration