PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / trunk
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder vtrunk
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Services / FormBuilder / NotificationParser.php

NotificationParser.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder trunk, at app/Services/FormBuilder/NotificationParser.php

48 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Services\FormBuilder;
4
5 use FluentForm\App\Services\FormBuilder\ShortCodeParser;
6
7 class NotificationParser
8 {
9 protected static $cache = null;
10
11 /**
12 * Parse Norifications
13 *
14 * @param array $notifications
15 * @param int $insertId
16 * @param array $data
17 * @param object $form
18 *
19 * @return bool $cache
20 */
21 public static function parse($notifications, $insertId, $data, $form, $cache = true)
22 {
23 if ($cache && ! is_null(static::$cache)) {
24 return static::$cache;
25 }
26
27 foreach ($notifications as &$notification) {
28 static::setRecepient($notification, $data);
29
30 $notification = ShortCodeParser::parse(
31 $notification,
32 $insertId,
33 $data,
34 $form
35 );
36 }
37
38 return $cache ? (static::$cache = $notifications) : $notifications;
39 }
40
41 protected static function setRecepient(&$notification, $data)
42 {
43 if (isset($notification['sendTo']) && 'field' == $notification['sendTo']['type']) {
44 $notification['sendTo']['email'] = $data[$notification['sendTo']['field']];
45 }
46 }
47 }
48