예제 #1
0
파일: BanAdmin.php 프로젝트: ddrozdik/dmaps
 /**
  * {@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');
 }
예제 #2
0
 /**
  * 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);
 }
예제 #3
0
 /**
  * {@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';
 }
예제 #4
0
 /**
  * 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();
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     $this->banManager->banIp($row->getDestinationProperty('ip'));
 }