Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
229
Merge Requests
229
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
bd01bba5
Commit
bd01bba5
authored
Dec 19, 2013
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2155665
by Wim Leers | yched: Update field_valid_language() calls in edit.module.
parent
5e4fb4fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
19 deletions
+14
-19
core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php
...dit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php
+1
-1
core/modules/edit/lib/Drupal/edit/EditController.php
core/modules/edit/lib/Drupal/edit/EditController.php
+1
-1
core/modules/edit/tests/Drupal/edit/Tests/Access/EditEntityFieldAccessCheckTest.php
...upal/edit/Tests/Access/EditEntityFieldAccessCheckTest.php
+12
-17
No files found.
core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php
View file @
bd01bba5
...
...
@@ -88,7 +88,7 @@ protected function validateAndUpcastRequestAttributes(Request $request) {
throw
new
NotFoundHttpException
();
}
$langcode
=
$request
->
attributes
->
get
(
'langcode'
);
if
(
!
$langcode
||
(
field_valid_language
(
$langcode
)
!==
$langcode
))
{
if
(
!
$langcode
||
!
$entity
->
hasTranslation
(
$langcode
))
{
throw
new
NotFoundHttpException
();
}
}
...
...
core/modules/edit/lib/Drupal/edit/EditController.php
View file @
bd01bba5
...
...
@@ -149,7 +149,7 @@ public function metadata(Request $request) {
if
(
!
$field_name
||
!
$entity
->
hasField
(
$field_name
))
{
throw
new
NotFoundHttpException
();
}
if
(
!
$langcode
||
(
field_valid_language
(
$langcode
)
!==
$langcode
))
{
if
(
!
$langcode
||
!
$entity
->
hasTranslation
(
$langcode
))
{
throw
new
NotFoundHttpException
();
}
...
...
core/modules/edit/tests/Drupal/edit/Tests/Access/EditEntityFieldAccessCheckTest.php
View file @
bd01bba5
...
...
@@ -5,7 +5,7 @@
* Contains \Drupal\edit\Tests\Access\EditEntityFieldAccessCheckTest.
*/
namespace
Drupal\edit\Tests\Access
{
namespace
Drupal\edit\Tests\Access
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\Routing\Route
;
...
...
@@ -133,6 +133,10 @@ public function testAccess(EntityInterface $entity, FieldInterface $field = NULL
->
method
(
'get'
)
->
with
(
'valid'
)
->
will
(
$this
->
returnValue
(
$field
));
$entity_with_field
->
expects
(
$this
->
once
())
->
method
(
'hasTranslation'
)
->
with
(
Language
::
LANGCODE_NOT_SPECIFIED
)
->
will
(
$this
->
returnValue
(
TRUE
));
// Prepare the request to be valid.
$request
->
attributes
->
set
(
'entity_type'
,
'test_entity'
);
...
...
@@ -242,10 +246,16 @@ public function testAccessWithNotPassedLanguage() {
* @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public
function
testAccessWithInvalidLanguage
()
{
$entity
=
$this
->
createMockEntity
();
$entity
->
expects
(
$this
->
once
())
->
method
(
'hasTranslation'
)
->
with
(
'xx-lolspeak'
)
->
will
(
$this
->
returnValue
(
FALSE
));
$route
=
new
Route
(
'/edit/form/test_entity/1/body/und/full'
,
array
(),
array
(
'_access_edit_entity_field'
=>
'TRUE'
));
$request
=
new
Request
();
$request
->
attributes
->
set
(
'entity_type'
,
'entity_test'
);
$request
->
attributes
->
set
(
'entity'
,
$
this
->
createMockEntity
()
);
$request
->
attributes
->
set
(
'entity'
,
$
entity
);
$request
->
attributes
->
set
(
'field_name'
,
'valid'
);
$request
->
attributes
->
set
(
'langcode'
,
'xx-lolspeak'
);
...
...
@@ -272,18 +282,3 @@ protected function createMockEntity() {
}
}
}
// @todo remove once field_access() and field_valid_language() can be injected.
namespace
{
use
Drupal\Core\Language\Language
;
if
(
!
function_exists
(
'field_valid_language'
))
{
function
field_valid_language
(
$langcode
,
$default
=
TRUE
)
{
return
$langcode
==
Language
::
LANGCODE_NOT_SPECIFIED
?
Language
::
LANGCODE_NOT_SPECIFIED
:
'en'
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment