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
d4a92f8c
Commit
d4a92f8c
authored
Aug 21, 2016
by
Pawel G
Browse files
make getSetting() return a provided default value if setting does not exist
parent
60cdc004
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/Batch.php
View file @
d4a92f8c
...
...
@@ -172,15 +172,15 @@ class Batch {
$url_object
=
$entity
->
toUrl
();
}
// Do not in
dex if this is an
external path.
// Do not in
clude
external path
s
.
if
(
!
$url_object
->
isRouted
())
continue
;
// Do not include path i
f
anonymous users
do not have access to it
.
// Do not include path
s
i
naccessible to
anonymous users.
if
(
!
$url_object
->
access
(
$anon_user
))
continue
;
// Do not include path
if it
already
exists
.
// Do not include path
s that have been
already
indexed
.
$path
=
$url_object
->
getInternalPath
();
if
(
$batch_info
[
'remove_duplicates'
]
&&
self
::
pathProcessed
(
$path
,
$context
))
continue
;
...
...
src/Form/SimplesitemapSettingsForm.php
View file @
d4a92f8c
...
...
@@ -63,7 +63,7 @@ class SimplesitemapSettingsForm extends ConfigFormBase {
'#type'
=>
'checkbox'
,
'#title'
=>
$this
->
t
(
'Regenerate the sitemap on every cron run'
),
'#description'
=>
$this
->
t
(
'Uncheck this if you intend to only regenerate the sitemap manually or via drush.'
),
'#default_value'
=>
$generator
->
getSetting
(
'cron_generate'
),
'#default_value'
=>
$generator
->
getSetting
(
'cron_generate'
,
TRUE
),
];
$form
[
'simple_sitemap_settings'
][
'advanced'
]
=
[
...
...
@@ -91,7 +91,7 @@ class SimplesitemapSettingsForm extends ConfigFormBase {
'#type'
=>
'textfield'
,
'#maxlength'
=>
5
,
'#size'
=>
5
,
'#default_value'
=>
$generator
->
getSetting
(
'max_links'
),
'#default_value'
=>
$generator
->
getSetting
(
'max_links'
,
2000
),
];
$form
[
'simple_sitemap_settings'
][
'advanced'
][
'batch_process_limit'
]
=
[
...
...
@@ -100,7 +100,7 @@ class SimplesitemapSettingsForm extends ConfigFormBase {
'#type'
=>
'textfield'
,
'#maxlength'
=>
5
,
'#size'
=>
5
,
'#default_value'
=>
$generator
->
getSetting
(
'batch_process_limit'
),
'#default_value'
=>
$generator
->
getSetting
(
'batch_process_limit'
,
1500
),
'#required'
=>
TRUE
,
//TODO: test
];
...
...
src/Simplesitemap.php
View file @
d4a92f8c
...
...
@@ -391,12 +391,15 @@ class Simplesitemap {
* @param string $name
* Name of the setting, like 'max_links'.
*
* @param mixed $default
* Value to be returned if the setting does not exist in the conifuration.
*
* @return mixed
* The current setting from db or
FALSE if setting does not exist
.
* The current setting from db or
a default value
.
*/
public
function
getSetting
(
$name
)
{
public
function
getSetting
(
$name
,
$default
=
FALSE
)
{
$settings
=
$this
->
getConfig
(
'settings'
);
return
isset
(
$settings
[
$name
])
?
$settings
[
$name
]
:
FALSE
;
return
isset
(
$settings
[
$name
])
?
$settings
[
$name
]
:
$default
;
}
/**
...
...
src/SitemapGenerator.php
View file @
d4a92f8c
...
...
@@ -41,8 +41,9 @@ class SitemapGenerator {
'from'
=>
$this
->
generateFrom
,
'batch_process_limit'
=>
!
empty
(
$this
->
generator
->
getSetting
(
'batch_process_limit'
))
?
$this
->
generator
->
getSetting
(
'batch_process_limit'
)
:
NULL
,
'max_links'
=>
$this
->
generator
->
getSetting
(
'max_links'
),
'remove_duplicates'
=>
$this
->
generator
->
getSetting
(
'remove_duplicates'
),
'max_links'
=>
$this
->
generator
->
getSetting
(
'max_links'
,
2000
),
'skip_untranslated'
=>
$this
->
generator
->
getSetting
(
'skip_untranslated'
,
FALSE
),
'remove_duplicates'
=>
$this
->
generator
->
getSetting
(
'remove_duplicates'
,
TRUE
),
'entity_types'
=>
$this
->
generator
->
getConfig
(
'entity_types'
),
]);
// Add custom link generating operation.
...
...
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