public function BlockCountry::evaluate in Block Country 8
Evaluates the condition and returns TRUE or FALSE accordingly.
Return value
bool TRUE if the condition has been met, FALSE otherwise.
Overrides ConditionInterface::evaluate
File
- src/
Plugin/ Condition/ BlockCountry.php, line 112
Class
- BlockCountry
- Provides a 'Country' condition.
Namespace
Drupal\block_country\Plugin\ConditionCode
public function evaluate() {
if (empty($this->configuration['country_list']) && $this->configuration['negate'] == False) {
return True;
}
else {
$ip = $this->requestStack
->getCurrentRequest()
->getClientIp();
$ret = true;
if ($country = $this->ip2CountryLookUp
->getCountry($ip)) {
if (!in_array($country, $this->configuration['country_list'])) {
$ret = false;
}
}
else {
$ret = false;
}
return $ret;
}
}