mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
[phonenumber validation & format] format and validation does not make the app fail when network is not available
This commit is contained in:
parent
e348616d00
commit
7a952d6f88
@ -104,4 +104,4 @@ Branch CRUD-Init
|
|||||||
- module `show_hide`: add the possibility to launch a show hide manually and not on page loading. Useful when show/hide occurs in collection.
|
- module `show_hide`: add the possibility to launch a show hide manually and not on page loading. Useful when show/hide occurs in collection.
|
||||||
- module `show_hide`: add events to module
|
- module `show_hide`: add events to module
|
||||||
- [phonenumber validation] allow to validate against mobile **or** landline/voip phonenumbers;
|
- [phonenumber validation] allow to validate against mobile **or** landline/voip phonenumbers;
|
||||||
|
- [phonenumber validation & format] format and validation does not make the app fail when network is not available;
|
||||||
|
@ -20,6 +20,7 @@ namespace Chill\MainBundle\Phonenumber;
|
|||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use GuzzleHttp\Exception\ServerException;
|
use GuzzleHttp\Exception\ServerException;
|
||||||
|
use GuzzleHttp\Exception\ConnectException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Psr\Cache\CacheItemPoolInterface;
|
use Psr\Cache\CacheItemPoolInterface;
|
||||||
|
|
||||||
@ -182,6 +183,14 @@ class PhonenumberHelper
|
|||||||
"phonenumber" => $phonenumber
|
"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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,6 +239,14 @@ class PhonenumberHelper
|
|||||||
"phonenumber" => $phonenumber
|
"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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,6 @@ class Templating extends AbstractExtension
|
|||||||
|
|
||||||
public function formatPhonenumber($phonenumber)
|
public function formatPhonenumber($phonenumber)
|
||||||
{
|
{
|
||||||
return $this->phonenumberHelper->format($phonenumber);
|
return $this->phonenumberHelper->format($phonenumber) ?? $phonenumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user