Fix phone data to never be null
This commit is contained in:
parent
89459a0285
commit
857f953a04
|
@ -65,10 +65,10 @@ namespace controllers\internals;
|
||||||
* @param int $id_user : User to insert phone for
|
* @param int $id_user : User to insert phone for
|
||||||
* @param string $number : The number of the phone
|
* @param string $number : The number of the phone
|
||||||
* @param string $adapter : The adapter to use the phone
|
* @param string $adapter : The adapter to use the phone
|
||||||
* @param ?string json $adapter_datas : A JSON string representing adapter's datas (for example credentials for an api)
|
* @param string json $adapter_datas : A JSON string representing adapter's datas (for example credentials for an api)
|
||||||
* @return bool : false on error, true on success
|
* @return bool : false on error, true on success
|
||||||
*/
|
*/
|
||||||
public function create (int $id_user, string $number, string $adapter, ?string $adapter_datas) : bool
|
public function create (int $id_user, string $number, string $adapter, string $adapter_datas) : bool
|
||||||
{
|
{
|
||||||
$phone = [
|
$phone = [
|
||||||
'id_user' => $id_user,
|
'id_user' => $id_user,
|
||||||
|
|
|
@ -101,7 +101,7 @@ class Phone extends \descartes\Controller
|
||||||
* @param $csrf : CSRF token
|
* @param $csrf : CSRF token
|
||||||
* @param string $_POST['number'] : Phone number
|
* @param string $_POST['number'] : Phone number
|
||||||
* @param string $_POST['adapter'] : Phone adapter
|
* @param string $_POST['adapter'] : Phone adapter
|
||||||
* @param boolean $_POST['adapter_datas'] : Phone adapter datas
|
* @param string $_POST['adapter_datas'] : Phone adapter datas
|
||||||
*/
|
*/
|
||||||
public function create($csrf)
|
public function create($csrf)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +114,7 @@ class Phone extends \descartes\Controller
|
||||||
$id_user = $_SESSION['user']['id'];
|
$id_user = $_SESSION['user']['id'];
|
||||||
$number = $_POST['number'] ?? false;
|
$number = $_POST['number'] ?? false;
|
||||||
$adapter = $_POST['adapter'] ?? false;
|
$adapter = $_POST['adapter'] ?? false;
|
||||||
$adapter_datas = !empty($_POST['adapter_datas']) ? $_POST['adapter_datas'] : null;
|
$adapter_datas = !empty($_POST['adapter_datas']) ? $_POST['adapter_datas'] : '{}';
|
||||||
|
|
||||||
if (!$number || !$adapter)
|
if (!$number || !$adapter)
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,7 @@ class Phone extends \descartes\Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (NULL !== $adapter_datas && NULL === json_decode($adapter_datas))
|
if (NULL === json_decode($adapter_datas))
|
||||||
{
|
{
|
||||||
\FlashMessage\FlashMessage::push('danger', 'La chaîne de configuration n\'est pas valide.');
|
\FlashMessage\FlashMessage::push('danger', 'La chaîne de configuration n\'est pas valide.');
|
||||||
return $this->redirect(\descartes\Router::url('Phone', 'add'));
|
return $this->redirect(\descartes\Router::url('Phone', 'add'));
|
||||||
|
|
Loading…
Reference in New Issue