Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
simple_sitemap
Commits
ab18db04
Commit
ab18db04
authored
Mar 11, 2016
by
Sam Becker
Committed by
Pawel G
Mar 11, 2016
Browse files
Issue
#2685383
by Sam152: Inject the simple sitemap service into SimplesitemapController
parent
c8085d85
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Controller/SimplesitemapController.php
View file @
ab18db04
...
...
@@ -7,12 +7,21 @@
namespace
Drupal\simple_sitemap\Controller
;
use
Drupal\Core\Cache\CacheableResponse
;
use
Drupal\Core\Controller\ControllerBase
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\HttpFoundation\Response
;
/**
* SimplesitemapController.
*/
class
SimplesitemapController
{
class
SimplesitemapController
extends
ControllerBase
{
/**
* The sitemap generator.
*
* @var \Drupal\simple_sitemap\Simplesitemap
*/
protected
$sitemapGenerator
;
/**
* Returns the whole sitemap, a requested sitemap chunk, or the sitemap index file.
...
...
@@ -25,8 +34,7 @@ class SimplesitemapController {
* Returns an XML response.
*/
public
function
getSitemap
(
$sitemap_id
=
NULL
)
{
$sitemap
=
\
Drupal
::
service
(
'simple_sitemap.generator'
);
$output
=
$sitemap
->
getSitemap
(
$sitemap_id
);
$output
=
$this
->
sitemapGenerator
->
getSitemap
(
$sitemap_id
);
$output
=
!
$output
?
''
:
$output
;
// Display sitemap with correct xml header.
...
...
@@ -35,4 +43,22 @@ class SimplesitemapController {
$meta_data
->
addCacheTags
([
'simple_sitemap'
]);
return
$response
;
}
/**
* SimplesitemapController constructor.
*
* @param \Drupal\simple_sitemap\Simplesitemap $sitemap_generator
* The sitemap generator.
*/
public
function
__construct
(
$sitemap_generator
)
{
$this
->
sitemapGenerator
=
$sitemap_generator
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'simple_sitemap.generator'
));
}
}
src/LinkGeneratorBase.php
View file @
ab18db04
<?php
/**
* @file
* Contains \Drupal\simple_sitemap\LinkGeneratorBase.
...
...
@@ -47,5 +46,4 @@ abstract class LinkGeneratorBase extends PluginBase implements LinkGeneratorInte
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
return
new
static
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$container
->
get
(
'database'
));
}
}
src/LinkGeneratorInterface.php
View file @
ab18db04
...
...
@@ -11,7 +11,6 @@ use Drupal\Component\Plugin\PluginInspectionInterface;
/**
* Defines an interface for simple_sitemap plugins.
*/
interface
LinkGeneratorInterface
extends
PluginInspectionInterface
{
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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