Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Separating the settings (especially environment-specific settings) out into a content item aids in creating more maintainable code and makes migrations easier.

Table of Contents

Dependencies

The Settings module is dependent on the following modules:

Anchor
the-settings-schema
the-settings-schema
The Settings Schema

The Settings schema is a global content schema with one field, “settings”, a JSON field that will accept any valid JSON.

...

Settings Retrieval

The Settings module will look for content created using the Settings Schema in the current project.

...

If more than one such item is found, the first one found will be used, and a warning will be logged indicating that there are more than one settings content items, and detailing which one is being used to populate the settings.

Settings Access

Once retrieved, the settings will be available under the property “settings” on the project context:

...

Info

This example assumes a reference to the project context has been set in the flow context (See Getting the Project Context).

Methods

refresh

This method retrieves the settings content again and updates the settings in the project context.

...

Returns: A promise that resolves when the settings have been refreshed in the project context.

update

This method allows updates to the settings content from code.

...

Returns: A promise that resolves when the setting has been updated and the settings in the project context have been refreshed.

Settings Content Updates

Updating the settings content directly will result in an automatic refresh of the settings in the project context.

Info

This happens via the post data hooks feature of Orbita schemas, through a handler registered with the Data Hooks module.

Anchor
settings-template
settings-template
Settings Template

The Settings module establishes an endpoint that can be used to retrieve an example settings JSON object based on the installed modules:

...