diff --git a/controllers/internals/Phone.php b/controllers/internals/Phone.php index bec57d3..8a77167 100755 --- a/controllers/internals/Phone.php +++ b/controllers/internals/Phone.php @@ -65,10 +65,10 @@ namespace controllers\internals; * @param int $id_user : User to insert phone for * @param string $number : The number of 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 */ - 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 = [ 'id_user' => $id_user, diff --git a/controllers/publics/Phone.php b/controllers/publics/Phone.php index e492572..97a9672 100755 --- a/controllers/publics/Phone.php +++ b/controllers/publics/Phone.php @@ -101,7 +101,7 @@ class Phone extends \descartes\Controller * @param $csrf : CSRF token * @param string $_POST['number'] : Phone number * @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) { @@ -114,7 +114,7 @@ class Phone extends \descartes\Controller $id_user = $_SESSION['user']['id']; $number = $_POST['number'] ?? 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) { @@ -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.'); return $this->redirect(\descartes\Router::url('Phone', 'add'));