Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fillpdf
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
drupal.org
fillpdf
Commits
182acd2a
Commit
182acd2a
authored
5 years ago
by
Bernd Oliver Suenderhauf
Browse files
Options
Downloads
Patches
Plain Diff
Issue #3057401 by Pancho, wizonesolutions: Add a getter for TokenResolver->tokenService
parent
2327789e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/TokenResolver.php
+15
-8
15 additions, 8 deletions
src/TokenResolver.php
src/TokenResolverInterface.php
+8
-0
8 additions, 0 deletions
src/TokenResolverInterface.php
with
23 additions
and
8 deletions
src/TokenResolver.php
+
15
−
8
View file @
182acd2a
...
@@ -14,11 +14,11 @@ use Drupal\token\TokenEntityMapperInterface;
...
@@ -14,11 +14,11 @@ use Drupal\token\TokenEntityMapperInterface;
class
TokenResolver
implements
TokenResolverInterface
{
class
TokenResolver
implements
TokenResolverInterface
{
/**
/**
* Token
replacement instan
ce.
* T
he t
oken
servi
ce.
*
*
* @var \Drupal\
Core\Utility
\Token
* @var \Drupal\
token
\Token
*/
*/
protected
$token
;
protected
$token
Service
;
/**
/**
* The token entity mapper.
* The token entity mapper.
...
@@ -31,12 +31,12 @@ class TokenResolver implements TokenResolverInterface {
...
@@ -31,12 +31,12 @@ class TokenResolver implements TokenResolverInterface {
* Constructs a TokenResolver object.
* Constructs a TokenResolver object.
*
*
* @param \Drupal\Core\Utility\Token $token
* @param \Drupal\Core\Utility\Token $token
* The token
replacement instan
ce.
* The token
servi
ce.
* @param \Drupal\token\TokenEntityMapperInterface $token_entity_mapper
* @param \Drupal\token\TokenEntityMapperInterface $token_entity_mapper
* The token entity mapper.
* The token entity mapper.
*/
*/
public
function
__construct
(
Token
$token
,
TokenEntityMapperInterface
$token_entity_mapper
)
{
public
function
__construct
(
Token
$token
_service
,
TokenEntityMapperInterface
$token_entity_mapper
)
{
$this
->
token
=
$token
;
$this
->
token
Service
=
$token
_service
;
$this
->
tokenEntityMapper
=
$token_entity_mapper
;
$this
->
tokenEntityMapper
=
$token_entity_mapper
;
}
}
...
@@ -52,7 +52,7 @@ class TokenResolver implements TokenResolverInterface {
...
@@ -52,7 +52,7 @@ class TokenResolver implements TokenResolverInterface {
$seititne
=
array_reverse
(
$entity_objects
);
// Get it?
$seititne
=
array_reverse
(
$entity_objects
);
// Get it?
foreach
(
$seititne
as
$entity_id
=>
$entity
)
{
foreach
(
$seititne
as
$entity_id
=>
$entity
)
{
$replaced_string
=
$this
->
token
->
replace
(
$replaced_string
,
[
$replaced_string
=
$this
->
token
Service
->
replace
(
$replaced_string
,
[
$entity_type
=>
$entity
,
$entity_type
=>
$entity
,
]);
]);
}
}
...
@@ -61,10 +61,17 @@ class TokenResolver implements TokenResolverInterface {
...
@@ -61,10 +61,17 @@ class TokenResolver implements TokenResolverInterface {
// The entities might not have had values for all the tokens in the pattern.
// The entities might not have had values for all the tokens in the pattern.
// Ensure that any remaining tokens are cleared from the string so they
// Ensure that any remaining tokens are cleared from the string so they
// don't get sent to the PDF.
// don't get sent to the PDF.
$clean_replaced_string
=
$this
->
token
->
replace
(
$replaced_string
,
[],
[
'clear'
=>
TRUE
]);
$clean_replaced_string
=
$this
->
token
Service
->
replace
(
$replaced_string
,
[],
[
'clear'
=>
TRUE
]);
return
PlainTextOutput
::
renderFromHtml
(
$clean_replaced_string
);
return
PlainTextOutput
::
renderFromHtml
(
$clean_replaced_string
);
}
}
/**
* {@inheritdoc}
*/
public
function
getTokenService
()
{
return
$this
->
tokenService
;
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
...
...
This diff is collapsed.
Click to expand it.
src/TokenResolverInterface.php
+
8
−
0
View file @
182acd2a
...
@@ -27,6 +27,14 @@ interface TokenResolverInterface {
...
@@ -27,6 +27,14 @@ interface TokenResolverInterface {
*/
*/
public
function
replace
(
$original
,
array
$entities
);
public
function
replace
(
$original
,
array
$entities
);
/**
* Returns the token service.
*
* @return \Drupal\token\Token
* The token service.
*/
public
function
getTokenService
();
/**
/**
* Returns the token entity mapper.
* Returns the token entity mapper.
*
*
...
...
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