Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jsonapi_extras
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
jsonapi_extras
Commits
cc7daf4b
Unverified
Commit
cc7daf4b
authored
Dec 4, 2018
by
Mateu Aguiló Bosch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3018067
: Ensure the entity bundle is provided to the resource repository
parent
11c96cc7
Branches
Branches containing commit
Tags
8.x-2.13
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Normalizer/SchemaFieldDefinitionNormalizer.php
+4
-1
4 additions, 1 deletion
src/Normalizer/SchemaFieldDefinitionNormalizer.php
src/Normalizer/SchemataSchemaNormalizer.php
+10
-3
10 additions, 3 deletions
src/Normalizer/SchemataSchemaNormalizer.php
with
14 additions
and
4 deletions
src/Normalizer/SchemaFieldDefinitionNormalizer.php
+
4
−
1
View file @
cc7daf4b
...
...
@@ -35,7 +35,10 @@ class SchemaFieldDefinitionNormalizer extends SchemataJsonSchemaFieldDefinitionN
$normalized
=
parent
::
normalize
(
$entity
,
$format
,
$context
);
// Load the resource type for this entity type and bundle.
$resource_type
=
$this
->
resourceTypeRepository
->
get
(
$context
[
'entityTypeId'
],
$context
[
'bundleId'
]);
$bundle
=
empty
(
$context
[
'bundleId'
])
?
$context
[
'entityTypeId'
]
:
$context
[
'bundleId'
];
$resource_type
=
$this
->
resourceTypeRepository
->
get
(
$context
[
'entityTypeId'
],
$bundle
);
if
(
!
$resource_type
||
!
$resource_type
instanceof
ConfigurableResourceType
)
{
return
$normalized
;
...
...
This diff is collapsed.
Click to expand it.
src/Normalizer/SchemataSchemaNormalizer.php
+
10
−
3
View file @
cc7daf4b
...
...
@@ -2,6 +2,7 @@
namespace
Drupal\jsonapi_extras\Normalizer
;
use
Drupal\Component\Utility\NestedArray
;
use
Drupal\schemata_json_schema
\Normalizer\jsonapi\SchemataSchemaNormalizer
as
SchemataJsonSchemaSchemataSchemaNormalizer
;
use
Drupal\jsonapi\ResourceType\ResourceTypeRepository
;
...
...
@@ -34,7 +35,12 @@ class SchemataSchemaNormalizer extends SchemataJsonSchemaSchemataSchemaNormalize
$normalized
=
parent
::
normalize
(
$entity
,
$format
,
$context
);
// Load the resource type for this entity type and bundle.
$resource_type
=
$this
->
resourceTypeRepository
->
get
(
$entity
->
getEntityTypeId
(),
$entity
->
getBundleId
());
$bundle
=
$entity
->
getBundleId
();
$bundle
=
$bundle
?:
$entity
->
getEntityTypeId
();
$resource_type
=
$this
->
resourceTypeRepository
->
get
(
$entity
->
getEntityTypeId
(),
$bundle
);
if
(
!
$resource_type
)
{
return
$normalized
;
...
...
@@ -47,8 +53,9 @@ class SchemataSchemaNormalizer extends SchemataJsonSchemaSchemataSchemaNormalize
$root
[
$property_type
][
'required'
]
=
[];
}
$required_fields
=
[];
foreach
(
$root
[
$property_type
][
'properties'
]
as
$fieldname
=>
$schema
)
{
$properties
=
&
$root
[
$property_type
][
'properties'
];
$properties
=
NestedArray
::
getValue
(
$root
,
[
$property_type
,
'properties'
]);
$properties
=
$properties
?:
[];
foreach
(
$properties
as
$fieldname
=>
$schema
)
{
unset
(
$properties
[
$fieldname
]);
if
(
!
$resource_type
->
isFieldEnabled
(
$fieldname
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment