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
e4d5ad7a
Commit
e4d5ad7a
authored
4 years ago
by
Liam Morland
Browse files
Options
Downloads
Patches
Plain Diff
Coding standards
parent
d8cecfe1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Service/UWService.php
+19
-14
19 additions, 14 deletions
src/Service/UWService.php
src/Service/UWServiceInterface.php
+5
-1
5 additions, 1 deletion
src/Service/UWServiceInterface.php
uw_cfg_common.module
+4
-3
4 additions, 3 deletions
uw_cfg_common.module
with
28 additions
and
18 deletions
src/Service/UWService.php
+
19
−
14
View file @
e4d5ad7a
...
...
@@ -3,11 +3,10 @@
namespace
Drupal\uw_cfg_common\Service
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\node\Entity\Node
;
use
Drupal\node\NodeInterface
;
/**
* Class UWService
* Class UWService
.
*
* @package Drupal\uw_cfg_common\Service
*/
...
...
@@ -46,14 +45,16 @@ class UWService implements UWServiceInterface {
}
/**
* {@inheritDoc}
*/
* {@inheritDoc}
*/
public
function
getTeaserContent
(
NodeInterface
$node
,
array
$variables_to_get
,
string
$teaser_type
):
array
{
// Step through each of the variables to get and set the variables for the teaser content.
// Step through each of the variables to get and set the variables for the
// teaser content.
foreach
(
$variables_to_get
as
$variable_to_get
)
{
// Switch on the variable to get and set the variables for the teaser content.
// Switch on the variable to get and set the variables for the teaser
// content.
switch
(
$variable_to_get
)
{
case
'title'
:
...
...
@@ -74,8 +75,9 @@ class UWService implements UWServiceInterface {
// field_uw_<content_type>_date.
$field_name
=
'field_uw_'
.
trim
(
$teaser_type
)
.
'_date'
;
// Set the date variable, once returned to the calling function, they can
// change the date format as required (i.e. change it to long-date or date-time).
// Set the date variable, once returned to the calling function, they
// can change the date format as required (i.e. change it to long-date
// or date-time).
$variables
[
'date'
]
=
$node
->
$field_name
->
getString
();
break
;
...
...
@@ -104,7 +106,8 @@ class UWService implements UWServiceInterface {
// Ensure that we have an image before adding variables.
if
(
$image
!==
NULL
)
{
// Get all the image variables, including the sources using the prepareResponsiveImage function.
// Get all the image variables, including the sources using the
// prepareResponsiveImage function.
$image_variables
=
$this
->
prepareResponsiveImage
(
$image
,
'uw_ris_media'
);
// Set the responsive image variables for the teaser content.
...
...
@@ -116,7 +119,8 @@ class UWService implements UWServiceInterface {
case
'tags'
:
// Set the field name for the tags which is field_uw_<content_type>_tags'.
// Set the field name for the tags which is
// field_uw_<content_type>_tags.
$field_name
=
'field_uw_'
.
trim
(
$teaser_type
)
.
'_tags'
;
// Get all the taxonomy terms for the blog.
...
...
@@ -133,12 +137,13 @@ class UWService implements UWServiceInterface {
case
'content'
:
// Set the field name for the summary, which is field_name<content_type>_summary.
// Set the field name for the summary, which is
// field_name<content_type>_summary.
$field_name
=
'field_uw_'
.
$teaser_type
.
'_summary'
;
// Set the render array for the summary, we simply can not just send
the
// value as Drupal will just render it with no filters or HTML
applied.
// We need to send the full render array.
// Set the render array for the summary, we simply can not just send
//
the
value as Drupal will just render it with no filters or HTML
//
applied.
We need to send the full render array.
$variables
[
'content'
]
=
[
'#type'
=>
'processed_text'
,
'#text'
=>
$node
->
$field_name
->
value
,
...
...
This diff is collapsed.
Click to expand it.
src/Service/UWServiceInterface.php
+
5
−
1
View file @
e4d5ad7a
...
...
@@ -4,6 +4,9 @@ namespace Drupal\uw_cfg_common\Service;
use
Drupal\Core\Entity\EntityInterface
;
/**
* Interface for UW services.
*/
interface
UWServiceInterface
{
/**
...
...
@@ -15,7 +18,8 @@ interface UWServiceInterface {
* Image style to be used for responsive image.
*
* @return array
*
Array with details for responsive image.
* Array with details for responsive image.
*/
public
function
prepareResponsiveImage
(
EntityInterface
$entity
,
string
$image_style
):
array
;
}
This diff is collapsed.
Click to expand it.
uw_cfg_common.module
+
4
−
3
View file @
e4d5ad7a
...
...
@@ -152,9 +152,10 @@ function uw_cfg_common_toolbar_alter(&$items) {
// Get the roles of the user.
$roles
=
$current_user
->
getRoles
();
// If there is only 1 role and that first role is authenticated, remove the manage link.
// If there are multiple roles then we know that they will have the Manage link, we are
// only removing the manage link for strictly authenticated users only.
// If there is only 1 role and that first role is authenticated, remove the
// manage link. If there are multiple roles then we know that they will have
// the Manage link, we are only removing the manage link for strictly
// authenticated users only.
if
(
count
(
$roles
)
==
1
&&
$roles
[
0
]
==
'authenticated'
)
{
// Remove the manage link.
...
...
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