| Conditions | 4 |
| Paths | 21 |
| Total Lines | 19 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public function index(): void |
||
| 28 | { |
||
| 29 | $this->getRequest()->allowMethod(['post']); |
||
| 30 | $this->viewBuilder()->setClassName('Json'); |
||
| 31 | try { |
||
| 32 | $payload = $this->getRequest()->getData(); |
||
| 33 | foreach ($payload['data'] as $key => $value) { |
||
| 34 | if (strpos($key, '.') !== false) { |
||
| 35 | unset($payload['data'][$key]); |
||
| 36 | $payload['data'] = Hash::insert($payload['data'], $key, $value); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | ApiClientProvider::getApiClient()->post('/placeholders/send', (string)json_encode($payload)); |
||
| 40 | $response = ['message' => 'Email sent successfully']; |
||
| 41 | $this->set('response', $response); |
||
| 42 | $this->setSerialize(['response']); |
||
| 43 | } catch (Exception $e) { |
||
| 44 | $this->set('error', $e->getMessage()); |
||
| 45 | $this->setSerialize(['error']); |
||
| 46 | } |
||
| 49 |