/** * Form submission handler for the 'cancel' action. * * @param array $form * An associative array containing the structure of the form. * @param array $form_state * A reference to a keyed array containing the current state of the form. */ public function cancel(array $form, array &$form_state) { // Remove this view from cache so edits will be lost. $view = $this->entity; $this->tempStore->delete($view->id()); $form_state['redirect_route']['route_name'] = 'views_ui.list'; }
/** * Form submission handler for the 'cancel' action. * * @param array $form * An associative array containing the structure of the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ public function cancel(array $form, FormStateInterface $form_state) { // Remove this view from cache so edits will be lost. $view = $this->entity; $this->tempStore->delete($view->id()); $form_state->setRedirect('views_ui.list'); }
/** * Tests the deleteIfOwner() method. * * @covers ::deleteIfOwner() */ public function testDeleteIfOwner() { $this->lock->expects($this->once())->method('acquire')->with('test_2')->will($this->returnValue(TRUE)); $this->keyValue->expects($this->at(0))->method('get')->with('test_1')->will($this->returnValue(FALSE)); $this->keyValue->expects($this->at(1))->method('get')->with('test_2')->will($this->returnValue($this->ownObject)); $this->keyValue->expects($this->at(2))->method('delete')->with('test_2'); $this->keyValue->expects($this->at(3))->method('get')->with('test_3')->will($this->returnValue($this->otherObject)); $this->assertTrue($this->tempStore->deleteIfOwner('test_1')); $this->assertTrue($this->tempStore->deleteIfOwner('test_2')); $this->assertFalse($this->tempStore->deleteIfOwner('test_3')); }
/** * Form submission handler for the Preview button. */ public function submitPreview($form, FormStateInterface $form_state) { // Rebuild the form with a pristine $view object. $view = $this->entity; // Attempt to load the view from temp store, otherwise create a new one. if (!($new_view = $this->tempStore->get($view->id()))) { $new_view = new ViewUI($view); } $form_state['build_info']['args'][0] = $new_view; $form_state['show_preview'] = TRUE; $form_state['rebuild'] = TRUE; }
/** * {@inheritdoc} */ public function submit(array $form, FormStateInterface $form_state) { $this->tempStore->delete($this->entity->id()); $form_state->setRedirectUrl($this->entity->urlInfo('edit-form')); drupal_set_message($this->t('The lock has been broken and you may now edit this view.')); }
/** * {@inheritdoc} */ public function executeMultiple(array $entities) { $this->tempStore->set(\Drupal::currentUser()->id(), $entities); }
/** * {@inheritdoc} */ public function submit(array $form, array &$form_state) { $this->tempStore->delete($this->entity->id()); $form_state['redirect_route'] = $this->entity->urlInfo('edit-form'); drupal_set_message($this->t('The lock has been broken and you may now edit this view.')); }
/** * {@inheritdoc} */ public function executeMultiple(array $entities) { $this->tempStore->set($this->user->id(), $entities); }