Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 14 |
| ShortcutForm | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 14 |
| save | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 14 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\shortcut\ShortcutForm. | |
| */ | |
| namespace Drupal\shortcut; | |
| use Drupal\Core\Entity\ContentEntityForm; | |
| use Drupal\Core\Form\FormStateInterface; | |
| /** | |
| * Form controller for the shortcut entity forms. | |
| */ | |
| class ShortcutForm extends ContentEntityForm { | |
| /** | |
| * The entity being used by this form. | |
| * | |
| * @var \Drupal\shortcut\ShortcutInterface | |
| */ | |
| protected $entity; | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function save(array $form, FormStateInterface $form_state) { | |
| $entity = $this->entity; | |
| $status = $entity->save(); | |
| if ($status == SAVED_UPDATED) { | |
| $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->getTitle())); | |
| } | |
| drupal_set_message($message); | |
| $form_state->setRedirect( | |
| 'entity.shortcut_set.customize_form', | |
| array('shortcut_set' => $entity->bundle()) | |
| ); | |
| } | |
| } |