diff --git a/core/modules/ban/lib/Drupal/ban/BanIpManager.php b/core/modules/ban/lib/Drupal/ban/BanIpManager.php index c65ee8f90ce..3e6028cde3e 100644 --- a/core/modules/ban/lib/Drupal/ban/BanIpManager.php +++ b/core/modules/ban/lib/Drupal/ban/BanIpManager.php @@ -12,7 +12,7 @@ use Drupal\Core\Database\Connection; /** * Ban IP manager. */ -class BanIpManager { +class BanIpManager implements BanIpManagerInterface { /** * The database connection used to check the IP against. @@ -32,33 +32,21 @@ class BanIpManager { } /** - * Returns if this IP address is banned. - * - * @param string $ip - * The IP address to check. - * - * @return bool - * TRUE if the IP address is banned, FALSE otherwise. + * {@inheritdoc} */ public function isBanned($ip) { return (bool) $this->connection->query("SELECT * FROM {ban_ip} WHERE ip = :ip", array(':ip' => $ip))->fetchField(); } /** - * Finds all banned IP addresses. - * - * @return \Drupal\Core\Database\StatementInterface - * The result of the database query. + * {@inheritdoc} */ public function findAll() { return $this->connection->query('SELECT * FROM {ban_ip}'); } /** - * Bans an IP address. - * - * @param string $ip - * The IP address to ban. + * {@inheritdoc} */ public function banIp($ip) { $this->connection->insert('ban_ip') @@ -67,10 +55,7 @@ class BanIpManager { } /** - * Unbans an IP address. - * - * @param string $id - * The IP address to unban. + * {@inheritdoc} */ public function unbanIp($id) { $this->connection->delete('ban_ip') @@ -79,16 +64,9 @@ class BanIpManager { } /** - * Finds a banned IP address by its ID. - * - * @param int $ban_id - * The ID for a banned IP address. - * - * @return string|false - * Either the banned IP address or FALSE if none exist with that ID. + * {@inheritdoc} */ public function findById($ban_id) { return $this->connection->query("SELECT ip FROM {ban_ip} WHERE iid = :iid", array(':iid' => $ban_id))->fetchField(); } - } diff --git a/core/modules/ban/lib/Drupal/ban/BanIpManagerInterface.php b/core/modules/ban/lib/Drupal/ban/BanIpManagerInterface.php new file mode 100755 index 00000000000..331554b01f8 --- /dev/null +++ b/core/modules/ban/lib/Drupal/ban/BanIpManagerInterface.php @@ -0,0 +1,61 @@ +manager = $manager; } diff --git a/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php b/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php index bfaeb7ac258..bc83c541026 100644 --- a/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php +++ b/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php @@ -8,7 +8,7 @@ namespace Drupal\ban\Form; use Drupal\Core\Form\FormBase; -use Drupal\ban\BanIpManager; +use Drupal\ban\BanIpManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -17,16 +17,16 @@ use Symfony\Component\DependencyInjection\ContainerInterface; class BanAdmin extends FormBase { /** - * @var \Drupal\ban\BanIpManager + * @var \Drupal\ban\BanIpManagerInterface */ protected $ipManager; /** * Constructs a new BanAdmin object. * - * @param \Drupal\ban\BanIpManager $ip_manager + * @param \Drupal\ban\BanIpManagerInterface $ip_manager */ - public function __construct(BanIpManager $ip_manager) { + public function __construct(BanIpManagerInterface $ip_manager) { $this->ipManager = $ip_manager; } diff --git a/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php b/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php index e8fce2ed9cf..69b6e90df49 100644 --- a/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php +++ b/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php @@ -8,7 +8,7 @@ namespace Drupal\ban\Form; use Drupal\Core\Form\ConfirmFormBase; -use Drupal\ban\BanIpManager; +use Drupal\ban\BanIpManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -27,10 +27,10 @@ class BanDelete extends ConfirmFormBase { /** * Constructs a new BanDelete object. * - * @param \Drupal\ban\BanIpManager $ip_manager + * @param \Drupal\ban\BanIpManagerInterface $ip_manager * The IP manager. */ - public function __construct(BanIpManager $ip_manager) { + public function __construct(BanIpManagerInterface $ip_manager) { $this->ipManager = $ip_manager; }