Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
simple_sitemap
Commits
4859ffa6
Commit
4859ffa6
authored
Jul 03, 2017
by
Pawel G
Browse files
Issue
#2884892
by Bitvark: Webform error if "Skip non-existent translations" is checked
parent
60836c5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Batch/UrlGeneratorBase.php
View file @
4859ffa6
...
...
@@ -4,6 +4,7 @@ namespace Drupal\simple_sitemap\Batch;
use
Drupal\Component\Utility\Html
;
use
Drupal\Core\Entity\ContentEntityBase
;
use
Drupal\Core\Entity\Entity
;
use
Drupal\Core\StringTranslation\StringTranslationTrait
;
use
Drupal\Core\Url
;
use
Drupal\simple_sitemap
\
Logger
;
...
...
@@ -160,14 +161,14 @@ class UrlGeneratorBase {
}
/**
* @param
\Drupal\Core\
Url $url_object
* @param Url $url_object
* @param array $path_data
* @param
\Drupal\Core\Entity\ContentEntityBase
$entity
* @param
Entity
$entity
*/
protected
function
addUrlVariants
(
Url
$url_object
,
array
$path_data
,
Content
Entity
Base
$entity
=
null
)
{
protected
function
addUrlVariants
(
Url
$url_object
,
array
$path_data
,
Entity
$entity
=
null
)
{
$alternate_urls
=
[];
$translation_languages
=
NULL
!==
$e
ntity
&&
$this
->
batchInfo
[
'skip_untranslated'
]
$translation_languages
=
$entity
instanceof
ContentE
ntity
Base
&&
$this
->
batchInfo
[
'skip_untranslated'
]
?
$entity
->
getTranslationLanguages
()
:
$this
->
languages
;
...
...
@@ -179,8 +180,8 @@ class UrlGeneratorBase {
}
}
else
{
// Including only translated variants of entity.
if
(
NULL
!==
$e
ntity
&&
$this
->
batchInfo
[
'skip_untranslated'
])
{
// Including only translated variants of
content
entity.
if
(
$entity
instanceof
ContentE
ntity
Base
&&
$this
->
batchInfo
[
'skip_untranslated'
])
{
foreach
(
$translation_languages
as
$language
)
{
$translation
=
$entity
->
getTranslation
(
$language
->
getId
());
if
(
$translation
->
access
(
'view'
,
$this
->
anonUser
))
{
...
...
@@ -190,7 +191,7 @@ class UrlGeneratorBase {
}
}
// Not a
n
entity or including all untranslated variants.
// Not a
content
entity or including all untranslated variants.
elseif
(
$url_object
->
access
(
$this
->
anonUser
))
{
foreach
(
$translation_languages
as
$language
)
{
$url_object
->
setOption
(
'language'
,
$language
);
...
...
Write
Preview
Supports
Markdown
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