Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Commits
8f850956
Commit
8f850956
authored
2 years ago
by
Eric Bremner
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-5753: adding DI for uw content report
parent
c5193bee
No related branches found
No related tags found
1 merge request
!269
Feature/istwcms 5753 ebremner csv content report
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Controller/UwDownloadCsvController.php
+18
-3
18 additions, 3 deletions
src/Controller/UwDownloadCsvController.php
with
18 additions
and
3 deletions
src/Controller/UwDownloadCsvController.php
+
18
−
3
View file @
8f850956
...
@@ -5,6 +5,7 @@ namespace Drupal\uw_cfg_common\Controller;
...
@@ -5,6 +5,7 @@ namespace Drupal\uw_cfg_common\Controller;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\path_alias
\AliasManager
;
use
Drupal\path_alias
\AliasManager
;
use
Drupal\transliterate_filenames
\SanitizeName
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\Response
;
...
@@ -27,6 +28,13 @@ class UwDownloadCsvController extends ControllerBase {
...
@@ -27,6 +28,13 @@ class UwDownloadCsvController extends ControllerBase {
*/
*/
protected
$pathAlias
;
protected
$pathAlias
;
/**
* Sanitize name.
*
* @var Drupal\transliterate_filenames\SanitizeName
*/
protected
$sanitizeName
;
/**
/**
* CSV Report constructor.
* CSV Report constructor.
*
*
...
@@ -34,13 +42,18 @@ class UwDownloadCsvController extends ControllerBase {
...
@@ -34,13 +42,18 @@ class UwDownloadCsvController extends ControllerBase {
* The entity type manager.
* The entity type manager.
* @param Drupal\path_alias\AliasManager $pathAlias
* @param Drupal\path_alias\AliasManager $pathAlias
* The path alias.
* The path alias.
* @param Drupal\transliterate_filenames\SanitizeName $sanitizeName
* The sanitize name.
*/
*/
public
function
__construct
(
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
,
EntityTypeManagerInterface
$entityTypeManager
,
AliasManager
$pathAlias
AliasManager
$pathAlias
,
SanitizeName
$sanitizeName
)
{
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
pathAlias
=
$pathAlias
;
$this
->
pathAlias
=
$pathAlias
;
$this
->
sanitizeName
=
$sanitizeName
;
}
}
/**
/**
...
@@ -49,7 +62,8 @@ class UwDownloadCsvController extends ControllerBase {
...
@@ -49,7 +62,8 @@ class UwDownloadCsvController extends ControllerBase {
public
static
function
create
(
ContainerInterface
$container
)
{
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
return
new
static
(
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'path_alias.manager'
)
$container
->
get
(
'path_alias.manager'
),
$container
->
get
(
'transliterate_filenames.sanitize_name'
)
);
);
}
}
...
@@ -114,8 +128,9 @@ class UwDownloadCsvController extends ControllerBase {
...
@@ -114,8 +128,9 @@ class UwDownloadCsvController extends ControllerBase {
// Determine the filename for the CSV.
// Determine the filename for the CSV.
$sitename
=
\Drupal
::
config
(
'system.site'
)
->
get
(
'name'
);
$sitename
=
\Drupal
::
config
(
'system.site'
)
->
get
(
'name'
);
$filename
=
$sitename
.
'_content_report.csv'
;
$filename
=
$sitename
.
'_content_report.csv'
;
// Make sure we are using a safe filename.
// Make sure we are using a safe filename.
$filename
=
\Drupal
::
service
(
'transliterate_filenames.
sanitize
_n
ame
'
)
->
sanitizeFilename
(
$filename
);
$filename
=
$this
->
sanitize
N
ame
->
sanitizeFilename
(
$filename
);
// Set the headers for the CSV.
// Set the headers for the CSV.
$response
->
headers
->
set
(
'Content-Type'
,
'text/csv'
);
$response
->
headers
->
set
(
'Content-Type'
,
'text/csv'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment