mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
[phonenumber validation & format] format and validation does not make the app fail when network is not available
This commit is contained in:
@@ -20,6 +20,7 @@ namespace Chill\MainBundle\Phonenumber;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
|
||||
@@ -182,6 +183,14 @@ class PhonenumberHelper
|
||||
"phonenumber" => $phonenumber
|
||||
]);
|
||||
|
||||
return null;
|
||||
} catch (ConnectException $e) {
|
||||
$this->logger->error("[phonenumber helper] Could not format number "
|
||||
. "due to connect error", [
|
||||
"message" => $e->getMessage(),
|
||||
"phonenumber" => $phonenumber
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -230,6 +239,14 @@ class PhonenumberHelper
|
||||
"phonenumber" => $phonenumber
|
||||
]);
|
||||
|
||||
return null;
|
||||
} catch (ConnectException $e) {
|
||||
$this->logger->error("[phonenumber helper] Could not format number "
|
||||
. "due to connect error", [
|
||||
"message" => $e->getMessage(),
|
||||
"phonenumber" => $phonenumber
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -47,6 +47,6 @@ class Templating extends AbstractExtension
|
||||
|
||||
public function formatPhonenumber($phonenumber)
|
||||
{
|
||||
return $this->phonenumberHelper->format($phonenumber);
|
||||
return $this->phonenumberHelper->format($phonenumber) ?? $phonenumber;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user