diff options
| author | polo <ordipolo@gmx.fr> | 2025-10-29 12:08:28 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-10-29 12:08:28 +0100 |
| commit | 822f526fd7f4e89043e64b435961720b622bdb6e (patch) | |
| tree | 2c4bb2a653052f9dc76858db2a2f9f1d0d0a031a /src/controller | |
| parent | f653506421ee8e2c46c78e93d28ee2418a1d399d (diff) | |
| download | cms-822f526fd7f4e89043e64b435961720b622bdb6e.tar.gz cms-822f526fd7f4e89043e64b435961720b622bdb6e.tar.bz2 cms-822f526fd7f4e89043e64b435961720b622bdb6e.zip | |
gestion réseaux sociaux présents/absents, partie 1
Diffstat (limited to 'src/controller')
| -rw-r--r-- | src/controller/HeadFootController.php | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/controller/HeadFootController.php b/src/controller/HeadFootController.php index ffa33bc..7597683 100644 --- a/src/controller/HeadFootController.php +++ b/src/controller/HeadFootController.php | |||
| @@ -3,14 +3,13 @@ | |||
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | use App\Entity\NodeData; | ||
| 6 | use App\Entity\NodeDataAsset; | 7 | use App\Entity\NodeDataAsset; |
| 7 | use App\Entity\Asset; | 8 | use App\Entity\Asset; |
| 8 | use Doctrine\ORM\EntityManager; | 9 | use Doctrine\ORM\EntityManager; |
| 9 | 10 | ||
| 10 | class HeadFootController | 11 | class HeadFootController |
| 11 | { | 12 | { |
| 12 | static array $social_networks = ['facebook', 'instagram', 'linkedin', 'github']; // à completer | ||
| 13 | |||
| 14 | static public function setTextData(EntityManager $entityManager, string $request_params, array $json): void | 13 | static public function setTextData(EntityManager $entityManager, string $request_params, array $json): void |
| 15 | { | 14 | { |
| 16 | $params_array = explode('_', $request_params); // header_title, header_description, footer_name, footer_address, footer_email | 15 | $params_array = explode('_', $request_params); // header_title, header_description, footer_name, footer_address, footer_email |
| @@ -22,7 +21,8 @@ class HeadFootController | |||
| 22 | $model = new Model($entityManager); | 21 | $model = new Model($entityManager); |
| 23 | if($model->findWhateverNode('name_node', $params_array[0])){ | 22 | if($model->findWhateverNode('name_node', $params_array[0])){ |
| 24 | $node_data = $model->getNode()->getNodeData(); | 23 | $node_data = $model->getNode()->getNodeData(); |
| 25 | if(in_array($params_array[1], self::$social_networks)){ | 24 | |
| 25 | if(in_array($params_array[1], NodeData::$social_networks)){ | ||
| 26 | $social = $node_data->getData()['social']; | 26 | $social = $node_data->getData()['social']; |
| 27 | $social[$params_array[1]] = $json['new_text']; | 27 | $social[$params_array[1]] = $json['new_text']; |
| 28 | $node_data->updateData('social', $social); | 28 | $node_data->updateData('social', $social); |
| @@ -30,6 +30,7 @@ class HeadFootController | |||
| 30 | else{ | 30 | else{ |
| 31 | $node_data->updateData($params_array[1], $json['new_text']); // $params_array[1] n'est pas contrôlé | 31 | $node_data->updateData($params_array[1], $json['new_text']); // $params_array[1] n'est pas contrôlé |
| 32 | } | 32 | } |
| 33 | |||
| 33 | $entityManager->flush(); | 34 | $entityManager->flush(); |
| 34 | echo json_encode(['success' => true]); | 35 | echo json_encode(['success' => true]); |
| 35 | } | 36 | } |
