Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
X
xmlsitemap
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
0
Merge Requests
0
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
xmlsitemap
Commits
5c359697
Commit
5c359697
authored
Aug 02, 2014
by
andrei.dincu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2249723
by andrei.dincu: form_state is FormStateInterface now
parent
c9a042b9
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
47 additions
and
36 deletions
+47
-36
src/Form/XmlSitemapDeleteForm.php
src/Form/XmlSitemapDeleteForm.php
+2
-1
src/Form/XmlSitemapEntitiesSettingsForm.php
src/Form/XmlSitemapEntitiesSettingsForm.php
+3
-2
src/Form/XmlSitemapForm.php
src/Form/XmlSitemapForm.php
+4
-3
src/Form/XmlSitemapLinkBundleSettingsForm.php
src/Form/XmlSitemapLinkBundleSettingsForm.php
+3
-2
src/Form/XmlSitemapRebuildForm.php
src/Form/XmlSitemapRebuildForm.php
+3
-2
src/Form/XmlSitemapSettingsForm.php
src/Form/XmlSitemapSettingsForm.php
+5
-4
src/Tests/XmlSitemapListBuilderTest.php
src/Tests/XmlSitemapListBuilderTest.php
+3
-3
src/Tests/XmlSitemapMenuFunctionalTest.php
src/Tests/XmlSitemapMenuFunctionalTest.php
+1
-1
xmlsitemap.module
xmlsitemap.module
+8
-7
xmlsitemap_custom/src/Form/XmlSitemapCustomAddForm.php
xmlsitemap_custom/src/Form/XmlSitemapCustomAddForm.php
+4
-3
xmlsitemap_custom/src/Form/XmlSitemapCustomDeleteForm.php
xmlsitemap_custom/src/Form/XmlSitemapCustomDeleteForm.php
+3
-2
xmlsitemap_custom/src/Form/XmlSitemapCustomEditForm.php
xmlsitemap_custom/src/Form/XmlSitemapCustomEditForm.php
+4
-3
xmlsitemap_engines/src/Form/XmlSitemapEnginesSettingsForm.php
...itemap_engines/src/Form/XmlSitemapEnginesSettingsForm.php
+4
-3
No files found.
src/Form/XmlSitemapDeleteForm.php
View file @
5c359697
...
...
@@ -9,6 +9,7 @@ namespace Drupal\xmlsitemap\Form;
use
Drupal\Core\Entity\EntityConfirmFormBase
;
use
Drupal\Core\Url
;
use
Drupal\Core\Form\FormStateInterface
;
/**
* Builds the form to delete a sitemap.
...
...
@@ -46,7 +47,7 @@ class XmlSitemapDeleteForm extends EntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public
function
submit
(
array
$form
,
array
&
$form_state
)
{
public
function
submit
(
array
$form
,
FormStateInterface
$form_state
)
{
$this
->
entity
->
delete
();
drupal_set_message
(
$this
->
t
(
'Sitemap %label has been deleted.'
,
array
(
'%label'
=>
$this
->
entity
->
label
())));
$form_state
[
'redirect'
]
=
'admin/config/search/xmlsitemap'
;
...
...
src/Form/XmlSitemapEntitiesSettingsForm.php
View file @
5c359697
...
...
@@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityManagerInterface;
use
Drupal\Core\DependencyInjection\ContainerInjectionInterface
;
use
Drupal\Core\Session\AnonymousUserSession
;
use
Drupal\Core\Entity\ContentEntityTypeInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
...
...
@@ -59,7 +60,7 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
)
{
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
)
{
$config
=
$this
->
config
(
'xmlsitemap.settings'
);
$entity_types
=
$this
->
entityManager
->
getDefinitions
();
$labels
=
array
();
...
...
@@ -131,7 +132,7 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$bundles
=
$this
->
entityManager
->
getAllBundleInfo
();
$entity_values
=
$form_state
[
'values'
][
'entity_types'
];
$config
=
$this
->
config
(
'xmlsitemap.settings'
);
...
...
src/Form/XmlSitemapForm.php
View file @
5c359697
...
...
@@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityForm;
use
Drupal\Core\Entity\EntityStorageException
;
use
Drupal\Core\Language\LanguageInterface
;
use
Drupal\Core\Render\Element
;
use
Drupal\Core\Form\FormStateInterface
;
class
XmlSitemapForm
extends
EntityForm
{
...
...
@@ -24,7 +25,7 @@ class XmlSitemapForm extends EntityForm {
/**
* {@inheritdoc}
*/
public
function
form
(
array
$form
,
array
&
$form_state
)
{
public
function
form
(
array
$form
,
FormStateInterface
$form_state
)
{
$form
=
parent
::
form
(
$form
,
$form_state
);
if
(
$this
->
entity
->
getContext
()
==
NULL
)
{
$this
->
entity
->
context
=
array
();
...
...
@@ -57,7 +58,7 @@ class XmlSitemapForm extends EntityForm {
/**
* {@inheritdoc}
*/
public
function
save
(
array
$form
,
array
&
$form_state
)
{
public
function
save
(
array
$form
,
FormStateInterface
$form_state
)
{
if
(
!
isset
(
$form_state
[
'values'
][
'context'
]))
{
$form_state
[
'values'
][
'context'
]
=
xmlsitemap_get_current_context
();
}
...
...
@@ -92,7 +93,7 @@ class XmlSitemapForm extends EntityForm {
/**
* {@inheritdoc}
*/
public
function
delete
(
array
$form
,
array
&
$form_state
)
{
public
function
delete
(
array
$form
,
FormStateInterface
$form_state
)
{
$destination
=
array
();
$request
=
$this
->
getRequest
();
if
(
$request
->
query
->
has
(
'destination'
))
{
...
...
src/Form/XmlSitemapLinkBundleSettingsForm.php
View file @
5c359697
...
...
@@ -11,6 +11,7 @@ use Drupal\Core\Form\ConfigFormBase;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Entity\EntityManagerInterface
;
use
Drupal\Core\DependencyInjection\ContainerInjectionInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
;
...
...
@@ -62,7 +63,7 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase implements Contain
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
,
$entity
=
NULL
,
$bundle
=
NULL
)
{
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
,
$entity
=
NULL
,
$bundle
=
NULL
)
{
$this
->
entity_type
=
$entity
;
$this
->
bundle_type
=
$bundle
;
$config
=
$this
->
config
(
'xmlsitemap.settings'
);
...
...
@@ -104,7 +105,7 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase implements Contain
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$entity
=
$form
[
'xmlsitemap'
][
'#entity'
];
$bundle
=
$form
[
'xmlsitemap'
][
'#bundle'
];
...
...
src/Form/XmlSitemapRebuildForm.php
View file @
5c359697
...
...
@@ -10,6 +10,7 @@ namespace Drupal\xmlsitemap\Form;
use
Drupal\Core\Form\ConfigFormBase
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\State\StateInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
...
...
@@ -56,7 +57,7 @@ class XmlSitemapRebuildForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
)
{
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
)
{
$request
=
$this
->
getRequest
();
if
(
!
$request
->
request
&&
!
$this
->
state
->
get
(
'xmlsitemap_rebuild_needed'
))
{
if
(
!
$this
->
state
->
get
(
'xmlsitemap_regenerate_needed'
))
{
...
...
@@ -92,7 +93,7 @@ class XmlSitemapRebuildForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
// Save any changes to the frontpage link.
$batch
=
xmlsitemap_rebuild_batch
(
$form_state
[
'values'
][
'entities'
],
$form_state
[
'values'
][
'save_custom'
]);
batch_set
(
$batch
);
...
...
src/Form/XmlSitemapSettingsForm.php
View file @
5c359697
...
...
@@ -13,8 +13,9 @@ use Drupal\Core\Render\Element;
use
Drupal\Core\State\StateInterface
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Form\FormBuilderInterface
;
use
Symfony\Component\DependencyInjection\Container
Interface
;
use
Drupal\Core\Form\FormState
Interface
;
use
Drupal\xmlsitemap\XmlSitemapLinkStorageInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Configure xmlsitemap settings for this site.
...
...
@@ -78,7 +79,7 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
)
{
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
)
{
$config
=
$this
->
config
(
'xmlsitemap.settings'
);
$intervals
=
array
(
300
,
900
,
1800
,
3600
,
10800
,
21600
,
43200
,
86400
,
172800
,
259200
,
604800
);
$form
[
'minimum_lifetime'
]
=
array
(
...
...
@@ -210,7 +211,7 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
validateForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
validateForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
// Check that the chunk size will not create more than 1000 chunks.
$chunk_size
=
$form_state
[
'values'
][
'chunk_size'
];
if
(
$chunk_size
!=
'auto'
&&
$chunk_size
!=
50000
&&
(
xmlsitemap_get_link_count
()
/
$chunk_size
)
>
1000
)
{
...
...
@@ -229,7 +230,7 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
// Save any changes to the frontpage link.
$config
=
$this
->
config
(
'xmlsitemap.settings'
);
$values
=
$form_state
[
'values'
];
...
...
src/Tests/XmlSitemapListBuilderTest.php
View file @
5c359697
...
...
@@ -70,7 +70,7 @@ class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
*/
public
function
testDefaultSitemap
()
{
$this
->
drupalLogin
(
$this
->
admin_user
);
$context
=
array
(
'language'
=>
'en'
);
$context
=
array
();
$id
=
xmlsitemap_sitemap_get_context_hash
(
$context
);
$this
->
drupalGet
(
'admin/config/search/xmlsitemap'
);
...
...
@@ -89,7 +89,7 @@ class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
$this
->
drupalPostForm
(
'admin/config/search/xmlsitemap/add'
,
$edit
,
t
(
'Save'
));
$context
=
array
(
'language'
=>
'en'
);
$id
=
xmlsitemap_sitemap_get_context_hash
(
$context
);
$this
->
assertText
(
t
(
'
There is another sitemap saved with the same context
.'
));
$this
->
assertText
(
t
(
'
Saved the English sitemap
.'
));
$this
->
assertText
(
$id
);
$edit
=
array
(
...
...
@@ -110,7 +110,7 @@ class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
'context[language]'
=>
'und'
);
$this
->
drupalPostForm
(
'admin/config/search/xmlsitemap/add'
,
$edit
,
t
(
'Save'
));
$this
->
assertText
(
t
(
'
Saved the Undefined sitemap
.'
));
$this
->
assertText
(
t
(
'
There is another sitemap saved with the same context
.'
));
$sitemaps
=
entity_load_multiple
(
'xmlsitemap'
);
foreach
(
$sitemaps
as
$sitemap
)
{
...
...
src/Tests/XmlSitemapMenuFunctionalTest.php
View file @
5c359697
...
...
@@ -19,7 +19,7 @@ class XmlSitemapMenuFunctionalTest extends XmlSitemapTestBase {
*
* @var array
*/
public
static
$modules
=
array
(
'node'
,
'xmlsitemap'
,
'menu_link
'
,
'menu_ui'
);
public
static
$modules
=
array
(
'node'
,
'xmlsitemap'
,
'menu_link_content
'
,
'menu_ui'
);
public
static
function
getInfo
()
{
return
array
(
...
...
xmlsitemap.module
View file @
5c359697
...
...
@@ -20,6 +20,7 @@ use Drupal\Core\Routing\RouteMatchInterface;
use
Drupal\Core\Database\Query\AlterableInterface
;
use
Drupal\Core\Entity\Query\QueryInterface
;
use
Drupal\Core\Cache\Cache
;
use
Drupal\Core\Form\FormStateInterface
;
use
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
;
use
Symfony\Component\HttpFoundation\Response
;
...
...
@@ -1073,7 +1074,7 @@ function xmlsitemap_calculate_changefreq($timestamps) {
* This function needs to be called before system_settings_form_submit() or any
* calls to variable_set().
*/
function
xmlsitemap_form_submit_flag_regenerate
(
$form
,
$form_state
)
{
function
xmlsitemap_form_submit_flag_regenerate
(
array
$form
,
FormStateInterface
$form_state
)
{
foreach
(
$form_state
[
'values'
]
as
$variable
=>
$value
)
{
if
(
\
Drupal
::
config
(
'xmlsitemap.settings'
)
->
get
(
$variable
)
==
NULL
)
{
$stored_value
=
'not_a_variable'
;
...
...
@@ -1230,7 +1231,7 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
/**
* Submit callback for the entity form to save.
*/
function
xmlsitemap_process_form_link_options
(
$form
,
&
$form_state
)
{
function
xmlsitemap_process_form_link_options
(
array
$form
,
FormStateInterface
$form_state
)
{
$link
=
&
$form_state
[
'values'
][
'xmlsitemap'
];
$fields
=
array
(
'status'
=>
XMLSITEMAP_STATUS_DEFAULT
,
'priority'
=>
XMLSITEMAP_PRIORITY_DEFAULT
);
...
...
@@ -1562,14 +1563,14 @@ function theme_xmlsitemap_content_settings_table($variables) {
* An instance of the entity form interface or FALSE if not an
* entity form.
*/
function
xmlsitemap_form_controller
(
array
$form_state
)
{
function
xmlsitemap_form_controller
(
FormStateInterface
$form_state
)
{
return
isset
(
$form_state
[
'controller'
])
&&
$form_state
[
'controller'
]
instanceof
EntityForm
?
$form_state
[
'controller'
]
:
FALSE
;
}
/**
* Implements hook_form_alter().
*/
function
xmlsitemap_form_alter
(
array
&
$form
,
array
&
$form_state
,
$form_id
)
{
function
xmlsitemap_form_alter
(
array
&
$form
,
FormStateInterface
$form_state
,
$form_id
)
{
$form_controller
=
xmlsitemap_form_controller
(
$form_state
);
$entity
=
$form_controller
?
$form_controller
->
getEntity
()
:
NULL
;
$entity_type
=
$entity
?
$entity
->
getEntityTypeId
()
:
NULL
;
...
...
@@ -1774,7 +1775,7 @@ function xmlsitemap_xmlsitemap_context_url_options(array $context) {
/**
* Implements hook_form_FORM_ID_alter().
*/
function
xmlsitemap_form_xmlsitemap_sitemap_edit_form_alter
(
&
$form
,
$form_state
)
{
function
xmlsitemap_form_xmlsitemap_sitemap_edit_form_alter
(
&
$form
,
FormStateInterface
$form_state
)
{
if
(
!
\
Drupal
::
moduleHandler
()
->
moduleExists
(
'language'
))
{
return
;
}
...
...
@@ -1798,7 +1799,7 @@ function xmlsitemap_form_xmlsitemap_sitemap_edit_form_alter(&$form, $form_state)
*
* Set the regeneration needed flag if settings are changed.
*/
function
xmlsitemap_form_language_admin_overview_form_alter
(
&
$form
,
$form_state
)
{
function
xmlsitemap_form_language_admin_overview_form_alter
(
&
$form
,
FormStateInterface
$form_state
)
{
if
(
!
\
Drupal
::
moduleHandler
()
->
moduleExists
(
'language'
))
{
return
;
}
...
...
@@ -2067,7 +2068,7 @@ function xmlsitemap_add_form_entity_summary(&$form, $entity, array $entity_info)
* @param string $bundle
* Bundle id.
*/
function
xmlsitemap_add_link_bundle_settings
(
array
&
$form
,
array
&
$form_state
,
$entity
,
$bundle
)
{
function
xmlsitemap_add_link_bundle_settings
(
array
&
$form
,
FormStateInterface
$form_state
,
$entity
,
$bundle
)
{
$entity_info
=
xmlsitemap_get_link_info
(
$entity
);
$bundle_info
=
xmlsitemap_link_bundle_load
(
$entity
,
$bundle
);
...
...
xmlsitemap_custom/src/Form/XmlSitemapCustomAddForm.php
View file @
5c359697
...
...
@@ -16,6 +16,7 @@ use Drupal\Core\Form\FormBuilderInterface;
use
Drupal\Core\Language\LanguageManagerInterface
;
use
Drupal\Core\Path\AliasManagerInterface
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\xmlsitemap\XmlSitemapLinkStorageInterface
;
/**
...
...
@@ -92,7 +93,7 @@ class XmlSitemapCustomAddForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
)
{
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
)
{
$query
=
db_select
(
'xmlsitemap'
,
'x'
);
$query
->
addExpression
(
'MAX(id)'
);
$id
=
$query
->
execute
()
->
fetchField
();
...
...
@@ -169,7 +170,7 @@ class XmlSitemapCustomAddForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
validateForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
validateForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$link
=
&
$form_state
[
'values'
];
// Make sure we trim and normalize the path first.
...
...
@@ -200,7 +201,7 @@ class XmlSitemapCustomAddForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$link
=
$form_state
[
'values'
];
$this
->
linkStorage
->
save
(
$link
);
drupal_set_message
(
t
(
'The custom link for %loc was saved.'
,
array
(
'%loc'
=>
$link
[
'loc'
])));
...
...
xmlsitemap_custom/src/Form/XmlSitemapCustomDeleteForm.php
View file @
5c359697
...
...
@@ -10,6 +10,7 @@ namespace Drupal\xmlsitemap_custom\Form;
use
Drupal\Core\Form\ConfirmFormBase
;
use
Drupal\Core\Url
;
use
Drupal\xmlsitemap\XmlSitemapLinkStorage
;
use
Drupal\Core\Form\FormStateInterface
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
/**
...
...
@@ -34,7 +35,7 @@ class XmlSitemapCustomDeleteForm extends ConfirmFormBase {
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
,
$link
=
''
)
{
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
,
$link
=
''
)
{
$query
=
db_select
(
'xmlsitemap'
);
$query
->
fields
(
'xmlsitemap'
);
$query
->
condition
(
'type'
,
'custom'
);
...
...
@@ -75,7 +76,7 @@ class XmlSitemapCustomDeleteForm extends ConfirmFormBase {
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
XmlSitemapLinkStorage
::
linkDelete
(
'custom'
,
$this
->
custom_link
[
'id'
]);
drupal_set_message
(
t
(
'The custom link for %loc has been deleted.'
,
array
(
'%loc'
=>
$this
->
custom_link
[
'loc'
])));
watchdog
(
'xmlsitemap'
,
'The custom link for %loc has been deleted.'
,
array
(
'%loc'
=>
$this
->
custom_link
[
'loc'
]),
WATCHDOG_NOTICE
);
...
...
xmlsitemap_custom/src/Form/XmlSitemapCustomEditForm.php
View file @
5c359697
...
...
@@ -17,6 +17,7 @@ use Drupal\Core\Language\LanguageManagerInterface;
use
Drupal\Core\Path\AliasManagerInterface
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\xmlsitemap\XmlSitemapLinkStorageInterface
;
use
Drupal\Core\Form\FormStateInterface
;
/**
* Provides a form for editing a custom link.
...
...
@@ -99,7 +100,7 @@ class XmlSitemapCustomEditForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
,
$link
=
''
)
{
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
,
$link
=
''
)
{
$query
=
db_select
(
'xmlsitemap'
);
$query
->
fields
(
'xmlsitemap'
);
$query
->
condition
(
'type'
,
'custom'
);
...
...
@@ -188,7 +189,7 @@ class XmlSitemapCustomEditForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
validateForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
validateForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$link
=
&
$form_state
[
'values'
];
$link
[
'loc'
]
=
trim
(
$link
[
'loc'
]);
$link
[
'loc'
]
=
$this
->
aliasManager
->
getPathByAlias
(
$link
[
'loc'
],
$link
[
'language'
]);
...
...
@@ -205,7 +206,7 @@ class XmlSitemapCustomEditForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$link
=
$form_state
[
'values'
];
$this
->
linkStorage
->
save
(
$link
);
drupal_set_message
(
t
(
'The custom link for %loc was saved.'
,
array
(
'%loc'
=>
$link
[
'loc'
])));
...
...
xmlsitemap_engines/src/Form/XmlSitemapEnginesSettingsForm.php
View file @
5c359697
...
...
@@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use
Drupal\Core\State\StateInterface
;
use
Drupal\Core\Form\FormBuilderInterface
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Form\FormStateInterface
;
/**
* Configure xmlsitemap engines settings for this site.
...
...
@@ -68,7 +69,7 @@ class XmlSitemapEnginesSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
)
{
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
)
{
// Build the list of support engines for the checkboxes options.
$engines
=
xmlsitemap_engines_get_engine_info
();
$engine_options
=
array
();
...
...
@@ -112,7 +113,7 @@ class XmlSitemapEnginesSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
validateForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
validateForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$custom_urls
=
preg_split
(
'/[\r\n]+/'
,
$form_state
[
'values'
][
'custom_urls'
],
-
1
,
PREG_SPLIT_NO_EMPTY
);
foreach
(
$custom_urls
as
$custom_url
)
{
$url
=
xmlsitemap_engines_prepare_url
(
$custom_url
,
''
);
...
...
@@ -127,7 +128,7 @@ class XmlSitemapEnginesSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
array
&
$form_state
)
{
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$state_variables
=
xmlsitemap_engines_state_variables
();
$config_variables
=
xmlsitemap_engines_config_variables
();
$keys
=
array
(
...
...
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