Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function save(array $form, array &$form_state)
 {
     foreach ($this->entity->getShortcuts() as $shortcut) {
         $shortcut->setWeight($form_state['values']['shortcuts']['links'][$shortcut->id()]['weight']);
         $shortcut->save();
     }
     drupal_set_message(t('The shortcut set has been updated.'));
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     foreach ($this->entity->getShortcuts() as $shortcut) {
         $weight = $form_state->getValue(array('shortcuts', 'links', $shortcut->id(), 'weight'));
         $shortcut->setWeight($weight);
         $shortcut->save();
     }
     drupal_set_message(t('The shortcut set has been updated.'));
 }
Beispiel #3
0
 /**
  * Extracts information from shortcut set links.
  *
  * @param \Drupal\shortcut\ShortcutSetInterface $set
  *   The shortcut set object to extract information from.
  * @param string $key
  *   The array key indicating what information to extract from each link:
  *    - 'title': Extract shortcut titles.
  *    - 'path': Extract shortcut paths.
  *    - 'id': Extract the shortcut ID.
  *
  * @return array
  *   Array of the requested information from each link.
  */
 function getShortcutInformation(ShortcutSetInterface $set, $key)
 {
     $info = array();
     \Drupal::entityManager()->getStorage('shortcut')->resetCache();
     foreach ($set->getShortcuts() as $shortcut) {
         $info[] = $shortcut->{$key}->value;
     }
     return $info;
 }