diff options
Diffstat (limited to 'src/controller/HeadFootController.php')
| -rw-r--r-- | src/controller/HeadFootController.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/controller/HeadFootController.php b/src/controller/HeadFootController.php index d3e75ee..ffa33bc 100644 --- a/src/controller/HeadFootController.php +++ b/src/controller/HeadFootController.php | |||
| @@ -9,6 +9,8 @@ use Doctrine\ORM\EntityManager; | |||
| 9 | 9 | ||
| 10 | class HeadFootController | 10 | class HeadFootController |
| 11 | { | 11 | { |
| 12 | static array $social_networks = ['facebook', 'instagram', 'linkedin', 'github']; // à completer | ||
| 13 | |||
| 12 | static public function setTextData(EntityManager $entityManager, string $request_params, array $json): void | 14 | static public function setTextData(EntityManager $entityManager, string $request_params, array $json): void |
| 13 | { | 15 | { |
| 14 | $params_array = explode('_', $request_params); // header_title, header_description, footer_name, footer_address, footer_email | 16 | $params_array = explode('_', $request_params); // header_title, header_description, footer_name, footer_address, footer_email |
| @@ -20,7 +22,14 @@ class HeadFootController | |||
| 20 | $model = new Model($entityManager); | 22 | $model = new Model($entityManager); |
| 21 | if($model->findWhateverNode('name_node', $params_array[0])){ | 23 | if($model->findWhateverNode('name_node', $params_array[0])){ |
| 22 | $node_data = $model->getNode()->getNodeData(); | 24 | $node_data = $model->getNode()->getNodeData(); |
| 23 | $node_data->updateData($params_array[1], $json['new_text']); // $params_array[1] n'est pas contrôlé | 25 | if(in_array($params_array[1], self::$social_networks)){ |
| 26 | $social = $node_data->getData()['social']; | ||
| 27 | $social[$params_array[1]] = $json['new_text']; | ||
| 28 | $node_data->updateData('social', $social); | ||
| 29 | } | ||
| 30 | else{ | ||
| 31 | $node_data->updateData($params_array[1], $json['new_text']); // $params_array[1] n'est pas contrôlé | ||
| 32 | } | ||
| 24 | $entityManager->flush(); | 33 | $entityManager->flush(); |
| 25 | echo json_encode(['success' => true]); | 34 | echo json_encode(['success' => true]); |
| 26 | } | 35 | } |
