diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9294c37684c4563c19ea08e4572e5bec37d5f717..5260aa296fe724a340543d40dc37750783bccf59 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,6 +33,14 @@ include: # View these include files at https://git.drupalcode.org/project/gitlab_templates/ ################ - project: $_GITLAB_TEMPLATES_REPO +<<<<<<< HEAD +======= + # "ref" value can be: + # - Recommended (default) - `ref: $_GITLAB_TEMPLATES_REF` - The Drupal Association will update this value to the recommended tag for contrib. + # - Latest - `ref: main` - Get the latest additions and bug fixes as they are merged into the templates. + # - Minor or Major latests - `ref: 1.x-latest` or `ref: 1.0.x-latest` - Get the latest additions within a minor (mostly bugfixes) or major (bugs and new features). + # - Fixed tag - `ref: 1.0.1` - Set the value to a known tag. This will not get any updates. +>>>>>>> 8.x-1.x ref: $_GITLAB_TEMPLATES_REF file: - '/includes/include.drupalci.main.yml' @@ -49,15 +57,12 @@ include: # Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml ################ variables: -# SKIP_ESLINT: '1' # Broaden test coverage. - OPT_IN_TEST_PREVIOUS_MAJOR: 1 OPT_IN_TEST_PREVIOUS_MINOR: 1 OPT_IN_TEST_NEXT_MINOR: 1 OPT_IN_TEST_NEXT_MAJOR: 1 OPT_IN_TEST_MAX_PHP: 1 - ################################################################################### # # * diff --git a/openapi_ui.info.yml b/openapi_ui.info.yml index b5c7cab025de845dfa62ce647cb456f9373e91da..66d5d6a4a25f9c4b37e42af4d269859059365ff9 100644 --- a/openapi_ui.info.yml +++ b/openapi_ui.info.yml @@ -1,5 +1,5 @@ name: OpenAPI UI type: module description: Provides plugin system for OpenAPI/Swagger Interface libraries. -core_version_requirement: ^9 || ^10 || ^11 +core_version_requirement: ^10 || ^11 package: OpenAPI diff --git a/src/Element/OpenApiUi.php b/src/Element/OpenApiUi.php index 6bc3b0477e907b97f087d23ae9bae42bbbefc188..e640a50a00e4ddaeb20f534cc4ce5e8e9a8a0491 100644 --- a/src/Element/OpenApiUi.php +++ b/src/Element/OpenApiUi.php @@ -2,12 +2,16 @@ namespace Drupal\openapi_ui\Element; +use Drupal\Component\Plugin\PluginBase; +use Drupal\Component\Utility\DeprecationHelper; +use Drupal\Core\Render\Element\ElementInterface; use Drupal\Core\Render\Element\RenderElement; +use Drupal\Core\Render\Element\RenderElementBase; use Drupal\Core\Url; use Drupal\openapi_ui\Plugin\openapi_ui\OpenApiUiInterface; /** - * Defines a render element for OpenApi Doc display library. + * Defines a render element for OpenApi Doc display libraries. * * This display element will act as a wrapper for the ui element. The rendering * process will use the library's plugin in order to allow for the plugin to @@ -28,7 +32,7 @@ use Drupal\openapi_ui\Plugin\openapi_ui\OpenApiUiInterface; * - A callback function: The docs can be implemented via a callback. The * callback will be passed the render element and as a result should take * exactly one parameter, an array, and return either an array with openapi - * compliant schema or an url for the schema. + * compliant schema or a url for the schema. * * Doc library plugins may only support specific formats for the openapi docs. * They may also support additional properties on this render element which can @@ -52,19 +56,15 @@ use Drupal\openapi_ui\Plugin\openapi_ui\OpenApiUiInterface; * * @RenderElement("openapi_ui") */ -class OpenApiUi extends RenderElement { +class OpenApiUi extends PluginBase implements ElementInterface { /** * {@inheritdoc} */ public function getInfo() { - $class = get_class($this); return [ '#pre_render' => [ - [ - $class, - 'preRenderOpenApiUi', - ], + [static::class, 'preRenderOpenApiUi'], ], ]; } @@ -118,4 +118,19 @@ class OpenApiUi extends RenderElement { return $element; } + /** + * {@inheritdoc} + */ + public static function setAttributes(&$element, $class = []) { + // This method can be removed when Drupal 10.3 is the minimum supported + // version of core, and this class extends RenderElementBase instead of + // implementing ElementInterface. + DeprecationHelper::backwardsCompatibleCall( + \Drupal::VERSION, + '10.3.0', + fn () => RenderElementBase::setAttributes($element, $class), + fn () => RenderElement::setAttributes($element, $class), + ); + } + }