Completed
Branch EDTR/master (2b4e68)
by
unknown
09:43 queued 41s
created
core/domain/entities/routing/data_nodes/core/CurrentUser.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -16,43 +16,43 @@
 block discarded – undo
16 16
  */
17 17
 class CurrentUser extends JsonDataNode
18 18
 {
19
-    const NODE_NAME = 'currentUser';
19
+	const NODE_NAME = 'currentUser';
20 20
 
21 21
 
22
-    /**
23
-     * @param JsonDataNodeValidator $validator
24
-     */
25
-    public function __construct(JsonDataNodeValidator $validator)
26
-    {
27
-        if (! class_exists('WPGraphQL')) {
28
-            require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php';
29
-        }
30
-        parent::__construct($validator);
31
-        $this->setNodeName(CurrentUser::NODE_NAME);
32
-    }
22
+	/**
23
+	 * @param JsonDataNodeValidator $validator
24
+	 */
25
+	public function __construct(JsonDataNodeValidator $validator)
26
+	{
27
+		if (! class_exists('WPGraphQL')) {
28
+			require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php';
29
+		}
30
+		parent::__construct($validator);
31
+		$this->setNodeName(CurrentUser::NODE_NAME);
32
+	}
33 33
 
34
-    /**
35
-     * @inheritDoc
36
-     */
37
-    public function initialize()
38
-    {
39
-        $current_user = wp_get_current_user();
40
-        if (! $current_user instanceof WP_User) {
41
-            $current_user = new WP_User();
42
-        }
34
+	/**
35
+	 * @inheritDoc
36
+	 */
37
+	public function initialize()
38
+	{
39
+		$current_user = wp_get_current_user();
40
+		if (! $current_user instanceof WP_User) {
41
+			$current_user = new WP_User();
42
+		}
43 43
 
44
-        $this->addData('id', Relay::toGlobalId('user', $current_user->ID));
45
-        $this->addData('databaseId', $current_user->ID);
46
-        $this->addData('description', $current_user->description);
47
-        $this->addData('email', $current_user->user_email);
48
-        $this->addData('firstName', $current_user->first_name);
49
-        $this->addData('lastName', $current_user->last_name);
50
-        $this->addData('locale', get_user_locale($current_user->ID));
51
-        $this->addData('name', $current_user->display_name);
52
-        $this->addData('nicename', $current_user->user_nicename);
53
-        $this->addData('nickname', $current_user->nickname);
54
-        $this->addData('username', $current_user->user_login);
55
-        $this->addData('__typename', 'User');
56
-        $this->setInitialized(true);
57
-    }
44
+		$this->addData('id', Relay::toGlobalId('user', $current_user->ID));
45
+		$this->addData('databaseId', $current_user->ID);
46
+		$this->addData('description', $current_user->description);
47
+		$this->addData('email', $current_user->user_email);
48
+		$this->addData('firstName', $current_user->first_name);
49
+		$this->addData('lastName', $current_user->last_name);
50
+		$this->addData('locale', get_user_locale($current_user->ID));
51
+		$this->addData('name', $current_user->display_name);
52
+		$this->addData('nicename', $current_user->user_nicename);
53
+		$this->addData('nickname', $current_user->nickname);
54
+		$this->addData('username', $current_user->user_login);
55
+		$this->addData('__typename', 'User');
56
+		$this->setInitialized(true);
57
+	}
58 58
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/data_nodes/core/GeneralSettings.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -15,28 +15,28 @@
 block discarded – undo
15 15
 class GeneralSettings extends JsonDataNode
16 16
 {
17 17
 
18
-    const NODE_NAME = 'generalSettings';
19
-
20
-
21
-    /**
22
-     * @param JsonDataNodeValidator $validator
23
-     */
24
-    public function __construct(JsonDataNodeValidator $validator)
25
-    {
26
-        parent::__construct($validator);
27
-        $this->setNodeName(GeneralSettings::NODE_NAME);
28
-    }
29
-
30
-
31
-    /**
32
-     * @inheritDoc
33
-     */
34
-    public function initialize()
35
-    {
36
-        $this->addData('dateFormat', get_option('date_format'));
37
-        $this->addData('timeFormat', get_option('time_format'));
38
-        $this->addData('timezone', get_option('timezone_string'));
39
-        $this->addData('__typename', 'GeneralSettings');
40
-        $this->setInitialized(true);
41
-    }
18
+	const NODE_NAME = 'generalSettings';
19
+
20
+
21
+	/**
22
+	 * @param JsonDataNodeValidator $validator
23
+	 */
24
+	public function __construct(JsonDataNodeValidator $validator)
25
+	{
26
+		parent::__construct($validator);
27
+		$this->setNodeName(GeneralSettings::NODE_NAME);
28
+	}
29
+
30
+
31
+	/**
32
+	 * @inheritDoc
33
+	 */
34
+	public function initialize()
35
+	{
36
+		$this->addData('dateFormat', get_option('date_format'));
37
+		$this->addData('timeFormat', get_option('time_format'));
38
+		$this->addData('timezone', get_option('timezone_string'));
39
+		$this->addData('__typename', 'GeneralSettings');
40
+		$this->setInitialized(true);
41
+	}
42 42
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/data_nodes/core/SiteUrls.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -16,26 +16,26 @@
 block discarded – undo
16 16
 class SiteUrls extends JsonDataNode
17 17
 {
18 18
 
19
-    const NODE_NAME = 'siteUrls';
20
-
21
-
22
-    /**
23
-     * @param JsonDataNodeValidator $validator
24
-     */
25
-    public function __construct(JsonDataNodeValidator $validator)
26
-    {
27
-        parent::__construct($validator);
28
-        $this->setNodeName(SiteUrls::NODE_NAME);
29
-    }
30
-
31
-
32
-    /**
33
-     * @since $VID:$
34
-     */
35
-    public function initialize()
36
-    {
37
-        $this->addData('admin', admin_url('/'));
38
-        $this->addData('home', site_url('/'));
39
-        $this->setInitialized(true);
40
-    }
19
+	const NODE_NAME = 'siteUrls';
20
+
21
+
22
+	/**
23
+	 * @param JsonDataNodeValidator $validator
24
+	 */
25
+	public function __construct(JsonDataNodeValidator $validator)
26
+	{
27
+		parent::__construct($validator);
28
+		$this->setNodeName(SiteUrls::NODE_NAME);
29
+	}
30
+
31
+
32
+	/**
33
+	 * @since $VID:$
34
+	 */
35
+	public function initialize()
36
+	{
37
+		$this->addData('admin', admin_url('/'));
38
+		$this->addData('home', site_url('/'));
39
+		$this->setInitialized(true);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/data_nodes/core/Locale.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -17,30 +17,30 @@
 block discarded – undo
17 17
 class Locale extends JsonDataNode
18 18
 {
19 19
 
20
-    const NODE_NAME = 'locale';
20
+	const NODE_NAME = 'locale';
21 21
 
22 22
 
23
-    /**
24
-     * @param JsonDataNodeValidator $validator
25
-     */
26
-    public function __construct(JsonDataNodeValidator $validator)
27
-    {
28
-        parent::__construct($validator);
29
-        $this->setNodeName(Locale::NODE_NAME);
30
-    }
23
+	/**
24
+	 * @param JsonDataNodeValidator $validator
25
+	 */
26
+	public function __construct(JsonDataNodeValidator $validator)
27
+	{
28
+		parent::__construct($validator);
29
+		$this->setNodeName(Locale::NODE_NAME);
30
+	}
31 31
 
32
-    /**
33
-     * @inheritDoc
34
-     */
35
-    public function initialize()
36
-    {
37
-        $this->addData('user', get_user_locale());
38
-        $this->addData('site', get_locale());
39
-        $this->addData('siteTimezone', [
40
-            'city'   => EEH_DTT_Helper::get_timezone_string_for_display(),
41
-            'name'   => get_option('timezone_string'),
42
-            'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
43
-        ]);
44
-        $this->setInitialized(true);
45
-    }
32
+	/**
33
+	 * @inheritDoc
34
+	 */
35
+	public function initialize()
36
+	{
37
+		$this->addData('user', get_user_locale());
38
+		$this->addData('site', get_locale());
39
+		$this->addData('siteTimezone', [
40
+			'city'   => EEH_DTT_Helper::get_timezone_string_for_display(),
41
+			'name'   => get_option('timezone_string'),
42
+			'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
43
+		]);
44
+		$this->setInitialized(true);
45
+	}
46 46
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/data_nodes/core/Api.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -19,32 +19,32 @@
 block discarded – undo
19 19
 class Api extends JsonDataNode
20 20
 {
21 21
 
22
-    const NODE_NAME = 'api';
23
-
24
-
25
-    /**
26
-     * @param JsonDataNodeValidator $validator
27
-     */
28
-    public function __construct(JsonDataNodeValidator $validator)
29
-    {
30
-        parent::__construct($validator);
31
-        $this->setNodeName(Api::NODE_NAME);
32
-    }
33
-
34
-
35
-    /**
36
-     * @throws DomainException
37
-     * @since $VID:$
38
-     */
39
-    public function initialize()
40
-    {
41
-        $this->addData('restApiNonce', wp_create_nonce('wp_rest'));
42
-        $this->addData('restApiBaseUrl', rest_url());
43
-        $this->addData('restApiRouteUrl', rest_url('ee/v4.8.36/'));
44
-        $this->addData('restApiCollectionEndpoints', EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName());
45
-        $this->addData('restApiPrimaryKeys', EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName());
46
-        $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : '';
47
-        $this->addData('graphqlEndpoint', esc_url($graphqlEndpoint));
48
-        $this->setInitialized(true);
49
-    }
22
+	const NODE_NAME = 'api';
23
+
24
+
25
+	/**
26
+	 * @param JsonDataNodeValidator $validator
27
+	 */
28
+	public function __construct(JsonDataNodeValidator $validator)
29
+	{
30
+		parent::__construct($validator);
31
+		$this->setNodeName(Api::NODE_NAME);
32
+	}
33
+
34
+
35
+	/**
36
+	 * @throws DomainException
37
+	 * @since $VID:$
38
+	 */
39
+	public function initialize()
40
+	{
41
+		$this->addData('restApiNonce', wp_create_nonce('wp_rest'));
42
+		$this->addData('restApiBaseUrl', rest_url());
43
+		$this->addData('restApiRouteUrl', rest_url('ee/v4.8.36/'));
44
+		$this->addData('restApiCollectionEndpoints', EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName());
45
+		$this->addData('restApiPrimaryKeys', EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName());
46
+		$graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : '';
47
+		$this->addData('graphqlEndpoint', esc_url($graphqlEndpoint));
48
+		$this->setInitialized(true);
49
+	}
50 50
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/data_nodes/EventEspressoData.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -21,49 +21,49 @@
 block discarded – undo
21 21
 class EventEspressoData extends PrimaryJsonDataNode
22 22
 {
23 23
 
24
-    const NODE_NAME = 'eventEspressoData';
24
+	const NODE_NAME = 'eventEspressoData';
25 25
 
26
-    /**
27
-     * @var Api $api
28
-     */
29
-    private $api;
26
+	/**
27
+	 * @var Api $api
28
+	 */
29
+	private $api;
30 30
 
31
-    /**
32
-     * @var Config $config
33
-     */
34
-    private $config;
31
+	/**
32
+	 * @var Config $config
33
+	 */
34
+	private $config;
35 35
 
36
-    /**
37
-     * @var JedLocaleData $jed_locale
38
-     */
39
-    private $jed_locale;
36
+	/**
37
+	 * @var JedLocaleData $jed_locale
38
+	 */
39
+	private $jed_locale;
40 40
 
41 41
 
42
-    /**
43
-     * @param Api $api
44
-     * @param Config $config
45
-     * @param JedLocaleData         $jed_locale
46
-     * @param JsonDataNodeValidator $validator
47
-     */
48
-    public function __construct(Api $api, Config $config, JedLocaleData $jed_locale, JsonDataNodeValidator $validator)
49
-    {
50
-        parent::__construct($validator);
51
-        $this->api = $api;
52
-        $this->config = $config;
53
-        $this->jed_locale = $jed_locale;
54
-        $this->setNodeName(EventEspressoData::NODE_NAME);
55
-    }
42
+	/**
43
+	 * @param Api $api
44
+	 * @param Config $config
45
+	 * @param JedLocaleData         $jed_locale
46
+	 * @param JsonDataNodeValidator $validator
47
+	 */
48
+	public function __construct(Api $api, Config $config, JedLocaleData $jed_locale, JsonDataNodeValidator $validator)
49
+	{
50
+		parent::__construct($validator);
51
+		$this->api = $api;
52
+		$this->config = $config;
53
+		$this->jed_locale = $jed_locale;
54
+		$this->setNodeName(EventEspressoData::NODE_NAME);
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * @throws DomainException
60
-     * @since $VID:$
61
-     */
62
-    public function initialize()
63
-    {
64
-        $this->addDataNode($this->api);
65
-        $this->addDataNode($this->config);
66
-        $this->addData('i18n', $this->jed_locale->getData('event_espresso'));
67
-        $this->setInitialized(true);
68
-    }
58
+	/**
59
+	 * @throws DomainException
60
+	 * @since $VID:$
61
+	 */
62
+	public function initialize()
63
+	{
64
+		$this->addDataNode($this->api);
65
+		$this->addDataNode($this->config);
66
+		$this->addData('i18n', $this->jed_locale->getData('event_espresso'));
67
+		$this->setInitialized(true);
68
+	}
69 69
 }
Please login to merge, or discard this patch.
core/services/json/JsonDataNodeHandler.php 2 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -18,130 +18,130 @@
 block discarded – undo
18 18
 class JsonDataNodeHandler
19 19
 {
20 20
 
21
-    /**
22
-     * @var PrimaryJsonDataNode $primary_data_node
23
-     */
24
-    private $primary_data_node;
25
-
26
-    /**
27
-     * @var JsonDataNodeValidator $validator
28
-     */
29
-    private $validator;
30
-
31
-
32
-    /**
33
-     * @param JsonDataNodeValidator $validator
34
-     */
35
-    public function __construct(JsonDataNodeValidator $validator)
36
-    {
37
-        $this->validator = $validator;
38
-    }
39
-
40
-
41
-    /**
42
-     * @param JsonDataNode $data_node
43
-     * @throws DomainException
44
-     */
45
-    public function addDataNode(JsonDataNode $data_node)
46
-    {
47
-        if ($data_node->isNotInitialized()) {
48
-            $this->validatePrimaryDataNode($data_node);
49
-            $this->primary_data_node->addDataNode($data_node);
50
-        }
51
-    }
52
-
53
-
54
-    /**
55
-     * @param PrimaryJsonDataNode $primary_data_node
56
-     */
57
-    public function setPrimaryDataNode(PrimaryJsonDataNode $primary_data_node)
58
-    {
59
-        $this->primary_data_node = $primary_data_node;
60
-    }
61
-
62
-
63
-    /**
64
-     * @param JsonDataNode $data_node
65
-     * @param int                $depth
66
-     * @return mixed
67
-     * @since $VID:$
68
-     */
69
-    private function initializeDataNodes(JsonDataNode $data_node, $depth = 0)
70
-    {
71
-        $depth++;
72
-        $data = [];
73
-        // initialize the data node if not done already
74
-        if ($data_node->isNotInitialized()) {
75
-            $data_node->initialize();
76
-            // grab the data node's data array
77
-            $data_node_data = $data_node->data();
78
-            foreach ($data_node_data as $child_node_name => $child_node) {
79
-                // don't parse node if it's the primary, OR if depth has exceeded wp_json_encode() limit
80
-                if ($child_node instanceof PrimaryJsonDataNode || $depth > 512) {
81
-                    continue;
82
-                }
83
-                if ($child_node instanceof JsonDataNode) {
84
-                    // feed data node back into this function
85
-                    $data[ $child_node_name ] = $this->initializeDataNodes($child_node, $depth);
86
-                } else {
87
-                    // or assign data directly
88
-                    $data[ $child_node_name ] = $child_node;
89
-                }
90
-            }
91
-        }
92
-        return $data;
93
-    }
94
-
95
-
96
-    /**
97
-     * @throws DomainException
98
-     * @since $VID:$
99
-     */
100
-    public function printDataNode()
101
-    {
102
-        if (!$this->primary_data_node instanceof PrimaryJsonDataNode) {
103
-            return;
104
-        }
105
-        // validate that the domain, node name, and target script are set
106
-        $domain = $this->primary_data_node->domain();
107
-        $node_name = $this->primary_data_node->nodeName();
108
-        $target_script = $this->primary_data_node->targetScript();
109
-        $data_valid =  $this->validator->validateCriticalProperty($domain, 'domain route', false)
110
-                       && $this->validator->validateCriticalProperty($node_name, 'node name', false)
111
-                       && $this->validator->validateCriticalProperty($target_script, 'target script', false);
112
-        if (! $data_valid) {
113
-            return;
114
-        }
115
-        // initialize and parse data from primary data node
116
-        $data = $this->initializeDataNodes($this->primary_data_node);
117
-        // this prepends the current domain "use case" to the front of the array
118
-        $data = ['domain' => $domain] + $data;
119
-        // add legacy i18n strings
120
-        $data['eei18n'] = EE_Registry::$i18n_js_strings;
121
-        // and finally JSON encode the data and attach to the target script
122
-        $data = json_encode($data);
123
-        wp_add_inline_script($target_script, "var {$node_name}={$data};", 'before');
124
-    }
125
-
126
-
127
-    /**
128
-     * @param JsonDataNode $data_node
129
-     * @throws DomainException
130
-     */
131
-    private function validatePrimaryDataNode(JsonDataNode $data_node)
132
-    {
133
-        // set primary data node if that's what the incoming node is
134
-        if ($data_node instanceof PrimaryJsonDataNode) {
135
-            $this->setPrimaryDataNode($data_node);
136
-        }
137
-        // and don't allow other nodes to be set until a primary is set
138
-        if (! $this->primary_data_node instanceof PrimaryJsonDataNode) {
139
-            throw new DomainException(
140
-                esc_html__(
141
-                    'A PrimaryJsonDataNode needs to be set before data nodes can be added.',
142
-                    'event_espresso'
143
-                )
144
-            );
145
-        }
146
-    }
21
+	/**
22
+	 * @var PrimaryJsonDataNode $primary_data_node
23
+	 */
24
+	private $primary_data_node;
25
+
26
+	/**
27
+	 * @var JsonDataNodeValidator $validator
28
+	 */
29
+	private $validator;
30
+
31
+
32
+	/**
33
+	 * @param JsonDataNodeValidator $validator
34
+	 */
35
+	public function __construct(JsonDataNodeValidator $validator)
36
+	{
37
+		$this->validator = $validator;
38
+	}
39
+
40
+
41
+	/**
42
+	 * @param JsonDataNode $data_node
43
+	 * @throws DomainException
44
+	 */
45
+	public function addDataNode(JsonDataNode $data_node)
46
+	{
47
+		if ($data_node->isNotInitialized()) {
48
+			$this->validatePrimaryDataNode($data_node);
49
+			$this->primary_data_node->addDataNode($data_node);
50
+		}
51
+	}
52
+
53
+
54
+	/**
55
+	 * @param PrimaryJsonDataNode $primary_data_node
56
+	 */
57
+	public function setPrimaryDataNode(PrimaryJsonDataNode $primary_data_node)
58
+	{
59
+		$this->primary_data_node = $primary_data_node;
60
+	}
61
+
62
+
63
+	/**
64
+	 * @param JsonDataNode $data_node
65
+	 * @param int                $depth
66
+	 * @return mixed
67
+	 * @since $VID:$
68
+	 */
69
+	private function initializeDataNodes(JsonDataNode $data_node, $depth = 0)
70
+	{
71
+		$depth++;
72
+		$data = [];
73
+		// initialize the data node if not done already
74
+		if ($data_node->isNotInitialized()) {
75
+			$data_node->initialize();
76
+			// grab the data node's data array
77
+			$data_node_data = $data_node->data();
78
+			foreach ($data_node_data as $child_node_name => $child_node) {
79
+				// don't parse node if it's the primary, OR if depth has exceeded wp_json_encode() limit
80
+				if ($child_node instanceof PrimaryJsonDataNode || $depth > 512) {
81
+					continue;
82
+				}
83
+				if ($child_node instanceof JsonDataNode) {
84
+					// feed data node back into this function
85
+					$data[ $child_node_name ] = $this->initializeDataNodes($child_node, $depth);
86
+				} else {
87
+					// or assign data directly
88
+					$data[ $child_node_name ] = $child_node;
89
+				}
90
+			}
91
+		}
92
+		return $data;
93
+	}
94
+
95
+
96
+	/**
97
+	 * @throws DomainException
98
+	 * @since $VID:$
99
+	 */
100
+	public function printDataNode()
101
+	{
102
+		if (!$this->primary_data_node instanceof PrimaryJsonDataNode) {
103
+			return;
104
+		}
105
+		// validate that the domain, node name, and target script are set
106
+		$domain = $this->primary_data_node->domain();
107
+		$node_name = $this->primary_data_node->nodeName();
108
+		$target_script = $this->primary_data_node->targetScript();
109
+		$data_valid =  $this->validator->validateCriticalProperty($domain, 'domain route', false)
110
+					   && $this->validator->validateCriticalProperty($node_name, 'node name', false)
111
+					   && $this->validator->validateCriticalProperty($target_script, 'target script', false);
112
+		if (! $data_valid) {
113
+			return;
114
+		}
115
+		// initialize and parse data from primary data node
116
+		$data = $this->initializeDataNodes($this->primary_data_node);
117
+		// this prepends the current domain "use case" to the front of the array
118
+		$data = ['domain' => $domain] + $data;
119
+		// add legacy i18n strings
120
+		$data['eei18n'] = EE_Registry::$i18n_js_strings;
121
+		// and finally JSON encode the data and attach to the target script
122
+		$data = json_encode($data);
123
+		wp_add_inline_script($target_script, "var {$node_name}={$data};", 'before');
124
+	}
125
+
126
+
127
+	/**
128
+	 * @param JsonDataNode $data_node
129
+	 * @throws DomainException
130
+	 */
131
+	private function validatePrimaryDataNode(JsonDataNode $data_node)
132
+	{
133
+		// set primary data node if that's what the incoming node is
134
+		if ($data_node instanceof PrimaryJsonDataNode) {
135
+			$this->setPrimaryDataNode($data_node);
136
+		}
137
+		// and don't allow other nodes to be set until a primary is set
138
+		if (! $this->primary_data_node instanceof PrimaryJsonDataNode) {
139
+			throw new DomainException(
140
+				esc_html__(
141
+					'A PrimaryJsonDataNode needs to be set before data nodes can be added.',
142
+					'event_espresso'
143
+				)
144
+			);
145
+		}
146
+	}
147 147
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
                 }
83 83
                 if ($child_node instanceof JsonDataNode) {
84 84
                     // feed data node back into this function
85
-                    $data[ $child_node_name ] = $this->initializeDataNodes($child_node, $depth);
85
+                    $data[$child_node_name] = $this->initializeDataNodes($child_node, $depth);
86 86
                 } else {
87 87
                     // or assign data directly
88
-                    $data[ $child_node_name ] = $child_node;
88
+                    $data[$child_node_name] = $child_node;
89 89
                 }
90 90
             }
91 91
         }
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function printDataNode()
101 101
     {
102
-        if (!$this->primary_data_node instanceof PrimaryJsonDataNode) {
102
+        if ( ! $this->primary_data_node instanceof PrimaryJsonDataNode) {
103 103
             return;
104 104
         }
105 105
         // validate that the domain, node name, and target script are set
106 106
         $domain = $this->primary_data_node->domain();
107 107
         $node_name = $this->primary_data_node->nodeName();
108 108
         $target_script = $this->primary_data_node->targetScript();
109
-        $data_valid =  $this->validator->validateCriticalProperty($domain, 'domain route', false)
109
+        $data_valid = $this->validator->validateCriticalProperty($domain, 'domain route', false)
110 110
                        && $this->validator->validateCriticalProperty($node_name, 'node name', false)
111 111
                        && $this->validator->validateCriticalProperty($target_script, 'target script', false);
112
-        if (! $data_valid) {
112
+        if ( ! $data_valid) {
113 113
             return;
114 114
         }
115 115
         // initialize and parse data from primary data node
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             $this->setPrimaryDataNode($data_node);
136 136
         }
137 137
         // and don't allow other nodes to be set until a primary is set
138
-        if (! $this->primary_data_node instanceof PrimaryJsonDataNode) {
138
+        if ( ! $this->primary_data_node instanceof PrimaryJsonDataNode) {
139 139
             throw new DomainException(
140 140
                 esc_html__(
141 141
                     'A PrimaryJsonDataNode needs to be set before data nodes can be added.',
Please login to merge, or discard this patch.
core/services/json/JsonDataNode.php 1 patch
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -18,181 +18,181 @@
 block discarded – undo
18 18
 abstract class JsonDataNode implements JsonDataNodeInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var JsonDataNodeValidator $validator
23
-     */
24
-    protected $validator;
25
-
26
-    /**
27
-     * @var array $data
28
-     */
29
-    private $data = [];
30
-
31
-    /**
32
-     * @var string $domain
33
-     */
34
-    private $domain;
35
-
36
-    /**
37
-     * @var boolean $initialized
38
-     */
39
-    private $initialized = false;
40
-
41
-    /**
42
-     * @var string $node_name
43
-     */
44
-    private $node_name;
45
-
46
-
47
-    /**
48
-     * @param JsonDataNodeValidator $validator
49
-     * @throws DomainException
50
-     */
51
-    public function __construct(JsonDataNodeValidator $validator)
52
-    {
53
-        $this->validator = $validator;
54
-    }
55
-
56
-
57
-    /**
58
-     * for adding primitive data like arrays, integers, or strings
59
-     *
60
-     * @param string $key
61
-     * @param mixed  $data
62
-     * @throws DomainException
63
-     */
64
-    protected function addData($key, $data)
65
-    {
66
-        if ($this->validator->propertyNotSet($this->data, $key)) {
67
-            $this->data[ $key ] = $data;
68
-        }
69
-    }
70
-
71
-
72
-    /**
73
-     * for embedding other JsonDataNode objects within this one
74
-     *
75
-     * @param JsonDataNode $data_node
76
-     * @throws DomainException
77
-     */
78
-    public function addDataNode(JsonDataNode $data_node)
79
-    {
80
-        if ($data_node->isNotInitialized()) {
81
-            // $data_node->initialize();
82
-            $key = $data_node->nodeName();
83
-            $this->addData($key, $data_node);
84
-            // if the node being added specifies a domain (use case)
85
-            // and this is the primary data node, then set the domain
86
-            if ($this instanceof PrimaryJsonDataNode && $data_node->domain() !== null) {
87
-                $this->setDomain($data_node->domain());
88
-            }
89
-        }
90
-    }
91
-
92
-
93
-    /**
94
-     * sets the domain (use case) that this data node provides data for
95
-     *
96
-     * @param string $domain
97
-     * @throws DomainException
98
-     */
99
-    protected function setDomain($domain)
100
-    {
101
-        if ($this->domain !== null) {
102
-            $this->validator->overwriteError($domain, 'domain route');
103
-        }
104
-        $this->domain = $domain;
105
-    }
106
-
107
-
108
-    /**
109
-     * used to mark the data node as having been processed
110
-     *
111
-     * @param bool $initialized
112
-     */
113
-    protected function setInitialized($initialized)
114
-    {
115
-        $this->initialized = filter_var($initialized, FILTER_VALIDATE_BOOLEAN);
116
-    }
117
-
118
-
119
-    /**
120
-     * self explanatory (i hope)
121
-     *
122
-     * @param string $node_name
123
-     * @throws DomainException
124
-     */
125
-    protected function setNodeName($node_name)
126
-    {
127
-        $this->validator->validateCriticalProperty($node_name, 'node name');
128
-        $this->node_name = $node_name;
129
-    }
130
-
131
-
132
-    /**
133
-     * the actual data in key value array format
134
-     *
135
-     * @return array
136
-     */
137
-    public function data()
138
-    {
139
-        return $this->data;
140
-    }
141
-
142
-
143
-    /**
144
-     * the domain (use case) that this data node provides data for
145
-     *
146
-     * @return string
147
-     */
148
-    public function domain()
149
-    {
150
-        return $this->domain;
151
-    }
152
-
153
-
154
-    /**
155
-     * true if the data node has been initialized,
156
-     * which entails retrieving the required data and adding it to the data node data array
157
-     *
158
-     * @return bool
159
-     */
160
-    public function isInitialized()
161
-    {
162
-        return $this->initialized;
163
-    }
164
-
165
-
166
-    /**
167
-     * true if the data node has NOT been initialized
168
-     *
169
-     * @return bool
170
-     */
171
-    public function isNotInitialized()
172
-    {
173
-        return ! $this->initialized;
174
-    }
175
-
176
-
177
-    /**
178
-     * Specify data which should be serialized to JSON
179
-     *
180
-     * @link  https://php.net/manual/en/jsonserializable.jsonserialize.php
181
-     * @return mixed data which can be serialized by json_encode
182
-     */
183
-    public function jsonSerialize()
184
-    {
185
-        return $this->data;
186
-    }
187
-
188
-
189
-    /**
190
-     * self explanatory (i hope)
191
-     *
192
-     * @return string
193
-     */
194
-    public function nodeName()
195
-    {
196
-        return $this->node_name;
197
-    }
21
+	/**
22
+	 * @var JsonDataNodeValidator $validator
23
+	 */
24
+	protected $validator;
25
+
26
+	/**
27
+	 * @var array $data
28
+	 */
29
+	private $data = [];
30
+
31
+	/**
32
+	 * @var string $domain
33
+	 */
34
+	private $domain;
35
+
36
+	/**
37
+	 * @var boolean $initialized
38
+	 */
39
+	private $initialized = false;
40
+
41
+	/**
42
+	 * @var string $node_name
43
+	 */
44
+	private $node_name;
45
+
46
+
47
+	/**
48
+	 * @param JsonDataNodeValidator $validator
49
+	 * @throws DomainException
50
+	 */
51
+	public function __construct(JsonDataNodeValidator $validator)
52
+	{
53
+		$this->validator = $validator;
54
+	}
55
+
56
+
57
+	/**
58
+	 * for adding primitive data like arrays, integers, or strings
59
+	 *
60
+	 * @param string $key
61
+	 * @param mixed  $data
62
+	 * @throws DomainException
63
+	 */
64
+	protected function addData($key, $data)
65
+	{
66
+		if ($this->validator->propertyNotSet($this->data, $key)) {
67
+			$this->data[ $key ] = $data;
68
+		}
69
+	}
70
+
71
+
72
+	/**
73
+	 * for embedding other JsonDataNode objects within this one
74
+	 *
75
+	 * @param JsonDataNode $data_node
76
+	 * @throws DomainException
77
+	 */
78
+	public function addDataNode(JsonDataNode $data_node)
79
+	{
80
+		if ($data_node->isNotInitialized()) {
81
+			// $data_node->initialize();
82
+			$key = $data_node->nodeName();
83
+			$this->addData($key, $data_node);
84
+			// if the node being added specifies a domain (use case)
85
+			// and this is the primary data node, then set the domain
86
+			if ($this instanceof PrimaryJsonDataNode && $data_node->domain() !== null) {
87
+				$this->setDomain($data_node->domain());
88
+			}
89
+		}
90
+	}
91
+
92
+
93
+	/**
94
+	 * sets the domain (use case) that this data node provides data for
95
+	 *
96
+	 * @param string $domain
97
+	 * @throws DomainException
98
+	 */
99
+	protected function setDomain($domain)
100
+	{
101
+		if ($this->domain !== null) {
102
+			$this->validator->overwriteError($domain, 'domain route');
103
+		}
104
+		$this->domain = $domain;
105
+	}
106
+
107
+
108
+	/**
109
+	 * used to mark the data node as having been processed
110
+	 *
111
+	 * @param bool $initialized
112
+	 */
113
+	protected function setInitialized($initialized)
114
+	{
115
+		$this->initialized = filter_var($initialized, FILTER_VALIDATE_BOOLEAN);
116
+	}
117
+
118
+
119
+	/**
120
+	 * self explanatory (i hope)
121
+	 *
122
+	 * @param string $node_name
123
+	 * @throws DomainException
124
+	 */
125
+	protected function setNodeName($node_name)
126
+	{
127
+		$this->validator->validateCriticalProperty($node_name, 'node name');
128
+		$this->node_name = $node_name;
129
+	}
130
+
131
+
132
+	/**
133
+	 * the actual data in key value array format
134
+	 *
135
+	 * @return array
136
+	 */
137
+	public function data()
138
+	{
139
+		return $this->data;
140
+	}
141
+
142
+
143
+	/**
144
+	 * the domain (use case) that this data node provides data for
145
+	 *
146
+	 * @return string
147
+	 */
148
+	public function domain()
149
+	{
150
+		return $this->domain;
151
+	}
152
+
153
+
154
+	/**
155
+	 * true if the data node has been initialized,
156
+	 * which entails retrieving the required data and adding it to the data node data array
157
+	 *
158
+	 * @return bool
159
+	 */
160
+	public function isInitialized()
161
+	{
162
+		return $this->initialized;
163
+	}
164
+
165
+
166
+	/**
167
+	 * true if the data node has NOT been initialized
168
+	 *
169
+	 * @return bool
170
+	 */
171
+	public function isNotInitialized()
172
+	{
173
+		return ! $this->initialized;
174
+	}
175
+
176
+
177
+	/**
178
+	 * Specify data which should be serialized to JSON
179
+	 *
180
+	 * @link  https://php.net/manual/en/jsonserializable.jsonserialize.php
181
+	 * @return mixed data which can be serialized by json_encode
182
+	 */
183
+	public function jsonSerialize()
184
+	{
185
+		return $this->data;
186
+	}
187
+
188
+
189
+	/**
190
+	 * self explanatory (i hope)
191
+	 *
192
+	 * @return string
193
+	 */
194
+	public function nodeName()
195
+	{
196
+		return $this->node_name;
197
+	}
198 198
 }
Please login to merge, or discard this patch.
core/services/routing/RouteHandler.php 2 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -20,124 +20,124 @@
 block discarded – undo
20 20
 class RouteHandler
21 21
 {
22 22
 
23
-    /**
24
-     * @var JsonDataNodeHandler $data_node_handler
25
-     */
26
-    private $data_node_handler;
27
-
28
-    /**
29
-     * @var LoaderInterface $loader
30
-     */
31
-    private $loader;
32
-
33
-    /**
34
-     * @var RequestInterface $request
35
-     */
36
-    protected $request;
37
-
38
-    /**
39
-     * @var RouteCollection $routes
40
-     */
41
-    private $routes;
42
-
43
-
44
-    /**
45
-     * RouteHandler constructor.
46
-     *
47
-     * @param JsonDataNodeHandler $data_node_handler
48
-     * @param LoaderInterface  $loader
49
-     * @param RequestInterface $request
50
-     * @param RouteCollection $routes
51
-     */
52
-    public function __construct(
53
-        JsonDataNodeHandler $data_node_handler,
54
-        LoaderInterface $loader,
55
-        RequestInterface $request,
56
-        RouteCollection $routes
57
-    ) {
58
-        $this->data_node_handler = $data_node_handler;
59
-        $this->loader = $loader;
60
-        $this->request = $request;
61
-        $this->routes = $routes;
62
-        if (! $this->request->isActivation()) {
63
-            add_action('admin_footer', [$this->data_node_handler, 'printDataNode']);
64
-            add_action('wp_footer', [$this->data_node_handler, 'printDataNode']);
65
-        }
66
-    }
67
-
68
-
69
-    /**
70
-     * @param string $fqcn   Fully Qualified Class Name for Route
71
-     * @param bool   $handle if true [default] will immediately call RouteInterface::handleRequest() after adding
72
-     * @throws Exception
73
-     * @since $VID:$
74
-     */
75
-    public function addRoute($fqcn, $handle = true)
76
-    {
77
-        try {
78
-            if ($this->request->isActivation()) {
79
-                return;
80
-            }
81
-            $route = $this->loader->getShared($fqcn);
82
-            $this->validateRoute($route, $fqcn);
83
-            $this->routes->add($route);
84
-            $this->handle($route, $handle);
85
-        } catch (Exception $exception) {
86
-            new ExceptionStackTraceDisplay($exception);
87
-        }
88
-    }
89
-
90
-
91
-    /**
92
-     * @param RouteInterface $route
93
-     * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest()
94
-     */
95
-    public function handle(RouteInterface $route, $handle = true)
96
-    {
97
-        if ($handle && $route->isNotHandled()) {
98
-            $route->handleRequest();
99
-            $data_node = $route->dataNode();
100
-            if ($data_node instanceof JsonDataNode) {
101
-                $this->data_node_handler->addDataNode($data_node);
102
-            }
103
-        }
104
-    }
105
-
106
-
107
-    /**
108
-     * calls RouteInterface::handleRequest() on all Routes that
109
-     *      - match current request
110
-     *      - have yet to be handled
111
-     *
112
-     * @return void
113
-     */
114
-    public function handleRoutesForCurrentRequest()
115
-    {
116
-        $this->routes->handleRoutesForCurrentRequest();
117
-    }
118
-
119
-
120
-    /**
121
-     * @param RouteInterface $route
122
-     * @param string         $fqcn
123
-     * @since $VID:$
124
-     */
125
-    private function validateRoute($route, $fqcn)
126
-    {
127
-        if (! $route instanceof RouteInterface) {
128
-            throw new InvalidClassException(
129
-                sprintf(
130
-                    /*
23
+	/**
24
+	 * @var JsonDataNodeHandler $data_node_handler
25
+	 */
26
+	private $data_node_handler;
27
+
28
+	/**
29
+	 * @var LoaderInterface $loader
30
+	 */
31
+	private $loader;
32
+
33
+	/**
34
+	 * @var RequestInterface $request
35
+	 */
36
+	protected $request;
37
+
38
+	/**
39
+	 * @var RouteCollection $routes
40
+	 */
41
+	private $routes;
42
+
43
+
44
+	/**
45
+	 * RouteHandler constructor.
46
+	 *
47
+	 * @param JsonDataNodeHandler $data_node_handler
48
+	 * @param LoaderInterface  $loader
49
+	 * @param RequestInterface $request
50
+	 * @param RouteCollection $routes
51
+	 */
52
+	public function __construct(
53
+		JsonDataNodeHandler $data_node_handler,
54
+		LoaderInterface $loader,
55
+		RequestInterface $request,
56
+		RouteCollection $routes
57
+	) {
58
+		$this->data_node_handler = $data_node_handler;
59
+		$this->loader = $loader;
60
+		$this->request = $request;
61
+		$this->routes = $routes;
62
+		if (! $this->request->isActivation()) {
63
+			add_action('admin_footer', [$this->data_node_handler, 'printDataNode']);
64
+			add_action('wp_footer', [$this->data_node_handler, 'printDataNode']);
65
+		}
66
+	}
67
+
68
+
69
+	/**
70
+	 * @param string $fqcn   Fully Qualified Class Name for Route
71
+	 * @param bool   $handle if true [default] will immediately call RouteInterface::handleRequest() after adding
72
+	 * @throws Exception
73
+	 * @since $VID:$
74
+	 */
75
+	public function addRoute($fqcn, $handle = true)
76
+	{
77
+		try {
78
+			if ($this->request->isActivation()) {
79
+				return;
80
+			}
81
+			$route = $this->loader->getShared($fqcn);
82
+			$this->validateRoute($route, $fqcn);
83
+			$this->routes->add($route);
84
+			$this->handle($route, $handle);
85
+		} catch (Exception $exception) {
86
+			new ExceptionStackTraceDisplay($exception);
87
+		}
88
+	}
89
+
90
+
91
+	/**
92
+	 * @param RouteInterface $route
93
+	 * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest()
94
+	 */
95
+	public function handle(RouteInterface $route, $handle = true)
96
+	{
97
+		if ($handle && $route->isNotHandled()) {
98
+			$route->handleRequest();
99
+			$data_node = $route->dataNode();
100
+			if ($data_node instanceof JsonDataNode) {
101
+				$this->data_node_handler->addDataNode($data_node);
102
+			}
103
+		}
104
+	}
105
+
106
+
107
+	/**
108
+	 * calls RouteInterface::handleRequest() on all Routes that
109
+	 *      - match current request
110
+	 *      - have yet to be handled
111
+	 *
112
+	 * @return void
113
+	 */
114
+	public function handleRoutesForCurrentRequest()
115
+	{
116
+		$this->routes->handleRoutesForCurrentRequest();
117
+	}
118
+
119
+
120
+	/**
121
+	 * @param RouteInterface $route
122
+	 * @param string         $fqcn
123
+	 * @since $VID:$
124
+	 */
125
+	private function validateRoute($route, $fqcn)
126
+	{
127
+		if (! $route instanceof RouteInterface) {
128
+			throw new InvalidClassException(
129
+				sprintf(
130
+					/*
131 131
                      * translators:
132 132
                      * The supplied FQCN (Fully\Qualified\Class\Name) must be an instance of RouteInterface.
133 133
                     */
134
-                    esc_html__(
135
-                        'The supplied FQCN (%1$s) must be an instance of RouteInterface.',
136
-                        'event_espresso'
137
-                    ),
138
-                    $fqcn
139
-                )
140
-            );
141
-        }
142
-    }
134
+					esc_html__(
135
+						'The supplied FQCN (%1$s) must be an instance of RouteInterface.',
136
+						'event_espresso'
137
+					),
138
+					$fqcn
139
+				)
140
+			);
141
+		}
142
+	}
143 143
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $this->loader = $loader;
60 60
         $this->request = $request;
61 61
         $this->routes = $routes;
62
-        if (! $this->request->isActivation()) {
62
+        if ( ! $this->request->isActivation()) {
63 63
             add_action('admin_footer', [$this->data_node_handler, 'printDataNode']);
64 64
             add_action('wp_footer', [$this->data_node_handler, 'printDataNode']);
65 65
         }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     private function validateRoute($route, $fqcn)
126 126
     {
127
-        if (! $route instanceof RouteInterface) {
127
+        if ( ! $route instanceof RouteInterface) {
128 128
             throw new InvalidClassException(
129 129
                 sprintf(
130 130
                     /*
Please login to merge, or discard this patch.