Commit 53d6cfa4 authored by Chris Shantz's avatar Chris Shantz
Browse files

Merge branch '1.0.x' into prod/1.0.x

parents f2ab5cbf 2e90e6c9
......@@ -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;
// These is a function from the responsive image module that sets all
// This 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);
......
......@@ -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.
......
......@@ -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;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment