/**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     foreach ($this->entity->getGradeLetters() as $grade_letter) {
         $weight = $form_state->getValue(array('grade_letter_sets', 'letters', $grade_letter->id(), 'weight'));
         $grade_letter->setWeight($weight);
         $grade_letter->save();
     }
     drupal_set_message(t('The grade letter set has been updated.'));
 }
示例#2
0
 /**
  * Extracts information from grade letter set links.
  *
  * @param \Drupal\gradebook\GradeLetterSetInterface $set
  *   The grade letter set object to extract information from.
  * @param string $key
  *   The array key indicating what information to extract from each link:
  *    - 'title': Extract shortcut titles.
  *    - 'link': Extract shortcut paths.
  *    - 'id': Extract the shortcut ID.
  *
  * @return array
  *   Array of the requested information from each link.
  */
 function getShortcutInformation(GradeLetterSetInterface $set, $key)
 {
     $info = array();
     \Drupal::entityManager()->getStorage('shortcut')->resetCache();
     foreach ($set->getGradeLetters() as $shortcut) {
         if ($key == 'link') {
             $info[] = $shortcut->link->uri;
         } else {
             $info[] = $shortcut->{$key}->value;
         }
     }
     return $info;
 }
 /**
  * The _title_callback for the entity.grade_letter_set.list_form route.
  *
  * @param \Drupal\gradebook\GradeLetterSetInterface $grade_letter_set
  *   The current grade letter set.
  *
  * @return string
  *   The page title.
  */
 public function pageTitle(GradeLetterSetInterface $grade_letter_set)
 {
     return $this->t('Grade letters: @set', array('@set' => $grade_letter_set->label()));
 }