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
3c49f508
Commit
3c49f508
authored
3 years ago
by
Eric Bremner
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-5195: adding function to get formatted text
parent
750feb53
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!172
Feature/istwcms 5128 ebremner theme node services
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Service/UwNodeFieldValue.php
+22
-6
22 additions, 6 deletions
src/Service/UwNodeFieldValue.php
with
22 additions
and
6 deletions
src/Service/UwNodeFieldValue.php
+
22
−
6
View file @
3c49f508
...
...
@@ -86,7 +86,7 @@ class UwNodeFieldValue {
// Long text field type with a text format.
if
(
$type
==
'formatted_text'
)
{
return
$node
->
$field_name
->
getValue
()[
0
]
;
return
$this
->
getFormattedText
(
$node
,
$field_name
)
;
}
// Only content, either layout builder or summary.
...
...
@@ -151,6 +151,25 @@ class UwNodeFieldValue {
}
}
/**
* Function to get the formatted text.
*
* @param \Drupal\node\Entity\Node $node
* The node.
* @param string $field_name
* The name of the field to get.
*
* @return array
* Render array for formatted text.
*/
public
function
getFormattedText
(
Node
$node
,
string
$field_name
):
array
{
return
[
'#type'
=>
'processed_text'
,
'#text'
=>
$node
->
$field_name
->
value
,
'#format'
=>
$node
->
$field_name
->
format
,
];
}
/**
* Function to get catalog tags.
*
...
...
@@ -273,12 +292,9 @@ class UwNodeFieldValue {
*/
public
function
getContentField
(
Node
$node
,
string
$view_mode
,
string
$field_name
)
{
// If on the teaser, return the summary field values.
if
(
$view_mode
==
'teaser'
)
{
return
[
'#type'
=>
'processed_text'
,
'#text'
=>
$node
->
$field_name
->
value
,
'#format'
=>
$node
->
$field_name
->
format
,
];
return
$this
->
getFormattedText
(
$node
,
$field_name
);
}
return
NULL
;
...
...
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