Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443488
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443488
Commits
54cc80e4
Commit
54cc80e4
authored
4 years ago
by
Jess
Browse files
Options
Downloads
Patches
Plain Diff
SA-
CORE-2020
-006 by BR0kEN, Wim Leers, xjm, larowlan
parent
b34dc3f7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/jsonapi/src/Controller/EntityResource.php
+1
-1
1 addition, 1 deletion
core/modules/jsonapi/src/Controller/EntityResource.php
core/modules/jsonapi/src/Controller/FileUpload.php
+4
-2
4 additions, 2 deletions
core/modules/jsonapi/src/Controller/FileUpload.php
with
5 additions
and
3 deletions
core/modules/jsonapi/src/Controller/EntityResource.php
+
1
−
1
View file @
54cc80e4
...
...
@@ -322,7 +322,7 @@ public function patchIndividual(ResourceType $resource_type, EntityInterface $en
));
}
$data
+=
[
'attributes'
=>
[],
'relationships'
=>
[]];
$field_names
=
array_merge
(
array_keys
(
$data
[
'attributes'
]),
array_keys
(
$data
[
'relationships'
]));
$field_names
=
array_map
([
$resource_type
,
'getInternalName'
],
array_merge
(
array_keys
(
$data
[
'attributes'
]),
array_keys
(
$data
[
'relationships'
]))
)
;
// User resource objects contain a read-only attribute that is not a real
// field on the user entity type.
...
...
This diff is collapsed.
Click to expand it.
core/modules/jsonapi/src/Controller/FileUpload.php
+
4
−
2
View file @
54cc80e4
...
...
@@ -112,6 +112,7 @@ public function __construct(AccountInterface $current_user, EntityFieldManagerIn
* created file entity.
*/
public
function
handleFileUploadForExistingResource
(
Request
$request
,
ResourceType
$resource_type
,
$file_field_name
,
FieldableEntityInterface
$entity
)
{
$file_field_name
=
$resource_type
->
getInternalName
(
$file_field_name
);
$field_definition
=
$this
->
validateAndLoadFieldDefinition
(
$resource_type
->
getEntityTypeId
(),
$resource_type
->
getBundle
(),
$file_field_name
);
static
::
ensureFileUploadAccess
(
$this
->
currentUser
,
$field_definition
,
$entity
);
...
...
@@ -138,7 +139,7 @@ public function handleFileUploadForExistingResource(Request $request, ResourceTy
$entity
->
save
();
$route_parameters
=
[
'entity'
=>
$entity
->
uuid
()];
$route_name
=
sprintf
(
'jsonapi.%s.%s.related'
,
$resource_type
->
getTypeName
(),
$file_field_name
);
$route_name
=
sprintf
(
'jsonapi.%s.%s.related'
,
$resource_type
->
getTypeName
(),
$resource_type
->
getPublicName
(
$file_field_name
)
)
;
$related_url
=
Url
::
fromRoute
(
$route_name
,
$route_parameters
)
->
toString
(
TRUE
);
$request
=
Request
::
create
(
$related_url
->
getGeneratedUrl
(),
'GET'
,
[],
$request
->
cookies
->
all
(),
[],
$request
->
server
->
all
());
return
$this
->
httpKernel
->
handle
(
$request
,
HttpKernelInterface
::
SUB_REQUEST
);
...
...
@@ -161,6 +162,7 @@ public function handleFileUploadForExistingResource(Request $request, ResourceTy
* Thrown when there are validation errors.
*/
public
function
handleFileUploadForNewResource
(
Request
$request
,
ResourceType
$resource_type
,
$file_field_name
)
{
$file_field_name
=
$resource_type
->
getInternalName
(
$file_field_name
);
$field_definition
=
$this
->
validateAndLoadFieldDefinition
(
$resource_type
->
getEntityTypeId
(),
$resource_type
->
getBundle
(),
$file_field_name
);
static
::
ensureFileUploadAccess
(
$this
->
currentUser
,
$field_definition
);
...
...
@@ -182,7 +184,7 @@ public function handleFileUploadForNewResource(Request $request, ResourceType $r
/* $self_link = new Link(new CacheableMetadata(), $this->entity->toUrl('jsonapi'), ['self']); */
$links
=
new
LinkCollection
([
'self'
=>
$self_link
]);
$relatable_resource_types
=
$resource_type
->
getRelatableResourceTypesByField
(
$file_field_name
);
$relatable_resource_types
=
$resource_type
->
getRelatableResourceTypesByField
(
$
resource_type
->
getPublicName
(
$
file_field_name
)
)
;
$file_resource_type
=
reset
(
$relatable_resource_types
);
$resource_object
=
ResourceObject
::
createFromEntity
(
$file_resource_type
,
$file
);
return
new
ResourceResponse
(
new
JsonApiDocumentTopLevel
(
new
ResourceObjectData
([
$resource_object
],
1
),
new
NullIncludedData
(),
$links
),
201
,
[]);
...
...
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