getType() === 'page') { // Get the event_dispatcher service using the container. api_affinidi.content_update $eventDispatcher = \Drupal::service('event_dispatcher'); // Create a new ContentEvent object. $event = new ContentEvent($entity); // Dispatch the event. $eventDispatcher->dispatch($event,ContentEventSubscriber::CONTENT_UPDATE_EVENT); } } /** * Implements hook_entity_insert() for node entities. */ function api_affinidi_entity_insert(Drupal\Core\Entity\EntityInterface $entity) { if ($entity instanceof NodeInterface && $entity->getType() === 'page') { // Get the event_dispatcher service using the container. $eventDispatcher = \Drupal::service('event_dispatcher'); // Create a new ContentEvent object. $event = new ContentEvent($entity); // Dispatch the event. $eventDispatcher->dispatch($event, ContentEventSubscriber::CONTENT_CREATE_EVENT); } } /** * Implements hook_entity_delete() for node entities. */ function api_affinidi_entity_delete(Drupal\Core\Entity\EntityInterface $entity) { if ($entity instanceof NodeInterface && $entity->getType() === 'page') { // Get the event_dispatcher service using the container. $eventDispatcher = \Drupal::service('event_dispatcher'); // Create a new ContentEvent object. $event = new ContentEvent($entity); // Dispatch the event. $eventDispatcher->dispatch($event,ContentEventSubscriber::CONTENT_DELETE_EVENT); //\Drupal::service('event_dispatcher')->dispatch($event, SmartIpEvents::GET_CONFIG_NAME); } } /** * Implements hook_form_FORM_ID_alter() for views_exposed_form. */ function api_affinidi_form_views_exposed_form_alter(array &$form, FormState $form_state, $form_id) { // Replace 'your_views_machine_name' with the machine name of your view. if ($form['#id'] === 'views-exposed-form-content-page-1' || $form['#id'] === 'views-exposed-form-home-content-page-1' || $form['#id'] === 'views-exposed-form-block-content-home-page-1' ) { // Replace 'your_filter_field_name' with the name of the exposed filter you want to alter. if (isset($form['type'])) { // Remove the default label from the drop-down filter on the basis of role $user = \Drupal::currentUser(); // Check if the user is logged in. if ($user->isAuthenticated()) { // Get an array of roles assigned to the user. $roles = $user->getRoles(); // You can now work with the $roles array, e.g., check if a specific role exists. if (in_array('content_editor', $roles)) { // User has the 'administrator' role. //$form['type']['#options']['All'] = t(' '); // this will chnage the lable of default drop down... unset($form['type']['#options']['All']); } } } } }