/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $ip = trim($form_state->getValue('ip')); $this->ipManager->banIp($ip); drupal_set_message($this->t('The IP address %ip has been banned.', array('%ip' => $ip))); $form_state->setRedirect('ban.admin_page'); }
/** * Executes the action with the given context. * * @param string $ip * (optional) The IP address that should be banned. */ protected function doExecute($ip = NULL) { if (!isset($ip)) { $ip = $this->request->getClientIp(); } $this->banManager->banIp($ip); }
/** * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $ip = trim($form_state['values']['ip']); $this->ipManager->banIp($ip); drupal_set_message($this->t('The IP address %ip has been banned.', array('%ip' => $ip))); $form_state['redirect_route']['route_name'] = 'ban.admin_page'; }
/** * Tests the action execution without Context IP set. * * Should fallback to the current IP of the request. * * @covers ::execute */ public function testActionExecutionWithoutContextIP() { // TEST-NET-1 IPv4. $ip = '192.0.2.0'; $this->request->getClientIp()->willReturn($ip)->shouldBeCalledTimes(1); $this->banManager->banIp($ip)->shouldBeCalledTimes(1); $this->action->execute(); }
/** * {@inheritdoc} */ public function import(Row $row, array $old_destination_id_values = array()) { $this->banManager->banIp($row->getDestinationProperty('ip')); }