public function RuleFormController::save in JS injector 8
File
- lib/Drupal/js_injector/RuleFormController.php, line 135
- Contains \Drupal\js_injector\RuleFormController.
Class
- RuleFormController
- Form controller for the shortcut set entity edit forms.
Namespace
Drupal\js_injector
Code
public function save(array $form, array &$form_state) {
$entity = $this->entity;
$entity
->set('label', trim($entity
->get('label')));
if ($entity
->get('preprocess')) {
$entity
->set('inline', 0);
}
$file_written = file_unmanaged_save_data($entity
->get('js'), _js_injector_rule_uri($entity
->id()), FILE_EXISTS_REPLACE);
$url = $entity
->url();
if ($entity
->save() == SAVED_UPDATED) {
drupal_set_message(t('Rule %label has been updated.', array(
'%label' => $entity
->label(),
)));
watchdog('js_injector', 'Rule %label has been updated.', array(
'%label' => $entity
->label(),
), WATCHDOG_NOTICE, l(t('Edit'), $url));
}
else {
drupal_set_message(t('Rule %label has been added.', array(
'%label' => $entity
->label(),
)));
watchdog('js_injector', 'Rule %label has been added.', array(
'%label' => $entity
->label(),
), WATCHDOG_NOTICE, l(t('Edit'), $url));
}
$form_state['redirect'] = 'admin/config/development/js-injector';
}