class BanIpManager in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/ban/src/BanIpManager.php \Drupal\ban\BanIpManager
Ban IP manager.
Hierarchy
- class \Drupal\ban\BanIpManager implements BanIpManagerInterface
Expanded class hierarchy of BanIpManager
1 string reference to 'BanIpManager'
- ban.services.yml in core/modules/ ban/ ban.services.yml 
- core/modules/ban/ban.services.yml
1 service uses BanIpManager
- ban.ip_manager in core/modules/ ban/ ban.services.yml 
- Drupal\ban\BanIpManager
File
- core/modules/ ban/ src/ BanIpManager.php, line 15 
- Contains \Drupal\ban\BanIpManager.
Namespace
Drupal\banView source
class BanIpManager implements BanIpManagerInterface {
  /**
   * The database connection used to check the IP against.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $connection;
  /**
   * Construct the BanSubscriber.
   *
   * @param \Drupal\Core\Database\Connection $connection
   *   The database connection which will be used to check the IP against.
   */
  public function __construct(Connection $connection) {
    $this->connection = $connection;
  }
  /**
   * {@inheritdoc}
   */
  public function isBanned($ip) {
    return (bool) $this->connection
      ->query("SELECT * FROM {ban_ip} WHERE ip = :ip", array(
      ':ip' => $ip,
    ))
      ->fetchField();
  }
  /**
   * {@inheritdoc}
   */
  public function findAll() {
    return $this->connection
      ->query('SELECT * FROM {ban_ip}');
  }
  /**
   * {@inheritdoc}
   */
  public function banIp($ip) {
    $this->connection
      ->insert('ban_ip')
      ->fields(array(
      'ip' => $ip,
    ))
      ->execute();
  }
  /**
   * {@inheritdoc}
   */
  public function unbanIp($id) {
    $this->connection
      ->delete('ban_ip')
      ->condition('ip', $id)
      ->execute();
  }
  /**
   * {@inheritdoc}
   */
  public function findById($ban_id) {
    return $this->connection
      ->query("SELECT ip FROM {ban_ip} WHERE iid = :iid", array(
      ':iid' => $ban_id,
    ))
      ->fetchField();
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| BanIpManager:: | protected | property | The database connection used to check the IP against. | |
| BanIpManager:: | public | function | Bans an IP address. Overrides BanIpManagerInterface:: | |
| BanIpManager:: | public | function | Finds all banned IP addresses. Overrides BanIpManagerInterface:: | |
| BanIpManager:: | public | function | Finds a banned IP address by its ID. Overrides BanIpManagerInterface:: | |
| BanIpManager:: | public | function | Returns if this IP address is banned. Overrides BanIpManagerInterface:: | |
| BanIpManager:: | public | function | Unbans an IP address. Overrides BanIpManagerInterface:: | |
| BanIpManager:: | public | function | Construct the BanSubscriber. | 
