Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WCMS
uw_cfg_common
Commits
53d6cfa4
Commit
53d6cfa4
authored
Mar 07, 2022
by
Chris Shantz
Browse files
Merge branch '1.0.x' into prod/1.0.x
parents
f2ab5cbf
2e90e6c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Service/UWService.php
View file @
53d6cfa4
...
...
@@ -109,7 +109,7 @@ class UWService implements UWServiceInterface {
/**
* {@inheritDoc}
*/
public
function
prepareResponsiveImage
(
EntityInterface
$entity
,
string
$image_style
):
array
{
public
function
prepareResponsiveImage
(
?
EntityInterface
$entity
,
string
$image_style
):
array
{
// Ensure that we can load an entity on the media.
if
(
$entity
&&
isset
(
$entity
->
field_media_image
->
entity
))
{
...
...
@@ -125,7 +125,7 @@ class UWService implements UWServiceInterface {
// Set the alt for the image.
$variables
[
'alt'
]
=
$entity
->
field_media_image
->
alt
;
// Th
ese
is a function from the responsive image module that sets all
// Th
is
is a function from the responsive image module that sets all
// the variables for the sources of the responsive image.
template_preprocess_responsive_image
(
$variables
);
...
...
src/Service/UWServiceInterface.php
View file @
53d6cfa4
...
...
@@ -38,7 +38,7 @@ interface UWServiceInterface {
* @return array
* Array with details for responsive image.
*/
public
function
prepareResponsiveImage
(
EntityInterface
$entity
,
string
$image_style
):
array
;
public
function
prepareResponsiveImage
(
?
EntityInterface
$entity
,
string
$image_style
):
array
;
/**
* Get the UW images styles used in UW responsive image.
...
...
uw_cfg_common.module
View file @
53d6cfa4
...
...
@@ -13,6 +13,7 @@ use Drupal\Core\Render\Element;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\Core\Url
;
use
Drupal\media_library
\
MediaLibraryState
;
use
Drupal\user\UserInterface
;
use
Drupal\uw_cfg_common
\
Service\UWService
;
use
Drupal\webform\WebformInterface
;
use
Drupal\webform\WebformSubmissionStorageInterface
;
...
...
@@ -1085,3 +1086,29 @@ function uw_cfg_common_entity_type_alter(array &$entity_types) {
// Add validation constraint to the node entity.
$entity_types
[
'node'
]
->
addConstraint
(
'UwMedia'
);
}
/**
* Implements hook_simplesamlphp_auth_user_attributes().
*
* Add role expiry records for all roles populated automatically from
* simpleSAMLphp attributes by simplesamlphp_auth module.
*/
function
uw_cfg_common_simplesamlphp_auth_user_attributes
(
UserInterface
$account
,
array
$attributes
):
bool
{
// Get the SimplesamlphpDrupalAuth service.
$drupalauth
=
\
Drupal
::
service
(
'simplesamlphp_auth.drupalauth'
);
$roles_to_expire
=
$drupalauth
->
getMatchingRoles
();
// Get the role_expire API.
$role_expire
=
\
Drupal
::
service
(
'role_expire.api'
);
$expiry_timestamp
=
time
()
+
24
*
60
*
60
;
foreach
(
$roles_to_expire
as
$rid
)
{
// Add role_expiry for the account.
$role_expire
->
writeRecord
(
$account
->
id
(),
$rid
,
$expiry_timestamp
);
}
// This implementation does not alter $account, so return is always FALSE.
return
FALSE
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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