protected static function JsonApiDefaultsFunctionalTest::overrideResources in JSON:API Extras 8.3
Creates the JSON API Resource Config entities to override the resources.
Overrides JsonApiExtrasFunctionalTestBase::overrideResources
File
- modules/
jsonapi_defaults/ tests/ src/ Functional/ JsonApiDefaultsFunctionalTest.php, line 230
Class
- JsonApiDefaultsFunctionalTest
- The test class for the JSON API Defaults functionality.
Namespace
Drupal\Tests\jsonapi_defaults\FunctionalCode
protected static function overrideResources() {
// Override paths and fields in the articles resource.
JsonapiResourceConfig::create([
'id' => 'node--article',
'third_party_settings' => [
'jsonapi_defaults' => [
'default_filter' => [
'filter:nidFilter#condition#path' => 'internalId',
'filter:nidFilter#condition#value' => 3,
],
'default_sorting' => [
'sort:title#path' => 'title',
'sort:title#direction' => 'DESC',
],
// @todo Change this to 'tags.vid'.
'default_include' => [
'tags',
],
],
],
'disabled' => FALSE,
'path' => 'articles',
'resourceType' => 'articles',
'resourceFields' => [
'nid' => [
'fieldName' => 'nid',
'publicName' => 'internalId',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
'uuid' => [
'fieldName' => 'uuid',
'publicName' => 'uuid',
'enhancer' => [
'id' => '',
],
'disabled' => TRUE,
],
'vid' => [
'fieldName' => 'vid',
'publicName' => 'vid',
'enhancer' => [
'id' => '',
],
'disabled' => TRUE,
],
'langcode' => [
'fieldName' => 'langcode',
'publicName' => 'langcode',
'enhancer' => [
'id' => '',
],
'disabled' => TRUE,
],
'type' => [
'fieldName' => 'type',
'publicName' => 'contentType',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
'status' => [
'fieldName' => 'status',
'publicName' => 'isPublished',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
'title' => [
'fieldName' => 'title',
'publicName' => 'title',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
'uid' => [
'fieldName' => 'uid',
'publicName' => 'owner',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
'created' => [
'fieldName' => 'created',
'publicName' => 'createdAt',
'enhancer' => [
'id' => 'date_time',
'settings' => [
'dateTimeFormat' => 'Y-m-d\\TH:i:sO',
],
],
'disabled' => FALSE,
],
'changed' => [
'fieldName' => 'changed',
'publicName' => 'updatedAt',
'enhancer' => [
'id' => 'date_time',
'settings' => [
'dateTimeFormat' => 'Y-m-d\\TH:i:sO',
],
],
'disabled' => FALSE,
],
'promote' => [
'fieldName' => 'promote',
'publicName' => 'isPromoted',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
'sticky' => [
'fieldName' => 'sticky',
'publicName' => 'sticky',
'enhancer' => [
'id' => '',
],
'disabled' => TRUE,
],
'revision_timestamp' => [
'fieldName' => 'revision_timestamp',
'publicName' => 'revision_timestamp',
'enhancer' => [
'id' => '',
],
'disabled' => TRUE,
],
'revision_uid' => [
'fieldName' => 'revision_uid',
'publicName' => 'revision_uid',
'enhancer' => [
'id' => '',
],
'disabled' => TRUE,
],
'revision_log' => [
'fieldName' => 'revision_log',
'publicName' => 'revision_log',
'enhancer' => [
'id' => '',
],
'disabled' => TRUE,
],
'revision_translation_affected' => [
'fieldName' => 'revision_translation_affected',
'publicName' => 'revision_translation_affected',
'enhancer' => [
'id' => '',
],
'disabled' => TRUE,
],
'default_langcode' => [
'fieldName' => 'default_langcode',
'publicName' => 'default_langcode',
'enhancer' => [
'id' => '',
],
'disabled' => TRUE,
],
'path' => [
'fieldName' => 'path',
'publicName' => 'path',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
'body' => [
'fieldName' => 'body',
'publicName' => 'body',
'enhancer' => [
'id' => 'nested',
'settings' => [
'path' => 'value',
],
],
'disabled' => FALSE,
],
'field_link' => [
'fieldName' => 'field_link',
'publicName' => 'link',
'enhancer' => [
'id' => 'uuid_link',
],
'disabled' => FALSE,
],
'field_timestamp' => [
'fieldName' => 'field_timestamp',
'publicName' => 'timestamp',
'enhancer' => [
'id' => 'date_time',
'settings' => [
'dateTimeFormat' => 'Y-m-d\\TH:i:sO',
],
],
'disabled' => FALSE,
],
'comment' => [
'fieldName' => 'comment',
'publicName' => 'comment',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
'field_image' => [
'fieldName' => 'field_image',
'publicName' => 'image',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
'field_recipes' => [
'fieldName' => 'field_recipes',
'publicName' => 'recipes',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
'field_tags' => [
'fieldName' => 'field_tags',
'publicName' => 'tags',
'enhancer' => [
'id' => '',
],
'disabled' => FALSE,
],
],
])
->save();
}