Drupal Answers Asked by Daniel Harper on November 8, 2021
I have a module with two pieces of config set using an admin form and Drupal the drupal config service.
Like this
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this->config('mars_spot_collection.defaultcollections')
->set('default_collection_title', $form_state->getValue('default_collection_title'))
->set('default_collection_description', $form_state->getValue('default_collection_description'))
->save();
}
How do I make this conig available in the JSONAPI?
Cheers
You can't do it. Not with the core JSON:API module. Out of the box, the resources JSON:API exposes are all the entity definitions from EntityTypeManager
which includes content & config entities (defined by extending ConfigEntityBase
).
However, arbitrarily set config values will not be exposed. JSON:API also doesn't support custom resources, as JSON:API docs state:
The JSON:API module provides no PHP API to modify its behavior. It is designed to have zero configuration.
• Adding new resources/resource types is unsupported: all entities/entity types are exposed automatically. If you want to expose more data via the JSON:API module, the data must be defined as entity. See the "Resources" section.
The JSON:API Resources project attempts to fill this in if you want to design your own endpoint with custom responses.
Answered by Shawn Conn on November 8, 2021
2 Asked on December 26, 2021 by sugandh-khanna
1 Asked on December 24, 2021 by tigertrussell
1 Asked on December 24, 2021 by wale
1 Asked on December 24, 2021
1 Asked on December 21, 2021 by oskar-calvo
1 Asked on December 21, 2021 by user3027413
1 Asked on December 21, 2021
2 Asked on December 19, 2021 by user48552
2 Asked on December 19, 2021 by tinohuda
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP