/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $form['path'] = array('#type' => 'textfield', '#title' => t('Path'), '#size' => 40, '#maxlength' => 255, '#field_prefix' => $this->url('<front>', array(), array('absolute' => TRUE)), '#default_value' => $this->entity->path->value); $form['langcode'] = array('#title' => t('Language'), '#type' => 'language_select', '#default_value' => $this->entity->getUntranslated()->language()->id, '#languages' => LanguageInterface::STATE_ALL); return $form; }
/** * Deletes the selected shortcut. * * @param \Drupal\shortcut\ShortcutInterface $shortcut * The shortcut to delete. * * @return \Symfony\Component\HttpFoundation\RedirectResponse * A redirect to the previous location or the front page when destination * is not set. */ public function deleteShortcutLinkInline(ShortcutInterface $shortcut) { $label = $shortcut->label(); try { $shortcut->delete(); drupal_set_message($this->t('The shortcut %title has been deleted.', array('%title' => $label))); } catch (\Exception $e) { drupal_set_message($this->t('Unable to delete the shortcut for %title.', array('%title' => $label)), 'error'); } return $this->redirect('<front>'); }
/** * Sort shortcut objects. * * Callback for uasort(). * * @param \Drupal\shortcut\ShortcutInterface $a * First item for comparison. * @param \Drupal\shortcut\ShortcutInterface $b * Second item for comparison. * * @return int * The comparison result for uasort(). */ public static function sort(ShortcutInterface $a, ShortcutInterface $b) { $a_weight = $a->getWeight(); $b_weight = $b->getWeight(); if ($a_weight == $b_weight) { return strnatcasecmp($a->getTitle(), $b->getTitle()); } return $a_weight < $b_weight ? -1 : 1; }