flashpoint_message-8.x-1.x-dev/modules/flashpoint_course_join_message/flashpoint_course_join_message.module

modules/flashpoint_course_join_message/flashpoint_course_join_message.module
<?php

/**
 * @file
 * Holds hook implementation for the Flashpoint Message module.
 */

use Drupal\Core\Entity\ContentEntityBase;
use Drupal\flashpoint_course_content\Entity\FlashpointCourseContent;
use Drupal\comment\Entity\Comment;
use Drupal\group\Entity\GroupContent;
use Drupal\message\Entity\Message;

/**
 * Implements hook_node_insert().
 */
function flashpoint_course_join_message_group_content_insert(GroupContent $group_content) {
  $gtype = $group_content->getContentPlugin()->getGroupTypeId();
  $gctype = $group_content->getGroupContentType()->getContentPlugin()->getPluginId();
  if ($gtype === 'flashpoint_course' && $gctype === 'group_membership') {
    $message_data = [
      'template' => 'flashpoint_course_join',
      'field_flashpoint_group' => $group_content->getGroup()->id(),
      'field_flashpoint_m_arg_user' => $group_content->getEntity()->id(),
    ];
    $message = Message::create($message_data);
    $message->save();
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc