Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
S
simple_sitemap
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
simple_sitemap
Commits
2d1a35a0
Commit
2d1a35a0
authored
Dec 01, 2017
by
Pawel G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not show lastmod for menu item URLs
parent
637c6709
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
9 deletions
+49
-9
src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php
...Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php
+6
-2
src/Tests/SimplesitemapTest.php
src/Tests/SimplesitemapTest.php
+43
-7
No files found.
src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php
View file @
2d1a35a0
...
@@ -84,10 +84,14 @@ class EntityUrlGenerator extends UrlGeneratorBase {
...
@@ -84,10 +84,14 @@ class EntityUrlGenerator extends UrlGeneratorBase {
$url_object
->
setOption
(
'absolute'
,
TRUE
);
$url_object
->
setOption
(
'absolute'
,
TRUE
);
$lastmod
=
method_exists
(
$entity
,
'getChangedTime'
)
?
date_iso8601
(
$entity
->
getChangedTime
())
:
NULL
;
// Menu fix.
$lastmod
=
$entity_type_name
!==
'menu_link_content'
?
$lastmod
:
NULL
;
return
[
return
[
'url'
=>
$url_object
,
'url'
=>
$url_object
,
'lastmod'
=>
method_exists
(
$entity
,
'getChangedTime'
)
'lastmod'
=>
$lastmod
,
?
date_iso8601
(
$entity
->
getChangedTime
())
:
NULL
,
'priority'
=>
isset
(
$entity_settings
[
'priority'
])
?
$entity_settings
[
'priority'
]
:
NULL
,
'priority'
=>
isset
(
$entity_settings
[
'priority'
])
?
$entity_settings
[
'priority'
]
:
NULL
,
'changefreq'
=>
!
empty
(
$entity_settings
[
'changefreq'
])
?
$entity_settings
[
'changefreq'
]
:
NULL
,
'changefreq'
=>
!
empty
(
$entity_settings
[
'changefreq'
])
?
$entity_settings
[
'changefreq'
]
:
NULL
,
'images'
=>
!
empty
(
$entity_settings
[
'include_images'
])
'images'
=>
!
empty
(
$entity_settings
[
'include_images'
])
...
...
src/Tests/SimplesitemapTest.php
View file @
2d1a35a0
...
@@ -3,8 +3,6 @@
...
@@ -3,8 +3,6 @@
namespace
Drupal\simple_sitemap\Tests
;
namespace
Drupal\simple_sitemap\Tests
;
/**
/**
* Class SimplesitemapTest
*
* Tests Simple XML sitemap functional integration.
* Tests Simple XML sitemap functional integration.
*
*
* @package Drupal\simple_sitemap\Tests
* @package Drupal\simple_sitemap\Tests
...
@@ -157,6 +155,36 @@ class SimplesitemapTest extends SimplesitemapTestBase {
...
@@ -157,6 +155,36 @@ class SimplesitemapTest extends SimplesitemapTestBase {
$this
->
assertNoRaw
(
'changefreq'
);
$this
->
assertNoRaw
(
'changefreq'
);
}
}
/**
* Test the lastmod parameter in different scenarios.
*/
public
function
testLastmod
()
{
// Entity links should have 'lastmod'.
$this
->
generator
->
setBundleSettings
(
'node'
,
'page'
)
->
removeCustomLinks
()
->
generateSitemap
(
'nobatch'
);
$this
->
drupalGet
(
'sitemap.xml'
);
$this
->
assertRaw
(
'lastmod'
);
// Entity custom links should have 'lastmod'.
$this
->
generator
->
setBundleSettings
(
'node'
,
'page'
,
[
'index'
=>
FALSE
])
->
addCustomLink
(
'/node/'
.
$this
->
node
->
id
())
->
generateSitemap
(
'nobatch'
);
$this
->
drupalGet
(
'sitemap.xml'
);
$this
->
assertRaw
(
'lastmod'
);
// Non-entity custom links should not have 'lastmod'.
$this
->
generator
->
removeCustomLinks
()
->
addCustomLink
(
'/'
)
->
generateSitemap
(
'nobatch'
);
$this
->
drupalGet
(
'sitemap.xml'
);
$this
->
assertNoRaw
(
'lastmod'
);
}
/**
/**
* Tests the duplicate setting.
* Tests the duplicate setting.
*
*
...
@@ -256,16 +284,24 @@ class SimplesitemapTest extends SimplesitemapTestBase {
...
@@ -256,16 +284,24 @@ class SimplesitemapTest extends SimplesitemapTestBase {
$this
->
assertText
(
'never'
);
$this
->
assertText
(
'never'
);
}
}
/**
/**
* Test indexing an atomic entity (here: a user).
* Test indexing an atomic entity (here: a user)
* @todo Not working
*/
*/
public
function
indexAtomicEntity
()
{
/* public function testAtomicEntityIndexation
() {
$user = $this->createPrivilegedUser();
$user = $this->createPrivilegedUser();
$this
->
generator
->
setBundleSettings
(
'user'
);
$this->generator->setBundleSettings('user')
->generateSitemap('nobatch');
$this->drupalGet('sitemap.xml');
$this->assertNoText('user/' . $user->id());
user_role_grant_permissions(0, ['access user profiles']);
$this->generator->generateSitemap('nobatch');
$this->drupalGet('sitemap.xml');
$this->drupalGet('sitemap.xml');
$this->assertText('user/' . $user->id());
$this->assertText('user/' . $user->id());
}
}
*/
/**
/**
* @todo Test indexing menu.
* @todo Test indexing menu.
...
...
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