Skip to content

Commit 5e0dc35

Browse files
#80 Upgrade path from API doc custom entities to nodes (#85)
* [#71] Create apidoc node bundle on install/update. * [#71] Apidoc conversion. * [#71] Apidoc conversion. * [#71] Apidoc conversion. * [#71] Apidoc - node path aliases. * [#71] Apidoc - tests. * [#71] Apidoc - README. * [#71] Apidoc - links/tasks/actions. * [#71] Apidoc - ApiDocsAdminTest. * [#71] Apidoc - ApiDocsJsonApi. * [#71] Apidoc - removing ApiDocsAccessTest as it is covered by core. * [#80] Allow updating from 1.x branch, and import config to create node type and fields, etc. * [#80] Moving logic to an update service. * [#80] Update step 8802 successful. * [#80] Update steps complete correctly. * [#80] Code sniffer fixes. * [#80] Fieldname and values fix. * [#80] Remove some merged code. * [#80] Fixes from the scenario where 1.x was never installed.
1 parent fe74528 commit 5e0dc35

6 files changed

+820
-18
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ https://www.drupal.org/node/3058344
4747

4848
### Known issues
4949

50-
- [Backwards compatibility with the version 1.x of this module is a separate issue](https://github.com/apigee/apigee-api-catalog-drupal/issues/80), you can subscribe to notifications to follow the status.
51-
5250
- The Apigee SmartDocs formatter can only render one OpenAPI spec per page and the URL pattern
5351
must match `/api/{entityId}`. This means that the formatter will probably not work correctly if
5452
you modify the default API Docs view or try to use this file Formatter on other node types or entities.

apigee_api_catalog.install

+28-16
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,6 @@ function apigee_api_catalog_requirements($phase) {
3838
];
3939
}
4040

41-
// Prevent updating the module from 1.x, as there is no update path yet.
42-
// @see https://github.com/apigee/apigee-api-catalog-drupal/issues/80
43-
$schemaVersion = \Drupal::keyValue('system.schema')->get('apigee_api_catalog');
44-
if (in_array($phase, ['update', 'runtime']) && $schemaVersion < 8801) {
45-
return [
46-
'apigee_api_catalog_update_unsupported' => [
47-
'title' => t('Apigee API Catalog'),
48-
'description' =>t('The <a href=":link_module">Apigee API Catalog</a> 1.x version is enabled on this site but the module has been replaced with a 2.x version on the filesystem. Currently there is no way to upgrade from 1.x to 2.x. You will need to revert to the latest 1.x version of the module or uninstall the Apigee API Catalog module which will remove the module\'s current content and configuration then install the 2.x version. If you want to upgrade you will need to follow <a href=":link_issue">issue #80</a> for updates on the upgrade path functionality.', [
49-
':link_module' => 'https://github.com/apigee/apigee-api-catalog-drupal/issues/80',
50-
':link_issue' => 'https://github.com/apigee/apigee-api-catalog-drupal/issues/80',
51-
]),
52-
'severity' => REQUIREMENT_ERROR,
53-
],
54-
];
55-
}
56-
5741
return [];
5842
}
5943

@@ -108,3 +92,31 @@ function apigee_api_catalog_update_8701() {
10892
function apigee_api_catalog_update_8801() {
10993
// Empty - only needed to set the 2.x module schema number.
11094
}
95+
96+
/**
97+
* Create API Doc node type and fields if updating from 1.x.
98+
*/
99+
function apigee_api_catalog_update_8802() {
100+
return \Drupal::service('apigee_api_catalog.updates')->update8802();
101+
}
102+
103+
/**
104+
* Recreate other fields added to the API Doc entity onto the API Doc node type if updating from 1.x.
105+
*/
106+
function apigee_api_catalog_update_8803() {
107+
return \Drupal::service('apigee_api_catalog.updates')->update8803();
108+
}
109+
110+
/**
111+
* Convert API Doc entities to nodes (migrating data) if updating from 1.x.
112+
*/
113+
function apigee_api_catalog_update_8804(&$sandbox) {
114+
return \Drupal::service('apigee_api_catalog.updates')->update8804($sandbox);
115+
}
116+
117+
/**
118+
* Delete API Doc entity definition if updating from 1.x.
119+
*/
120+
function apigee_api_catalog_update_8805() {
121+
return \Drupal::service('apigee_api_catalog.updates')->update8805();
122+
}

apigee_api_catalog.services.yml

+4
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ services:
1313
arguments: ['@path.matcher', '@path.validator']
1414
tags:
1515
- { name: event_subscriber }
16+
17+
apigee_api_catalog.updates:
18+
class: Drupal\apigee_api_catalog\UpdateService
19+
arguments: ['@uuid', '@config.factory', '@module_handler', '@entity_type.manager', '@entity_field.manager', '@entity.last_installed_schema.repository']

0 commit comments

Comments
 (0)