You are here

function course_clone_warning_messages in Course 3.x

Same name and namespace in other branches
  1. 8.3 includes/course.exporting.inc \course_clone_warning_messages()
  2. 8.2 includes/course.exporting.inc \course_clone_warning_messages()
  3. 6 includes/course.exporting.inc \course_clone_warning_messages()
  4. 7.2 includes/course.exporting.inc \course_clone_warning_messages()
  5. 7 includes/course.exporting.inc \course_clone_warning_messages()

Show warning messages for a Course.

Parameters

Course $course:

2 calls to course_clone_warning_messages()
course_clone_node_alter in includes/course.exporting.inc
Implements hook_clone_node_alter().
course_node_export_node_alter in includes/course.exporting.inc
Implements hook_node_export_node_alter().

File

includes/course.exporting.inc, line 22

Code

function course_clone_warning_messages($course) {
  $messages = array();
  foreach ($course
    ->getObjects() as $courseObject) {
    $warning = $courseObject
      ->getCloneAbility();
    if ($warning === FALSE) {
      $messages[] = t('The course object %object cannot be cloned. A new instance will be created.', array(
        '%object' => $courseObject
          ->getTitle(),
      ));
    }
    if (is_string($warning)) {
      $messages[] = $warning;
    }
  }
  $messages[] = t('Cloned course objects that reference an existing course object in this course will need to be updated to reference the newly cloned course object.');
  if ($messages) {
    \Drupal::messenger()
      ->addWarning(filter_xss_admin(theme('item_list', array(
      'items' => $messages,
      'title' => t('Cloning issues'),
    ))));
  }
}