Skip to content
Snippets Groups Projects
Commit d6555f26 authored by catch's avatar catch
Browse files

Issue #2030657 by ceng, marvin_B8, daffie: Expand Shortcut with methods.

parent d5f73ee0
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -111,7 +111,7 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr
public function resetLinkWeights() {
$weight = -50;
foreach ($this->getShortcuts() as $shortcut) {
$shortcut->weight->value = ++$weight;
$shortcut->setWeight(++$weight);
$shortcut->save();
}
......
......@@ -70,13 +70,13 @@ public function form(array $form, array &$form_state) {
foreach ($shortcuts as $shortcut) {
$id = $shortcut->id();
$form['shortcuts']['links'][$id]['#attributes']['class'][] = 'draggable';
$form['shortcuts']['links'][$id]['name']['#markup'] = l($shortcut->title->value, $shortcut->path->value);
$form['shortcuts']['links'][$id]['#weight'] = $shortcut->weight->value;
$form['shortcuts']['links'][$id]['name']['#markup'] = l($shortcut->getTitle(), $shortcut->path->value);
$form['shortcuts']['links'][$id]['#weight'] = $shortcut->getWeight();
$form['shortcuts']['links'][$id]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for @title', array('@title' => $shortcut->title->value)),
'#title' => t('Weight for @title', array('@title' => $shortcut->getTitle())),
'#title_display' => 'invisible',
'#default_value' => $shortcut->weight->value,
'#default_value' => $shortcut->getWeight(),
'#attributes' => array('class' => array('shortcut-weight')),
);
......@@ -121,7 +121,7 @@ protected function actions(array $form, array &$form_state) {
public function save(array $form, array &$form_state) {
$shortcuts = $this->storageController->loadByProperties(array('shortcut_set' => $this->entity->id()));
foreach ($shortcuts as $shortcut) {
$shortcut->weight->value = $form_state['values']['shortcuts']['links'][$shortcut->id()]['weight'];
$shortcut->setWeight($form_state['values']['shortcuts']['links'][$shortcut->id()]['weight']);
$shortcut->save();
}
drupal_set_message(t('The shortcut set has been updated.'));
......
......@@ -83,7 +83,7 @@ public function form(array $form, array &$form_state) {
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $entity->title->value,
'#default_value' => $entity->getTitle(),
'#size' => 40,
'#maxlength' => 255,
'#required' => TRUE,
......@@ -154,10 +154,10 @@ public function save(array $form, array &$form_state) {
$entity->save();
if ($entity->isNew()) {
$message = $this->t('The shortcut %link has been updated.', array('%link' => $entity->title->value));
$message = $this->t('The shortcut %link has been updated.', array('%link' => $entity->getTitle()));
}
else {
$message = $this->t('Added a shortcut for %title.', array('%title' => $entity->title->value));
$message = $this->t('Added a shortcut for %title.', array('%title' => $entity->getTitle()));
}
drupal_set_message($message);
......
......@@ -111,7 +111,7 @@ public function testShortcutLinkChangePath() {
$shortcuts = $set->getShortcuts();
$shortcut = reset($shortcuts);
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title' => $shortcut->title->value, 'path' => $new_link_path), t('Save'));
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title' => $shortcut->getTitle(), 'path' => $new_link_path), t('Save'));
$saved_set = shortcut_set_load($set->id());
$paths = $this->getShortcutInformation($saved_set, 'path');
$this->assertTrue(in_array($new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment