- 🇫🇷France fmb Perpinyà, Catalonia, EU
For those wondering how to use this feature: give your own event a priority lower than 100 (CASAttributeAlterEventSubscriber), get existing attributes ($event->getAttributes()), and then add your own before passing them to $event->setAttributes().
- 🇦🇺Australia elc
@FMB Would you be willing to provide a working example?
There is a request on #3311038: How to get term name instead of tid in the released attributes? →
The other possibility was https://www.drupal.org/project/cas_attributes →
- 🇫🇷France fmb Perpinyà, Catalonia, EU
@FMB Would you be willing to provide a working example?
Something like that:
namespace Drupal\mymodule\EventSubscriber; use Drupal\cas_server\Event\CASAttributesAlterEvent; use Drupal\Core\Database\Connection; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Pass profile UUIDs as CAS attributes. * * @see \Drupal\cas_server\EventSubscriber\CASAttributeAlterEventSubscriber */ class CasAttributes implements EventSubscriberInterface { /** * Connection to database. * * @var \Drupal\Core\Database\Connection */ protected Connection $database; /** * Constructor. * * @param \Drupal\Core\Database\Connection $database * Database connection. */ public function __construct(Connection $database) { $this->database = $database; } /** * {@inheritdoc} */ public static function getSubscribedEvents() { return [ CASAttributesAlterEvent::CAS_ATTRIBUTES_ALTER_EVENT => [ 'onCasAttributesAlter', // Lower than CASAttributeAlterEventSubscriber, so we can add // attributes. 50, ], ]; } /** * Actually alter CAS attributes. */ public function onCasAttributesAlter(CASAttributesAlterEvent $event) { $attributes = $event->getAttributes(); $bundles = ['bundle1', 'bundle2']; $uuids = $this->database ->select('profile', 'p') ->fields('p', ['type', 'uuid']) ->condition('uid', $event->getUser()->id()) ->condition('type', $bundles, 'IN') ->execute() ->fetchAllKeyed(); $attributes += $uuids; $event->setAttributes($attributes); } }
The other possibility was https://www.drupal.org/project/cas_attributes →
This module is installed on the client side. My purpose here was to pass additional CAS attributes from the server to its clients.