Skip to content
Snippets Groups Projects
Commit de7b2b88 authored by Patrick Kenny's avatar Patrick Kenny Committed by Damien McKenna
Browse files

Issue #3431154 by DamienMcKenna, Project Update Bot, ptmkenny,...

Issue #3431154 by DamienMcKenna, Project Update Bot, ptmkenny, travis-bradbury: Drupal 11 compatibility, require Drupal 10+.
parent 6e2d65a1
Branches
Tags
1 merge request!22Support drupal 11
Pipeline #195595 passed with warnings
......@@ -43,7 +43,13 @@ stylelint:
variables:
_CSPELL_WORDS: 'dawehner,Jesin,josdejong,jsoneditor,jsonview,McKenna,quickedit,Swaggest,yesmeck'
OPT_IN_TEST_MAX_PHP: '1'
OPT_IN_TEST_PREVIOUS_MAJOR: '1'
# Drupal 11; fails because of Composer dependencies.
# OPT_IN_TEST_NEXT_MAJOR: '1'
# Drupal 10.3; fails phpstan because of API deprecations.
# OPT_IN_TEST_NEXT_MINOR: '1'
# Drupal 9 fails because of Composer dependencies and API changes required by
# D11.
# OPT_IN_TEST_PREVIOUS_MAJOR: '1'
OPT_IN_TEST_PREVIOUS_MINOR: '1'
# Disable the next phpstan minor release as it would involve breaking
# compatibility with D9 and < 10.3.
......
......@@ -10,6 +10,8 @@ JSON Field 8.x-1.x-dev, 2024-xx-xx
phpstan and stylelint to pass.
#3411495 by ptmkenny, Chi, DamienMcKenna: Add a formatter to represent JSON data
in human readable form.
#3431154 by DamienMcKenna, Project Update Bot, ptmkenny, travis-bradbury: Drupal
11 compatibility, require Drupal 10+.
JSON Field 8.x-1.3, 2023-08-09
......
......@@ -19,11 +19,11 @@
},
"require": {
"ext-json": "*",
"drupal/core": "^9.2 || ^10"
"drupal/core": "^10 || ^11"
},
"require-dev": {
"drupal/diff": "^1",
"drupal/feeds": "^3.0@beta",
"drupal/feeds": "dev-3.x@dev",
"swaggest/json-schema": "^0"
},
"suggest": {
......
data:
label: 'Data'
description: 'Arbitrary data'
weight: 0
name: JSON Field
type: module
description: Provides a JSON field, formatter and views integration.
core_version_requirement: ^9 || ^10
core_version_requirement: ^10 || ^11
package: Field types
dependencies:
- drupal:field
......
......@@ -6,6 +6,7 @@
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Implements hook_help().
......@@ -31,3 +32,17 @@ function json_field_theme() {
return $theme;
}
/**
* Implements hook_field_info_alter().
*/
function json_field_field_info_alter(array &$info): void {
// Allow module to work with versions of older versions of Drupal.
if (\version_compare(\Drupal::VERSION, '10.1.9999', '<')) {
foreach (['json', 'json_native', 'json_native_binary'] as $field_type) {
if (empty($info[$field_type]['category'])) {
$info[$field_type]['category'] = new TranslatableMarkup('JSON data');
}
}
}
}
......@@ -11,7 +11,7 @@
return JSON.parse(string);
}
catch (e) {
return null;
return NULL;
}
}
......
name: JSON Field Widget
type: module
description: Adds a new field widget for the JSON Field module.
core_version_requirement: ^9 || ^10
core_version_requirement: ^9 || ^10 || ^11
package: Field types
dependencies:
- json_field:json_field
......@@ -21,7 +21,7 @@ class JsonItemNormalizer extends NormalizerBase {
/**
* {@inheritdoc}
*/
public function normalize($object, $format = NULL, array $context = []) {
public function normalize(mixed $object, ?string $format = NULL, array $context = []): \ArrayObject|array|string|int|float|bool|NULL {
$field = $object->getParent();
return [
$field->getName() => [$object->getValue()],
......
......@@ -16,7 +16,7 @@ use Drupal\Core\TypedData\DataDefinition;
* id = "json",
* label = @Translation("JSON (text)"),
* description = @Translation("Allows JSON data to be stored in the database. In the database the content is stored in a text column."),
* category = @Translation("Data"),
* category = "data",
* default_widget = "json_textarea",
* default_formatter = "json",
* constraints = {"valid_json" = {}}
......
......@@ -12,7 +12,7 @@ use Drupal\Core\TypedData\DataDefinition;
* id = "json_native_binary",
* label = @Translation("JSONB/JSON (raw)"),
* description = @Translation("Allows JSON data to be stored in the database. On PostgreSQL the data is stored in a JSONB column, on MySQL it uses a regular JSON column."),
* category = @Translation("Data"),
* category = "data",
* default_widget = "json_textarea",
* default_formatter = "json",
* constraints = {"valid_json" = {}}*
......
......@@ -13,7 +13,7 @@ use Drupal\Core\TypedData\DataDefinition;
* id = "json_native",
* label = @Translation("JSON (raw)"),
* description = @Translation("Allows JSON data to be stored in the database. Stores the data in a JSON column in the database."),
* category = @Translation("Data"),
* category = "data",
* default_widget = "json_textarea",
* default_formatter = "json",
* constraints = {"valid_json" = {}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment