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
xmlsitemap
Commits
126cf96e
Unverified
Commit
126cf96e
authored
Sep 26, 2018
by
Dave Reid
Committed by
Dave Reid
Sep 26, 2018
Browse files
Issue
#2416983
by Dave Reid: Added hook_xmlsitemap_rebuild_clear()
parent
e614903a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/XmlSitemapGenerator.php
View file @
126cf96e
...
...
@@ -395,6 +395,9 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface {
*/
public
function
rebuildBatchClear
(
array
$entity_type_ids
,
$save_custom
,
&
$context
)
{
if
(
!
empty
(
$entity_type_ids
))
{
// Let other modules respond to the rebuild clearing.
$this
->
moduleHandler
->
invokeAll
(
'xmlsitemap_rebuild_clear'
,
[
$entity_type_ids
,
$save_custom
]);
$query
=
db_delete
(
'xmlsitemap'
);
$query
->
condition
(
'type'
,
$entity_type_ids
,
'IN'
);
...
...
xmlsitemap.api.php
View file @
126cf96e
...
...
@@ -82,7 +82,7 @@ function hook_xmlsitemap_link_alter(&$link) {
* @see hook_xmlsitemap_link_update()
*/
function
hook_xmlsitemap_link_insert
(
array
$link
)
{
db_
insert
(
'mytable'
)
\
Drupal
::
database
()
->
insert
(
'mytable'
)
->
fields
([
'link_type'
=>
$link
[
'type'
],
'link_id'
=>
$link
[
'id'
],
...
...
@@ -101,7 +101,7 @@ function hook_xmlsitemap_link_insert(array $link) {
* @see hook_xmlsitemap_link_insert()
*/
function
hook_xmlsitemap_link_update
(
array
$link
)
{
db_
update
(
'mytable'
)
\
Drupal
::
database
()
->
update
(
'mytable'
)
->
fields
([
'link_type'
=>
$link
[
'type'
],
'link_id'
=>
$link
[
'id'
],
...
...
@@ -110,6 +110,20 @@ function hook_xmlsitemap_link_update(array $link) {
->
execute
();
}
/**
* Respond to XML sitemap link clearing and rebuilding.
*
* @param array $entity_type_ids
* An array of entity type IDs that are being rebuilt.
* @param bool $save_custom
* If links with overridden status and/or priority are being removed or not.
*/
function
hook_xmlsitemap_rebuild_clear
(
array
$entity_type_ids
,
$save_custom
)
{
\
Drupal
::
database
()
->
delete
(
'mytable'
)
->
condition
(
'link_type'
,
$types
,
'IN'
)
->
execute
();
}
/**
* Index links for the XML sitemaps.
*/
...
...
xmlsitemap.module
View file @
126cf96e
...
...
@@ -103,6 +103,7 @@ function xmlsitemap_hook_info() {
'query_xmlsitemap_generate_alter'
,
'query_xmlsitemap_link_bundle_access_alter'
,
'form_xmlsitemap_sitemap_edit_form_alter'
,
'xmlsitemap_rebuild_clear'
,
];
$hooks
=
array_combine
(
$hooks
,
$hooks
);
...
...
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