Completed
Branch EDTR/master (83b47e)
by
unknown
25:37 queued 16:41
created
core/services/options/JsonWpOptionManager.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -16,39 +16,39 @@
 block discarded – undo
16 16
  */
17 17
 class JsonWpOptionManager
18 18
 {
19
-    /**
20
-     * Updates the object with what's in the DB (specifically, the wp_options table). If nothing is in the DB, leaves
21
-     * the object alone and returns false.
22
-     * @since 4.9.80.p
23
-     * @param JsonWpOptionSerializableInterface $obj
24
-     * @return bool
25
-     */
26
-    public function populateFromDb(JsonWpOptionSerializableInterface $obj)
27
-    {
28
-        $option = get_option($obj->getWpOptionName());
29
-        if ($option) {
30
-            $json = json_decode($option, false);
31
-            if ($json instanceof stdClass) {
32
-                return $obj->fromJsonSerializedData($json);
33
-            }
34
-        }
35
-        return false;
36
-    }
19
+	/**
20
+	 * Updates the object with what's in the DB (specifically, the wp_options table). If nothing is in the DB, leaves
21
+	 * the object alone and returns false.
22
+	 * @since 4.9.80.p
23
+	 * @param JsonWpOptionSerializableInterface $obj
24
+	 * @return bool
25
+	 */
26
+	public function populateFromDb(JsonWpOptionSerializableInterface $obj)
27
+	{
28
+		$option = get_option($obj->getWpOptionName());
29
+		if ($option) {
30
+			$json = json_decode($option, false);
31
+			if ($json instanceof stdClass) {
32
+				return $obj->fromJsonSerializedData($json);
33
+			}
34
+		}
35
+		return false;
36
+	}
37 37
 
38
-    /**
39
-     * Saves the object's data to the wp_options table for later use.
40
-     * @since 4.9.80.p
41
-     * @param JsonWpOptionSerializableInterface $obj
42
-     * @return bool
43
-     */
44
-    public function saveToDb(JsonWpOptionSerializableInterface $obj)
45
-    {
46
-        return update_option(
47
-            $obj->getWpOptionName(),
48
-            wp_json_encode($obj->toJsonSerializableData()),
49
-            false
50
-        );
51
-    }
38
+	/**
39
+	 * Saves the object's data to the wp_options table for later use.
40
+	 * @since 4.9.80.p
41
+	 * @param JsonWpOptionSerializableInterface $obj
42
+	 * @return bool
43
+	 */
44
+	public function saveToDb(JsonWpOptionSerializableInterface $obj)
45
+	{
46
+		return update_option(
47
+			$obj->getWpOptionName(),
48
+			wp_json_encode($obj->toJsonSerializableData()),
49
+			false
50
+		);
51
+	}
52 52
 }
53 53
 // End of file JsonWpOptionManager.php
54 54
 // Location: EventEspresso\core\services\options/JsonWpOptionManager.php
Please login to merge, or discard this patch.
core/services/json/JsonDataNodeValidator.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      */
24 24
     public function propertyNotSet(array $data, $key, $type = 'key')
25 25
     {
26
-        if (isset($data[ $key ])) {
26
+        if (isset($data[$key])) {
27 27
             $this->overwriteError($key, $type);
28 28
             return false;
29 29
         }
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -14,76 +14,76 @@
 block discarded – undo
14 14
 class JsonDataNodeValidator
15 15
 {
16 16
 
17
-    /**
18
-     * @param array  $data      data array to check for property key
19
-     * @param string $key       value for the key being checked for
20
-     * @param string $type      the type of key and/or the data being checked
21
-     * @return bool             returns true if property is safe to write, false if overwrite will occur
22
-     * @throws DomainException  throws exception if WP_DEBUG is true
23
-     */
24
-    public function propertyNotSet(array $data, $key, $type = 'key')
25
-    {
26
-        if (isset($data[ $key ])) {
27
-            $this->overwriteError($key, $type);
28
-            return false;
29
-        }
30
-        return true;
31
-    }
17
+	/**
18
+	 * @param array  $data      data array to check for property key
19
+	 * @param string $key       value for the key being checked for
20
+	 * @param string $type      the type of key and/or the data being checked
21
+	 * @return bool             returns true if property is safe to write, false if overwrite will occur
22
+	 * @throws DomainException  throws exception if WP_DEBUG is true
23
+	 */
24
+	public function propertyNotSet(array $data, $key, $type = 'key')
25
+	{
26
+		if (isset($data[ $key ])) {
27
+			$this->overwriteError($key, $type);
28
+			return false;
29
+		}
30
+		return true;
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * @param string $key       value for the key being checked for
36
-     * @param string $type      the type of key and/or the data being checked
37
-     * @throws DomainException  throws exception if WP_DEBUG is true
38
-     */
39
-    public function overwriteError($key, $type)
40
-    {
41
-        if (WP_DEBUG) {
42
-            throw new DomainException(
43
-                sprintf(
44
-                    /*
34
+	/**
35
+	 * @param string $key       value for the key being checked for
36
+	 * @param string $type      the type of key and/or the data being checked
37
+	 * @throws DomainException  throws exception if WP_DEBUG is true
38
+	 */
39
+	public function overwriteError($key, $type)
40
+	{
41
+		if (WP_DEBUG) {
42
+			throw new DomainException(
43
+				sprintf(
44
+					/*
45 45
                      * translators:
46 46
                      * 'The "i18n" JsonDataNode key is already set and would be overwritten by the current action.'
47 47
                      */
48
-                    esc_html__(
49
-                        'The "%1$s" JsonDataNode %2$s is already set and would be overwritten by the current action.',
50
-                        'event_espresso'
51
-                    ),
52
-                    $key,
53
-                    $type
54
-                )
55
-            );
56
-        }
57
-    }
48
+					esc_html__(
49
+						'The "%1$s" JsonDataNode %2$s is already set and would be overwritten by the current action.',
50
+						'event_espresso'
51
+					),
52
+					$key,
53
+					$type
54
+				)
55
+			);
56
+		}
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * @param string $property  name for the key being checked for
62
-     * @param string $type      the type of key and/or the data being checked
63
-     * @param bool   $throw     if true [default] and WP_DEBUG is also true, then will throw exceptions
64
-     * @return bool             returns true if property is set, false if property is missing
65
-     * @throws DomainException  throws exception if WP_DEBUG is true
66
-     */
67
-    public function validateCriticalProperty($property, $type, $throw = true)
68
-    {
69
-        if (empty($property)) {
70
-            if (WP_DEBUG && $throw) {
71
-                throw new DomainException(
72
-                    sprintf(
73
-                        /*
60
+	/**
61
+	 * @param string $property  name for the key being checked for
62
+	 * @param string $type      the type of key and/or the data being checked
63
+	 * @param bool   $throw     if true [default] and WP_DEBUG is also true, then will throw exceptions
64
+	 * @return bool             returns true if property is set, false if property is missing
65
+	 * @throws DomainException  throws exception if WP_DEBUG is true
66
+	 */
67
+	public function validateCriticalProperty($property, $type, $throw = true)
68
+	{
69
+		if (empty($property)) {
70
+			if (WP_DEBUG && $throw) {
71
+				throw new DomainException(
72
+					sprintf(
73
+						/*
74 74
                          * translators:
75 75
                          * 'The JsonDataNodeHandler domain route is a required property but has not been set.'
76 76
                          */
77
-                        esc_html__(
78
-                            'The JsonDataNodeHandler %1$s is a required property but has not been set.',
79
-                            'event_espresso'
80
-                        ),
81
-                        $type
82
-                    )
83
-                );
84
-            }
85
-            return false;
86
-        }
87
-        return true;
88
-    }
77
+						esc_html__(
78
+							'The JsonDataNodeHandler %1$s is a required property but has not been set.',
79
+							'event_espresso'
80
+						),
81
+						$type
82
+					)
83
+				);
84
+			}
85
+			return false;
86
+		}
87
+		return true;
88
+	}
89 89
 }
Please login to merge, or discard this patch.
core/services/json/JsonDataNodeHandler.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -18,129 +18,129 @@
 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
-     * JsonDataNodeHandler constructor.
34
-     *
35
-     * @param JsonDataNodeValidator $validator
36
-     */
37
-    public function __construct(JsonDataNodeValidator $validator)
38
-    {
39
-        $this->validator = $validator;
40
-    }
41
-
42
-
43
-    /**
44
-     * @param JsonDataNode $data_node
45
-     * @throws DomainException
46
-     */
47
-    public function addDataNode(JsonDataNode $data_node)
48
-    {
49
-        if ($data_node->isNotInitialized()) {
50
-            $this->validatePrimaryDataNode($data_node);
51
-            $this->primary_data_node->addDataNode($data_node);
52
-        }
53
-    }
54
-
55
-
56
-    /**
57
-     * @param PrimaryJsonDataNode $primary_data_node
58
-     */
59
-    public function setPrimaryDataNode(PrimaryJsonDataNode $primary_data_node)
60
-    {
61
-        $this->primary_data_node = $primary_data_node;
62
-    }
63
-
64
-
65
-    /**
66
-     * @param JsonDataNode $data_node
67
-     * @param int                $depth
68
-     * @return mixed
69
-     * @since $VID:$
70
-     */
71
-    private function initializeDataNodes(JsonDataNode $data_node, $depth = 0)
72
-    {
73
-        $depth++;
74
-        $data = [];
75
-        // initialize the data node if not done already
76
-        if ($data_node->isNotInitialized()) {
77
-            $data_node->initialize();
78
-            // grab the data node's data array
79
-            $data_node_data = $data_node->data();
80
-            foreach ($data_node_data as $child_node_name => $child_node) {
81
-                // don't parse node if it's the primary, OR if depth has exceeded wp_json_encode() limit
82
-                if ($child_node instanceof PrimaryJsonDataNode || $depth > 512) {
83
-                    continue;
84
-                }
85
-                if ($child_node instanceof JsonDataNode) {
86
-                    // feed data node back into this function
87
-                    $data[ $child_node_name ] = $this->initializeDataNodes($child_node, $depth);
88
-                } else {
89
-                    // or assign data directly
90
-                    $data[ $child_node_name ] = $child_node;
91
-                }
92
-            }
93
-        }
94
-        return $data;
95
-    }
96
-
97
-
98
-    /**
99
-     * @throws DomainException
100
-     * @since $VID:$
101
-     */
102
-    public function printDataNode()
103
-    {
104
-        // validate that the domain, node name, and target script are set
105
-        $domain = $this->primary_data_node->domain();
106
-        $node_name = $this->primary_data_node->nodeName();
107
-        $target_script = $this->primary_data_node->targetScript();
108
-        $data_valid =  $this->validator->validateCriticalProperty($domain, 'domain route', false)
109
-                       && $this->validator->validateCriticalProperty($node_name, 'node name', false)
110
-                       && $this->validator->validateCriticalProperty($target_script, 'target script', false);
111
-        if (! $data_valid) {
112
-            return;
113
-        }
114
-        // initialize and parse data from primary data node
115
-        $data = $this->initializeDataNodes($this->primary_data_node);
116
-        // this prepends the current domain "use case" to the front of the array
117
-        $data = ['domain' => $domain] + $data;
118
-        // add legacy i18n strings
119
-        $data['eei18n'] = EE_Registry::$i18n_js_strings;
120
-        // and finally JSON encode the data and attach to the target script
121
-        $data = json_encode($data);
122
-        wp_add_inline_script($target_script, "var {$node_name}={$data};", 'before');
123
-    }
124
-
125
-
126
-    /**
127
-     * @param JsonDataNode $data_node
128
-     * @throws DomainException
129
-     */
130
-    private function validatePrimaryDataNode(JsonDataNode $data_node)
131
-    {
132
-        // set primary data node if that's what the incoming node is
133
-        if ($data_node instanceof PrimaryJsonDataNode) {
134
-            $this->setPrimaryDataNode($data_node);
135
-        }
136
-        // and don't allow other nodes to be set until a primary is set
137
-        if (! $this->primary_data_node instanceof PrimaryJsonDataNode) {
138
-            throw new DomainException(
139
-                esc_html__(
140
-                    'A PrimaryJsonDataNode needs to be set before data nodes can be added.',
141
-                    'event_espresso'
142
-                )
143
-            );
144
-        }
145
-    }
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
+	 * JsonDataNodeHandler constructor.
34
+	 *
35
+	 * @param JsonDataNodeValidator $validator
36
+	 */
37
+	public function __construct(JsonDataNodeValidator $validator)
38
+	{
39
+		$this->validator = $validator;
40
+	}
41
+
42
+
43
+	/**
44
+	 * @param JsonDataNode $data_node
45
+	 * @throws DomainException
46
+	 */
47
+	public function addDataNode(JsonDataNode $data_node)
48
+	{
49
+		if ($data_node->isNotInitialized()) {
50
+			$this->validatePrimaryDataNode($data_node);
51
+			$this->primary_data_node->addDataNode($data_node);
52
+		}
53
+	}
54
+
55
+
56
+	/**
57
+	 * @param PrimaryJsonDataNode $primary_data_node
58
+	 */
59
+	public function setPrimaryDataNode(PrimaryJsonDataNode $primary_data_node)
60
+	{
61
+		$this->primary_data_node = $primary_data_node;
62
+	}
63
+
64
+
65
+	/**
66
+	 * @param JsonDataNode $data_node
67
+	 * @param int                $depth
68
+	 * @return mixed
69
+	 * @since $VID:$
70
+	 */
71
+	private function initializeDataNodes(JsonDataNode $data_node, $depth = 0)
72
+	{
73
+		$depth++;
74
+		$data = [];
75
+		// initialize the data node if not done already
76
+		if ($data_node->isNotInitialized()) {
77
+			$data_node->initialize();
78
+			// grab the data node's data array
79
+			$data_node_data = $data_node->data();
80
+			foreach ($data_node_data as $child_node_name => $child_node) {
81
+				// don't parse node if it's the primary, OR if depth has exceeded wp_json_encode() limit
82
+				if ($child_node instanceof PrimaryJsonDataNode || $depth > 512) {
83
+					continue;
84
+				}
85
+				if ($child_node instanceof JsonDataNode) {
86
+					// feed data node back into this function
87
+					$data[ $child_node_name ] = $this->initializeDataNodes($child_node, $depth);
88
+				} else {
89
+					// or assign data directly
90
+					$data[ $child_node_name ] = $child_node;
91
+				}
92
+			}
93
+		}
94
+		return $data;
95
+	}
96
+
97
+
98
+	/**
99
+	 * @throws DomainException
100
+	 * @since $VID:$
101
+	 */
102
+	public function printDataNode()
103
+	{
104
+		// validate that the domain, node name, and target script are set
105
+		$domain = $this->primary_data_node->domain();
106
+		$node_name = $this->primary_data_node->nodeName();
107
+		$target_script = $this->primary_data_node->targetScript();
108
+		$data_valid =  $this->validator->validateCriticalProperty($domain, 'domain route', false)
109
+					   && $this->validator->validateCriticalProperty($node_name, 'node name', false)
110
+					   && $this->validator->validateCriticalProperty($target_script, 'target script', false);
111
+		if (! $data_valid) {
112
+			return;
113
+		}
114
+		// initialize and parse data from primary data node
115
+		$data = $this->initializeDataNodes($this->primary_data_node);
116
+		// this prepends the current domain "use case" to the front of the array
117
+		$data = ['domain' => $domain] + $data;
118
+		// add legacy i18n strings
119
+		$data['eei18n'] = EE_Registry::$i18n_js_strings;
120
+		// and finally JSON encode the data and attach to the target script
121
+		$data = json_encode($data);
122
+		wp_add_inline_script($target_script, "var {$node_name}={$data};", 'before');
123
+	}
124
+
125
+
126
+	/**
127
+	 * @param JsonDataNode $data_node
128
+	 * @throws DomainException
129
+	 */
130
+	private function validatePrimaryDataNode(JsonDataNode $data_node)
131
+	{
132
+		// set primary data node if that's what the incoming node is
133
+		if ($data_node instanceof PrimaryJsonDataNode) {
134
+			$this->setPrimaryDataNode($data_node);
135
+		}
136
+		// and don't allow other nodes to be set until a primary is set
137
+		if (! $this->primary_data_node instanceof PrimaryJsonDataNode) {
138
+			throw new DomainException(
139
+				esc_html__(
140
+					'A PrimaryJsonDataNode needs to be set before data nodes can be added.',
141
+					'event_espresso'
142
+				)
143
+			);
144
+		}
145
+	}
146 146
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
                 }
85 85
                 if ($child_node instanceof JsonDataNode) {
86 86
                     // feed data node back into this function
87
-                    $data[ $child_node_name ] = $this->initializeDataNodes($child_node, $depth);
87
+                    $data[$child_node_name] = $this->initializeDataNodes($child_node, $depth);
88 88
                 } else {
89 89
                     // or assign data directly
90
-                    $data[ $child_node_name ] = $child_node;
90
+                    $data[$child_node_name] = $child_node;
91 91
                 }
92 92
             }
93 93
         }
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
         $domain = $this->primary_data_node->domain();
106 106
         $node_name = $this->primary_data_node->nodeName();
107 107
         $target_script = $this->primary_data_node->targetScript();
108
-        $data_valid =  $this->validator->validateCriticalProperty($domain, 'domain route', false)
108
+        $data_valid = $this->validator->validateCriticalProperty($domain, 'domain route', false)
109 109
                        && $this->validator->validateCriticalProperty($node_name, 'node name', false)
110 110
                        && $this->validator->validateCriticalProperty($target_script, 'target script', false);
111
-        if (! $data_valid) {
111
+        if ( ! $data_valid) {
112 112
             return;
113 113
         }
114 114
         // initialize and parse data from primary data node
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
             $this->setPrimaryDataNode($data_node);
135 135
         }
136 136
         // and don't allow other nodes to be set until a primary is set
137
-        if (! $this->primary_data_node instanceof PrimaryJsonDataNode) {
137
+        if ( ! $this->primary_data_node instanceof PrimaryJsonDataNode) {
138 138
             throw new DomainException(
139 139
                 esc_html__(
140 140
                     '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 2 patches
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -18,183 +18,183 @@
 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
-     * JsonDataNodeHandler constructor.
49
-     *
50
-     * @param JsonDataNodeValidator $validator
51
-     * @throws DomainException
52
-     */
53
-    public function __construct(JsonDataNodeValidator $validator)
54
-    {
55
-        $this->validator = $validator;
56
-    }
57
-
58
-
59
-    /**
60
-     * for adding primitive data like arrays, integers, or strings
61
-     *
62
-     * @param string $key
63
-     * @param mixed  $data
64
-     * @throws DomainException
65
-     */
66
-    protected function addData($key, $data)
67
-    {
68
-        if ($this->validator->propertyNotSet($this->data, $key)) {
69
-            $this->data[ $key ] = $data;
70
-        }
71
-    }
72
-
73
-
74
-    /**
75
-     * for embedding other JsonDataNode objects within this one
76
-     *
77
-     * @param JsonDataNode $data_node
78
-     * @throws DomainException
79
-     */
80
-    public function addDataNode(JsonDataNode $data_node)
81
-    {
82
-        if ($data_node->isNotInitialized()) {
83
-            // $data_node->initialize();
84
-            $key = $data_node->nodeName();
85
-            $this->addData($key, $data_node);
86
-            // if the node being added specifies a domain (use case)
87
-            // and this is the primary data node, then set the domain
88
-            if ($this instanceof PrimaryJsonDataNode && $data_node->domain() !== null) {
89
-                $this->setDomain($data_node->domain());
90
-            }
91
-        }
92
-    }
93
-
94
-
95
-    /**
96
-     * sets the domain (use case) that this data node provides data for
97
-     *
98
-     * @param string $domain
99
-     * @throws DomainException
100
-     */
101
-    protected function setDomain($domain)
102
-    {
103
-        if ($this->domain !== null) {
104
-            $this->validator->overwriteError($domain, 'domain route');
105
-        }
106
-        $this->domain = $domain;
107
-    }
108
-
109
-
110
-    /**
111
-     * used to mark the data node as having been processed
112
-     *
113
-     * @param bool $initialized
114
-     */
115
-    protected function setInitialized($initialized)
116
-    {
117
-        $this->initialized = filter_var($initialized, FILTER_VALIDATE_BOOLEAN);
118
-    }
119
-
120
-
121
-    /**
122
-     * self explanatory (i hope)
123
-     *
124
-     * @param string $node_name
125
-     * @throws DomainException
126
-     */
127
-    protected function setNodeName($node_name)
128
-    {
129
-        $this->validator->validateCriticalProperty($node_name, 'node name');
130
-        $this->node_name = $node_name;
131
-    }
132
-
133
-
134
-    /**
135
-     * the actual data in key value array format
136
-     *
137
-     * @return array
138
-     */
139
-    public function data()
140
-    {
141
-        return $this->data;
142
-    }
143
-
144
-
145
-    /**
146
-     * the domain (use case) that this data node provides data for
147
-     *
148
-     * @return string
149
-     */
150
-    public function domain()
151
-    {
152
-        return $this->domain;
153
-    }
154
-
155
-
156
-    /**
157
-     * true if the data node has been initialized,
158
-     * which entails retrieving the required data and adding it to the data node data array
159
-     *
160
-     * @return bool
161
-     */
162
-    public function isInitialized()
163
-    {
164
-        return $this->initialized;
165
-    }
166
-
167
-
168
-    /**
169
-     * true if the data node has NOT been initialized
170
-     *
171
-     * @return bool
172
-     */
173
-    public function isNotInitialized()
174
-    {
175
-        return ! $this->initialized;
176
-    }
177
-
178
-
179
-    /**
180
-     * Specify data which should be serialized to JSON
181
-     *
182
-     * @link  https://php.net/manual/en/jsonserializable.jsonserialize.php
183
-     * @return mixed data which can be serialized by json_encode
184
-     */
185
-    public function jsonSerialize()
186
-    {
187
-        return $this->data;
188
-    }
189
-
190
-
191
-    /**
192
-     * self explanatory (i hope)
193
-     *
194
-     * @return string
195
-     */
196
-    public function nodeName()
197
-    {
198
-        return $this->node_name;
199
-    }
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
+	 * JsonDataNodeHandler constructor.
49
+	 *
50
+	 * @param JsonDataNodeValidator $validator
51
+	 * @throws DomainException
52
+	 */
53
+	public function __construct(JsonDataNodeValidator $validator)
54
+	{
55
+		$this->validator = $validator;
56
+	}
57
+
58
+
59
+	/**
60
+	 * for adding primitive data like arrays, integers, or strings
61
+	 *
62
+	 * @param string $key
63
+	 * @param mixed  $data
64
+	 * @throws DomainException
65
+	 */
66
+	protected function addData($key, $data)
67
+	{
68
+		if ($this->validator->propertyNotSet($this->data, $key)) {
69
+			$this->data[ $key ] = $data;
70
+		}
71
+	}
72
+
73
+
74
+	/**
75
+	 * for embedding other JsonDataNode objects within this one
76
+	 *
77
+	 * @param JsonDataNode $data_node
78
+	 * @throws DomainException
79
+	 */
80
+	public function addDataNode(JsonDataNode $data_node)
81
+	{
82
+		if ($data_node->isNotInitialized()) {
83
+			// $data_node->initialize();
84
+			$key = $data_node->nodeName();
85
+			$this->addData($key, $data_node);
86
+			// if the node being added specifies a domain (use case)
87
+			// and this is the primary data node, then set the domain
88
+			if ($this instanceof PrimaryJsonDataNode && $data_node->domain() !== null) {
89
+				$this->setDomain($data_node->domain());
90
+			}
91
+		}
92
+	}
93
+
94
+
95
+	/**
96
+	 * sets the domain (use case) that this data node provides data for
97
+	 *
98
+	 * @param string $domain
99
+	 * @throws DomainException
100
+	 */
101
+	protected function setDomain($domain)
102
+	{
103
+		if ($this->domain !== null) {
104
+			$this->validator->overwriteError($domain, 'domain route');
105
+		}
106
+		$this->domain = $domain;
107
+	}
108
+
109
+
110
+	/**
111
+	 * used to mark the data node as having been processed
112
+	 *
113
+	 * @param bool $initialized
114
+	 */
115
+	protected function setInitialized($initialized)
116
+	{
117
+		$this->initialized = filter_var($initialized, FILTER_VALIDATE_BOOLEAN);
118
+	}
119
+
120
+
121
+	/**
122
+	 * self explanatory (i hope)
123
+	 *
124
+	 * @param string $node_name
125
+	 * @throws DomainException
126
+	 */
127
+	protected function setNodeName($node_name)
128
+	{
129
+		$this->validator->validateCriticalProperty($node_name, 'node name');
130
+		$this->node_name = $node_name;
131
+	}
132
+
133
+
134
+	/**
135
+	 * the actual data in key value array format
136
+	 *
137
+	 * @return array
138
+	 */
139
+	public function data()
140
+	{
141
+		return $this->data;
142
+	}
143
+
144
+
145
+	/**
146
+	 * the domain (use case) that this data node provides data for
147
+	 *
148
+	 * @return string
149
+	 */
150
+	public function domain()
151
+	{
152
+		return $this->domain;
153
+	}
154
+
155
+
156
+	/**
157
+	 * true if the data node has been initialized,
158
+	 * which entails retrieving the required data and adding it to the data node data array
159
+	 *
160
+	 * @return bool
161
+	 */
162
+	public function isInitialized()
163
+	{
164
+		return $this->initialized;
165
+	}
166
+
167
+
168
+	/**
169
+	 * true if the data node has NOT been initialized
170
+	 *
171
+	 * @return bool
172
+	 */
173
+	public function isNotInitialized()
174
+	{
175
+		return ! $this->initialized;
176
+	}
177
+
178
+
179
+	/**
180
+	 * Specify data which should be serialized to JSON
181
+	 *
182
+	 * @link  https://php.net/manual/en/jsonserializable.jsonserialize.php
183
+	 * @return mixed data which can be serialized by json_encode
184
+	 */
185
+	public function jsonSerialize()
186
+	{
187
+		return $this->data;
188
+	}
189
+
190
+
191
+	/**
192
+	 * self explanatory (i hope)
193
+	 *
194
+	 * @return string
195
+	 */
196
+	public function nodeName()
197
+	{
198
+		return $this->node_name;
199
+	}
200 200
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
     protected function addData($key, $data)
67 67
     {
68 68
         if ($this->validator->propertyNotSet($this->data, $key)) {
69
-            $this->data[ $key ] = $data;
69
+            $this->data[$key] = $data;
70 70
         }
71 71
     }
72 72
 
Please login to merge, or discard this patch.
core/services/graphql/GraphQLManager.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -16,76 +16,76 @@
 block discarded – undo
16 16
 class GraphQLManager implements GQLManagerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var ConnectionsManager $connections_manager
21
-     */
22
-    protected $connections_manager;
19
+	/**
20
+	 * @var ConnectionsManager $connections_manager
21
+	 */
22
+	protected $connections_manager;
23 23
 
24
-    /**
25
-     * @var DataLoaderManager $data_loader_manager
26
-     */
27
-    protected $data_loader_manager;
24
+	/**
25
+	 * @var DataLoaderManager $data_loader_manager
26
+	 */
27
+	protected $data_loader_manager;
28 28
 
29
-    /**
30
-     * @var EnumsManager $enums_manager
31
-     */
32
-    protected $enums_manager;
29
+	/**
30
+	 * @var EnumsManager $enums_manager
31
+	 */
32
+	protected $enums_manager;
33 33
 
34
-    /**
35
-     * @var InputsManager $inputs_manager
36
-     */
37
-    protected $inputs_manager;
34
+	/**
35
+	 * @var InputsManager $inputs_manager
36
+	 */
37
+	protected $inputs_manager;
38 38
 
39
-    /**
40
-     * @var TypesManager $types_manager
41
-     */
42
-    protected $types_manager;
39
+	/**
40
+	 * @var TypesManager $types_manager
41
+	 */
42
+	protected $types_manager;
43 43
 
44
-    /**
45
-     * @var boolean $initialized
46
-     */
47
-    private $initialized = false;
44
+	/**
45
+	 * @var boolean $initialized
46
+	 */
47
+	private $initialized = false;
48 48
 
49 49
 
50
-    /**
51
-     * GraphQLManager constructor.
52
-     *
53
-     * @param ConnectionsManager $connections_manager
54
-     * @param DataLoaderManager $data_loader_manager
55
-     * @param EnumsManager $enums_manager
56
-     * @param InputsManager $inputs_manager
57
-     * @param TypesManager $types_manager
58
-     */
59
-    public function __construct(
60
-        ConnectionsManager $connections_manager,
61
-        DataLoaderManager $data_loader_manager,
62
-        EnumsManager $enums_manager,
63
-        InputsManager $inputs_manager,
64
-        TypesManager $types_manager
65
-    ) {
66
-        $this->connections_manager = $connections_manager;
67
-        $this->data_loader_manager = $data_loader_manager;
68
-        $this->enums_manager = $enums_manager;
69
-        $this->inputs_manager = $inputs_manager;
70
-        $this->types_manager = $types_manager;
71
-    }
50
+	/**
51
+	 * GraphQLManager constructor.
52
+	 *
53
+	 * @param ConnectionsManager $connections_manager
54
+	 * @param DataLoaderManager $data_loader_manager
55
+	 * @param EnumsManager $enums_manager
56
+	 * @param InputsManager $inputs_manager
57
+	 * @param TypesManager $types_manager
58
+	 */
59
+	public function __construct(
60
+		ConnectionsManager $connections_manager,
61
+		DataLoaderManager $data_loader_manager,
62
+		EnumsManager $enums_manager,
63
+		InputsManager $inputs_manager,
64
+		TypesManager $types_manager
65
+	) {
66
+		$this->connections_manager = $connections_manager;
67
+		$this->data_loader_manager = $data_loader_manager;
68
+		$this->enums_manager = $enums_manager;
69
+		$this->inputs_manager = $inputs_manager;
70
+		$this->types_manager = $types_manager;
71
+	}
72 72
 
73 73
 
74
-    /**
75
-     * @throws CollectionDetailsException
76
-     * @throws CollectionLoaderException
77
-     * @since $VID:$
78
-     */
79
-    public function init()
80
-    {
81
-        if ($this->initialized) {
82
-            return;
83
-        }
84
-        $this->connections_manager->init();
85
-        $this->data_loader_manager->init();
86
-        $this->enums_manager->init();
87
-        $this->inputs_manager->init();
88
-        $this->types_manager->init();
89
-        $this->initialized = true;
90
-    }
74
+	/**
75
+	 * @throws CollectionDetailsException
76
+	 * @throws CollectionLoaderException
77
+	 * @since $VID:$
78
+	 */
79
+	public function init()
80
+	{
81
+		if ($this->initialized) {
82
+			return;
83
+		}
84
+		$this->connections_manager->init();
85
+		$this->data_loader_manager->init();
86
+		$this->enums_manager->init();
87
+		$this->inputs_manager->init();
88
+		$this->types_manager->init();
89
+		$this->initialized = true;
90
+	}
91 91
 }
Please login to merge, or discard this patch.
core/services/assets/BlockAssetManager.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function setEditorScriptHandle($editor_script_handle)
61 61
     {
62
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
63
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
62
+        if (strpos($editor_script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
63
+            $editor_script_handle = BlockInterface::NAME_SPACE.'-'.$editor_script_handle;
64 64
         }
65 65
         $this->editor_script_handle = $editor_script_handle;
66 66
     }
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function setEditorStyleHandle($editor_style_handle)
82 82
     {
83
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
84
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
83
+        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
84
+            $editor_style_handle = BlockInterface::NAME_SPACE.'-'.$editor_style_handle;
85 85
         }
86 86
         $this->editor_style_handle = $editor_style_handle;
87 87
     }
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public function setScriptHandle($script_handle)
103 103
     {
104
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
105
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
104
+        if (strpos($script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
105
+            $script_handle = BlockInterface::NAME_SPACE.'-'.$script_handle;
106 106
         }
107 107
         $this->script_handle = $script_handle;
108 108
     }
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function setStyleHandle($style_handle)
124 124
     {
125
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
126
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
125
+        if (strpos($style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
126
+            $style_handle = BlockInterface::NAME_SPACE.'-'.$style_handle;
127 127
         }
128 128
         $this->style_handle = $style_handle;
129 129
     }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function addEditorScript($handle, array $dependencies = array())
156 156
     {
157
-        if ($this->assets->hasJavascriptAsset($handle)){
157
+        if ($this->assets->hasJavascriptAsset($handle)) {
158 158
             return $this->assets->getJavascriptAsset($handle);
159 159
         }
160 160
         $dependencies = array_merge(
Please login to merge, or discard this patch.
Indentation   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -21,253 +21,253 @@
 block discarded – undo
21 21
  */
22 22
 abstract class BlockAssetManager extends AssetManager implements BlockAssetManagerInterface
23 23
 {
24
-    /**
25
-     * @var string $editor_script_handle
26
-     */
27
-    private $editor_script_handle;
28
-
29
-    /**
30
-     * @var string $editor_style_handle
31
-     */
32
-    private $editor_style_handle;
33
-
34
-    /**
35
-     * @var string $script_handle
36
-     */
37
-    private $script_handle;
38
-
39
-    /**
40
-     * @var string $style_handle
41
-     */
42
-    private $style_handle;
43
-
44
-
45
-    /**
46
-     * @return string
47
-     */
48
-    public function getEditorScriptHandle()
49
-    {
50
-        return $this->editor_script_handle;
51
-    }
52
-
53
-
54
-    /**
55
-     * @param string $editor_script_handle
56
-     */
57
-    public function setEditorScriptHandle($editor_script_handle)
58
-    {
59
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
60
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
61
-        }
62
-        $this->editor_script_handle = $editor_script_handle;
63
-    }
64
-
65
-
66
-    /**
67
-     * @return string
68
-     */
69
-    public function getEditorStyleHandle()
70
-    {
71
-        return $this->editor_style_handle;
72
-    }
73
-
74
-
75
-    /**
76
-     * @param string $editor_style_handle
77
-     */
78
-    public function setEditorStyleHandle($editor_style_handle)
79
-    {
80
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
81
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
82
-        }
83
-        $this->editor_style_handle = $editor_style_handle;
84
-    }
85
-
86
-
87
-    /**
88
-     * @return string
89
-     */
90
-    public function getScriptHandle()
91
-    {
92
-        return $this->script_handle;
93
-    }
94
-
95
-
96
-    /**
97
-     * @param string $script_handle
98
-     */
99
-    public function setScriptHandle($script_handle)
100
-    {
101
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
102
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
103
-        }
104
-        $this->script_handle = $script_handle;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return string
110
-     */
111
-    public function getStyleHandle()
112
-    {
113
-        return $this->style_handle;
114
-    }
115
-
116
-
117
-    /**
118
-     * @param string $style_handle
119
-     */
120
-    public function setStyleHandle($style_handle)
121
-    {
122
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
123
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
124
-        }
125
-        $this->style_handle = $style_handle;
126
-    }
127
-
128
-    /**
129
-     * @since 4.9.71.p
130
-     * @throws InvalidDataTypeException
131
-     * @throws InvalidEntityException
132
-     * @throws DuplicateCollectionIdentifierException
133
-     */
134
-    public function addAssets()
135
-    {
136
-        $this->addEditorScript($this->getEditorScriptHandle());
137
-        // $this->addEditorStyle($this->getEditorStyleHandle());
138
-        $this->addScript($this->getScriptHandle());
139
-        // $this->addStyle($this->getStyleHandle());
140
-    }
141
-
142
-
143
-    /**
144
-     * @param       $handle
145
-     * @param array $dependencies
146
-     * @since 4.9.71.p
147
-     * @return JavascriptAsset
148
-     * @throws InvalidDataTypeException
149
-     * @throws InvalidEntityException
150
-     * @throws DuplicateCollectionIdentifierException
151
-     */
152
-    public function addEditorScript($handle, array $dependencies = array())
153
-    {
154
-        if ($this->assets->hasJavascriptAsset($handle)){
155
-            return $this->assets->getJavascriptAsset($handle);
156
-        }
157
-        $dependencies = array_merge(
158
-            $dependencies,
159
-            ['wp-blocks']
160
-        );
161
-        return $this->addJs($handle, $dependencies)->setRequiresTranslation();
162
-    }
163
-
164
-
165
-    /**
166
-     * @param        $handle
167
-     * @param array  $dependencies
168
-     * @since 4.9.71.p
169
-     * @return StylesheetAsset
170
-     * @throws InvalidDataTypeException
171
-     * @throws InvalidEntityException
172
-     * @throws DuplicateCollectionIdentifierException
173
-     */
174
-    public function addEditorStyle($handle, array $dependencies = array())
175
-    {
176
-        if ($this->assets->hasStylesheetAsset($handle)) {
177
-            return $this->assets->getStylesheetAsset($handle);
178
-        }
179
-        return $this->addCss($handle, $dependencies);
180
-    }
181
-
182
-
183
-    /**
184
-     * @param       $handle
185
-     * @param array $dependencies
186
-     * @since 4.9.71.p
187
-     * @return JavascriptAsset
188
-     * @throws InvalidDataTypeException
189
-     * @throws InvalidEntityException
190
-     * @throws DuplicateCollectionIdentifierException
191
-     */
192
-    public function addScript($handle, array $dependencies = array())
193
-    {
194
-        if ($this->assets->hasJavascriptAsset($handle)) {
195
-            return $this->assets->getJavascriptAsset($handle);
196
-        }
197
-        return $this->addJs($handle, $dependencies)->setRequiresTranslation();
198
-    }
199
-
200
-
201
-    /**
202
-     * @param        $handle
203
-     * @param array  $dependencies
204
-     * @since 4.9.71.p
205
-     * @return StylesheetAsset
206
-     * @throws InvalidDataTypeException
207
-     * @throws InvalidEntityException
208
-     * @throws DuplicateCollectionIdentifierException
209
-     */
210
-    public function addStyle($handle, array $dependencies = array())
211
-    {
212
-        if ($this->assets->hasStylesheetAsset($handle)) {
213
-            return $this->assets->getStylesheetAsset($handle);
214
-        }
215
-        return $this->addCss($handle, $dependencies);
216
-    }
217
-
218
-
219
-    /**
220
-     * @return JavascriptAsset|null
221
-     */
222
-    public function getEditorScript()
223
-    {
224
-        return $this->assets->getJavascriptAsset($this->editor_script_handle);
225
-    }
226
-
227
-
228
-    /**
229
-     * @return StylesheetAsset|null
230
-     */
231
-    public function getEditorStyle()
232
-    {
233
-        return $this->assets->getStylesheetAsset($this->editor_style_handle);
234
-    }
235
-
236
-
237
-    /**
238
-     * @return JavascriptAsset|null
239
-     */
240
-    public function getScript()
241
-    {
242
-        return $this->assets->getJavascriptAsset($this->script_handle);
243
-    }
244
-
245
-
246
-    /**
247
-     * @return StylesheetAsset|null
248
-     */
249
-    public function getStyle()
250
-    {
251
-        return $this->assets->getStylesheetAsset($this->style_handle);
252
-    }
253
-
254
-
255
-    /**
256
-     * @return  void
257
-     */
258
-    public function enqueueAssets()
259
-    {
260
-        $assets = array(
261
-            $this->getEditorScript(),
262
-            $this->getEditorStyle(),
263
-            $this->getScript(),
264
-            $this->getStyle(),
265
-        );
266
-        foreach ($assets as $asset) {
267
-            if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
268
-                $asset->enqueueAsset();
269
-            }
270
-        }
271
-    }
24
+	/**
25
+	 * @var string $editor_script_handle
26
+	 */
27
+	private $editor_script_handle;
28
+
29
+	/**
30
+	 * @var string $editor_style_handle
31
+	 */
32
+	private $editor_style_handle;
33
+
34
+	/**
35
+	 * @var string $script_handle
36
+	 */
37
+	private $script_handle;
38
+
39
+	/**
40
+	 * @var string $style_handle
41
+	 */
42
+	private $style_handle;
43
+
44
+
45
+	/**
46
+	 * @return string
47
+	 */
48
+	public function getEditorScriptHandle()
49
+	{
50
+		return $this->editor_script_handle;
51
+	}
52
+
53
+
54
+	/**
55
+	 * @param string $editor_script_handle
56
+	 */
57
+	public function setEditorScriptHandle($editor_script_handle)
58
+	{
59
+		if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
60
+			$editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
61
+		}
62
+		$this->editor_script_handle = $editor_script_handle;
63
+	}
64
+
65
+
66
+	/**
67
+	 * @return string
68
+	 */
69
+	public function getEditorStyleHandle()
70
+	{
71
+		return $this->editor_style_handle;
72
+	}
73
+
74
+
75
+	/**
76
+	 * @param string $editor_style_handle
77
+	 */
78
+	public function setEditorStyleHandle($editor_style_handle)
79
+	{
80
+		if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
81
+			$editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
82
+		}
83
+		$this->editor_style_handle = $editor_style_handle;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @return string
89
+	 */
90
+	public function getScriptHandle()
91
+	{
92
+		return $this->script_handle;
93
+	}
94
+
95
+
96
+	/**
97
+	 * @param string $script_handle
98
+	 */
99
+	public function setScriptHandle($script_handle)
100
+	{
101
+		if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
102
+			$script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
103
+		}
104
+		$this->script_handle = $script_handle;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return string
110
+	 */
111
+	public function getStyleHandle()
112
+	{
113
+		return $this->style_handle;
114
+	}
115
+
116
+
117
+	/**
118
+	 * @param string $style_handle
119
+	 */
120
+	public function setStyleHandle($style_handle)
121
+	{
122
+		if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
123
+			$style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
124
+		}
125
+		$this->style_handle = $style_handle;
126
+	}
127
+
128
+	/**
129
+	 * @since 4.9.71.p
130
+	 * @throws InvalidDataTypeException
131
+	 * @throws InvalidEntityException
132
+	 * @throws DuplicateCollectionIdentifierException
133
+	 */
134
+	public function addAssets()
135
+	{
136
+		$this->addEditorScript($this->getEditorScriptHandle());
137
+		// $this->addEditorStyle($this->getEditorStyleHandle());
138
+		$this->addScript($this->getScriptHandle());
139
+		// $this->addStyle($this->getStyleHandle());
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param       $handle
145
+	 * @param array $dependencies
146
+	 * @since 4.9.71.p
147
+	 * @return JavascriptAsset
148
+	 * @throws InvalidDataTypeException
149
+	 * @throws InvalidEntityException
150
+	 * @throws DuplicateCollectionIdentifierException
151
+	 */
152
+	public function addEditorScript($handle, array $dependencies = array())
153
+	{
154
+		if ($this->assets->hasJavascriptAsset($handle)){
155
+			return $this->assets->getJavascriptAsset($handle);
156
+		}
157
+		$dependencies = array_merge(
158
+			$dependencies,
159
+			['wp-blocks']
160
+		);
161
+		return $this->addJs($handle, $dependencies)->setRequiresTranslation();
162
+	}
163
+
164
+
165
+	/**
166
+	 * @param        $handle
167
+	 * @param array  $dependencies
168
+	 * @since 4.9.71.p
169
+	 * @return StylesheetAsset
170
+	 * @throws InvalidDataTypeException
171
+	 * @throws InvalidEntityException
172
+	 * @throws DuplicateCollectionIdentifierException
173
+	 */
174
+	public function addEditorStyle($handle, array $dependencies = array())
175
+	{
176
+		if ($this->assets->hasStylesheetAsset($handle)) {
177
+			return $this->assets->getStylesheetAsset($handle);
178
+		}
179
+		return $this->addCss($handle, $dependencies);
180
+	}
181
+
182
+
183
+	/**
184
+	 * @param       $handle
185
+	 * @param array $dependencies
186
+	 * @since 4.9.71.p
187
+	 * @return JavascriptAsset
188
+	 * @throws InvalidDataTypeException
189
+	 * @throws InvalidEntityException
190
+	 * @throws DuplicateCollectionIdentifierException
191
+	 */
192
+	public function addScript($handle, array $dependencies = array())
193
+	{
194
+		if ($this->assets->hasJavascriptAsset($handle)) {
195
+			return $this->assets->getJavascriptAsset($handle);
196
+		}
197
+		return $this->addJs($handle, $dependencies)->setRequiresTranslation();
198
+	}
199
+
200
+
201
+	/**
202
+	 * @param        $handle
203
+	 * @param array  $dependencies
204
+	 * @since 4.9.71.p
205
+	 * @return StylesheetAsset
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws InvalidEntityException
208
+	 * @throws DuplicateCollectionIdentifierException
209
+	 */
210
+	public function addStyle($handle, array $dependencies = array())
211
+	{
212
+		if ($this->assets->hasStylesheetAsset($handle)) {
213
+			return $this->assets->getStylesheetAsset($handle);
214
+		}
215
+		return $this->addCss($handle, $dependencies);
216
+	}
217
+
218
+
219
+	/**
220
+	 * @return JavascriptAsset|null
221
+	 */
222
+	public function getEditorScript()
223
+	{
224
+		return $this->assets->getJavascriptAsset($this->editor_script_handle);
225
+	}
226
+
227
+
228
+	/**
229
+	 * @return StylesheetAsset|null
230
+	 */
231
+	public function getEditorStyle()
232
+	{
233
+		return $this->assets->getStylesheetAsset($this->editor_style_handle);
234
+	}
235
+
236
+
237
+	/**
238
+	 * @return JavascriptAsset|null
239
+	 */
240
+	public function getScript()
241
+	{
242
+		return $this->assets->getJavascriptAsset($this->script_handle);
243
+	}
244
+
245
+
246
+	/**
247
+	 * @return StylesheetAsset|null
248
+	 */
249
+	public function getStyle()
250
+	{
251
+		return $this->assets->getStylesheetAsset($this->style_handle);
252
+	}
253
+
254
+
255
+	/**
256
+	 * @return  void
257
+	 */
258
+	public function enqueueAssets()
259
+	{
260
+		$assets = array(
261
+			$this->getEditorScript(),
262
+			$this->getEditorStyle(),
263
+			$this->getScript(),
264
+			$this->getStyle(),
265
+		);
266
+		foreach ($assets as $asset) {
267
+			if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
268
+				$asset->enqueueAsset();
269
+			}
270
+		}
271
+	}
272 272
 
273 273
 }
Please login to merge, or discard this patch.
core/services/assets/AssetManager.php 1 patch
Indentation   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -24,308 +24,308 @@
 block discarded – undo
24 24
 abstract class AssetManager implements AssetManagerInterface
25 25
 {
26 26
 
27
-    /**
28
-     * @var AssetCollection $assets
29
-     */
30
-    protected $assets;
31
-
32
-    /**
33
-     * @var DomainInterface
34
-     */
35
-    protected $domain;
36
-
37
-    /**
38
-     * @var Registry $registry
39
-     */
40
-    protected $registry;
41
-
42
-
43
-    /**
44
-     * AssetRegister constructor.
45
-     *
46
-     * @param DomainInterface $domain
47
-     * @param AssetCollection $assets
48
-     * @param Registry        $registry
49
-     */
50
-    public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry)
51
-    {
52
-        $this->domain = $domain;
53
-        $this->assets = $assets;
54
-        $this->registry = $registry;
55
-        add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0);
56
-        add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0);
57
-        add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2);
58
-        add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2);
59
-    }
60
-
61
-
62
-    /**
63
-     * @return AssetCollection
64
-     */
65
-    public function getAssets()
66
-    {
67
-        return $this->assets;
68
-    }
69
-
70
-
71
-    /**
72
-     * @since 4.9.71.p
73
-     * @return string
74
-     */
75
-    public function assetNamespace()
76
-    {
77
-        return $this->domain->assetNamespace();
78
-    }
79
-
80
-
81
-    /**
82
-     * @return void
83
-     * @throws DuplicateCollectionIdentifierException
84
-     * @throws InvalidDataTypeException
85
-     * @throws InvalidEntityException
86
-     * @since 4.9.62.p
87
-     */
88
-    public function addManifestFile()
89
-    {
90
-        // if a manifest file has already been added for this domain, then just return
91
-        if ($this->assets->has($this->domain->assetNamespace())) {
92
-            return;
93
-        }
94
-        $asset = new ManifestFile($this->domain);
95
-        $this->assets->add($asset, $this->domain->assetNamespace());
96
-    }
97
-
98
-
99
-    /**
100
-     * @return ManifestFile[]
101
-     * @since 4.9.62.p
102
-     */
103
-    public function getManifestFile()
104
-    {
105
-        return $this->assets->getManifestFiles();
106
-    }
107
-
108
-
109
-    /**
110
-     * @param string $handle
111
-     * @param string $source
112
-     * @param array  $dependencies
113
-     * @param bool   $load_in_footer
114
-     * @param string $version
115
-     * @return JavascriptAsset
116
-     * @throws DuplicateCollectionIdentifierException
117
-     * @throws InvalidDataTypeException
118
-     * @throws InvalidEntityException
119
-     * @throws DomainException
120
-     * @since 4.9.62.p
121
-     */
122
-    public function addJavascript(
123
-        $handle,
124
-        $source,
125
-        array $dependencies = array(),
126
-        $load_in_footer = true,
127
-        $version = ''
128
-    ) {
129
-        $asset = new JavascriptAsset(
130
-            $handle,
131
-            $source,
132
-            array_unique($dependencies),
133
-            $load_in_footer,
134
-            $this->domain,
135
-            $version
136
-        );
137
-        $this->assets->add($asset, $handle);
138
-        return $asset;
139
-    }
140
-
141
-
142
-    /**
143
-     * Used to register a javascript asset where everything is dynamically derived from the given handle.
144
-     *
145
-     * @param string       $handle
146
-     * @param string|array $extra_dependencies
147
-     * @return JavascriptAsset
148
-     * @throws DuplicateCollectionIdentifierException
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidEntityException
151
-     * @throws DomainException
152
-     */
153
-    public function addJs($handle, $extra_dependencies = [])
154
-    {
155
-        $details = $this->getAssetDetails(
156
-            Asset::TYPE_JS,
157
-            $handle,
158
-            $extra_dependencies
159
-        );
160
-        $source = $this->registry->getJsUrl($this->domain->assetNamespace(), $handle);
161
-        return $this->addJavascript(
162
-            $handle,
163
-            $source,
164
-            $details['dependencies'],
165
-            true,
166
-            $details['version']
167
-        );
168
-    }
169
-
170
-
171
-    /**
172
-     * @param string $handle
173
-     * @param array  $dependencies
174
-     * @param bool   $load_in_footer
175
-     * @param string $version
176
-     * @return JavascriptAsset
177
-     * @throws DomainException
178
-     * @throws DuplicateCollectionIdentifierException
179
-     * @throws InvalidDataTypeException
180
-     * @throws InvalidEntityException
181
-     * @since 4.9.71.p
182
-     */
183
-    public function addVendorJavascript(
184
-        $handle,
185
-        array $dependencies = array(),
186
-        $load_in_footer = true,
187
-        $version = ''
188
-    ) {
189
-        $dev_suffix = wp_scripts_get_suffix('dev');
190
-        $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/';
191
-        return $this->addJavascript(
192
-            $handle,
193
-            "{$vendor_path}{$handle}{$dev_suffix}.js",
194
-            $dependencies,
195
-            $load_in_footer,
196
-            $version
197
-        );
198
-    }
199
-
200
-
201
-    /**
202
-     * @param string $handle
203
-     * @param string $source
204
-     * @param array  $dependencies
205
-     * @param string $media
206
-     * @param string $version
207
-     * @return StylesheetAsset
208
-     * @throws DomainException
209
-     * @throws DuplicateCollectionIdentifierException
210
-     * @throws InvalidDataTypeException
211
-     * @throws InvalidEntityException
212
-     * @since 4.9.62.p
213
-     */
214
-    public function addStylesheet(
215
-        $handle,
216
-        $source,
217
-        array $dependencies = array(),
218
-        $media = 'all',
219
-        $version = ''
220
-    ) {
221
-        $asset = new StylesheetAsset(
222
-            $handle,
223
-            $source,
224
-            array_unique($dependencies),
225
-            $this->domain,
226
-            $media,
227
-            $version
228
-        );
229
-        $this->assets->add($asset, $handle);
230
-        return $asset;
231
-    }
232
-
233
-
234
-    /**
235
-     * Used to register a css asset where everything is dynamically derived from the given handle.
236
-     *
237
-     * @param string       $handle
238
-     * @param string|array $extra_dependencies
239
-     * @return StylesheetAsset
240
-     * @throws DuplicateCollectionIdentifierException
241
-     * @throws InvalidDataTypeException
242
-     * @throws InvalidEntityException
243
-     * @throws DomainException
244
-     */
245
-    public function addCss($handle, $extra_dependencies = [])
246
-    {
247
-        $details = $this->getAssetDetails(
248
-            Asset::TYPE_CSS,
249
-            $handle,
250
-            $extra_dependencies
251
-        );
252
-        return $this->addStylesheet(
253
-            $handle,
254
-            $this->registry->getCssUrl($this->domain->assetNamespace(), $handle),
255
-            $details['dependencies'],
256
-            'all',
257
-            $details['version']
258
-        );
259
-    }
260
-
261
-
262
-    /**
263
-     * @param string $handle
264
-     * @return bool
265
-     * @since 4.9.62.p
266
-     */
267
-    public function enqueueAsset($handle)
268
-    {
269
-        if ($this->assets->has($handle)) {
270
-            $asset = $this->assets->get($handle);
271
-            if ($asset->isRegistered()) {
272
-                $asset->enqueueAsset();
273
-                return true;
274
-            }
275
-        }
276
-        return false;
277
-    }
278
-
279
-
280
-    /**
281
-     * @return  void
282
-     * @since   $VID:$
283
-     */
284
-    public function enqueueBrowserAssets()
285
-    {
286
-        foreach ($this->assets as $asset) {
287
-            if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
288
-                $asset->enqueueAsset();
289
-            }
290
-        }
291
-    }
292
-
293
-
294
-    /**
295
-     * @param string $asset_type
296
-     * @param string $handle
297
-     * @param array  $extra_dependencies
298
-     * @return array
299
-     * @since 4.10.2.p
300
-     */
301
-    private function getAssetDetails($asset_type, $handle, $extra_dependencies = [])
302
-    {
303
-        $getAssetDetails = '';
304
-        switch ($asset_type) {
305
-            case Asset::TYPE_JS :
306
-                $getAssetDetails = 'getJsAssetDetails';
307
-                break;
308
-            case Asset::TYPE_CSS :
309
-                $getAssetDetails = 'getCssAssetDetails';
310
-                break;
311
-        }
312
-        if ($getAssetDetails === '') {
313
-            return ['dependencies' => [], 'version' => ''];
314
-        }
315
-        $details = $this->registry->$getAssetDetails(
316
-            $this->domain->assetNamespace(),
317
-            $handle
318
-        );
319
-        $details['dependencies'] = isset($details['dependencies'])
320
-            ? $details['dependencies']
321
-            : [];
322
-        $details['version'] = isset($details['version'])
323
-            ? $details['version']
324
-            : '';
325
-        $details['dependencies'] = ! empty($extra_dependencies)
326
-            ? array_merge($details['dependencies'], (array) $extra_dependencies)
327
-            : $details['dependencies'];
328
-        return $details;
329
-
330
-    }
27
+	/**
28
+	 * @var AssetCollection $assets
29
+	 */
30
+	protected $assets;
31
+
32
+	/**
33
+	 * @var DomainInterface
34
+	 */
35
+	protected $domain;
36
+
37
+	/**
38
+	 * @var Registry $registry
39
+	 */
40
+	protected $registry;
41
+
42
+
43
+	/**
44
+	 * AssetRegister constructor.
45
+	 *
46
+	 * @param DomainInterface $domain
47
+	 * @param AssetCollection $assets
48
+	 * @param Registry        $registry
49
+	 */
50
+	public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry)
51
+	{
52
+		$this->domain = $domain;
53
+		$this->assets = $assets;
54
+		$this->registry = $registry;
55
+		add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0);
56
+		add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0);
57
+		add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2);
58
+		add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2);
59
+	}
60
+
61
+
62
+	/**
63
+	 * @return AssetCollection
64
+	 */
65
+	public function getAssets()
66
+	{
67
+		return $this->assets;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @since 4.9.71.p
73
+	 * @return string
74
+	 */
75
+	public function assetNamespace()
76
+	{
77
+		return $this->domain->assetNamespace();
78
+	}
79
+
80
+
81
+	/**
82
+	 * @return void
83
+	 * @throws DuplicateCollectionIdentifierException
84
+	 * @throws InvalidDataTypeException
85
+	 * @throws InvalidEntityException
86
+	 * @since 4.9.62.p
87
+	 */
88
+	public function addManifestFile()
89
+	{
90
+		// if a manifest file has already been added for this domain, then just return
91
+		if ($this->assets->has($this->domain->assetNamespace())) {
92
+			return;
93
+		}
94
+		$asset = new ManifestFile($this->domain);
95
+		$this->assets->add($asset, $this->domain->assetNamespace());
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return ManifestFile[]
101
+	 * @since 4.9.62.p
102
+	 */
103
+	public function getManifestFile()
104
+	{
105
+		return $this->assets->getManifestFiles();
106
+	}
107
+
108
+
109
+	/**
110
+	 * @param string $handle
111
+	 * @param string $source
112
+	 * @param array  $dependencies
113
+	 * @param bool   $load_in_footer
114
+	 * @param string $version
115
+	 * @return JavascriptAsset
116
+	 * @throws DuplicateCollectionIdentifierException
117
+	 * @throws InvalidDataTypeException
118
+	 * @throws InvalidEntityException
119
+	 * @throws DomainException
120
+	 * @since 4.9.62.p
121
+	 */
122
+	public function addJavascript(
123
+		$handle,
124
+		$source,
125
+		array $dependencies = array(),
126
+		$load_in_footer = true,
127
+		$version = ''
128
+	) {
129
+		$asset = new JavascriptAsset(
130
+			$handle,
131
+			$source,
132
+			array_unique($dependencies),
133
+			$load_in_footer,
134
+			$this->domain,
135
+			$version
136
+		);
137
+		$this->assets->add($asset, $handle);
138
+		return $asset;
139
+	}
140
+
141
+
142
+	/**
143
+	 * Used to register a javascript asset where everything is dynamically derived from the given handle.
144
+	 *
145
+	 * @param string       $handle
146
+	 * @param string|array $extra_dependencies
147
+	 * @return JavascriptAsset
148
+	 * @throws DuplicateCollectionIdentifierException
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidEntityException
151
+	 * @throws DomainException
152
+	 */
153
+	public function addJs($handle, $extra_dependencies = [])
154
+	{
155
+		$details = $this->getAssetDetails(
156
+			Asset::TYPE_JS,
157
+			$handle,
158
+			$extra_dependencies
159
+		);
160
+		$source = $this->registry->getJsUrl($this->domain->assetNamespace(), $handle);
161
+		return $this->addJavascript(
162
+			$handle,
163
+			$source,
164
+			$details['dependencies'],
165
+			true,
166
+			$details['version']
167
+		);
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param string $handle
173
+	 * @param array  $dependencies
174
+	 * @param bool   $load_in_footer
175
+	 * @param string $version
176
+	 * @return JavascriptAsset
177
+	 * @throws DomainException
178
+	 * @throws DuplicateCollectionIdentifierException
179
+	 * @throws InvalidDataTypeException
180
+	 * @throws InvalidEntityException
181
+	 * @since 4.9.71.p
182
+	 */
183
+	public function addVendorJavascript(
184
+		$handle,
185
+		array $dependencies = array(),
186
+		$load_in_footer = true,
187
+		$version = ''
188
+	) {
189
+		$dev_suffix = wp_scripts_get_suffix('dev');
190
+		$vendor_path = $this->domain->pluginUrl() . 'assets/vendor/';
191
+		return $this->addJavascript(
192
+			$handle,
193
+			"{$vendor_path}{$handle}{$dev_suffix}.js",
194
+			$dependencies,
195
+			$load_in_footer,
196
+			$version
197
+		);
198
+	}
199
+
200
+
201
+	/**
202
+	 * @param string $handle
203
+	 * @param string $source
204
+	 * @param array  $dependencies
205
+	 * @param string $media
206
+	 * @param string $version
207
+	 * @return StylesheetAsset
208
+	 * @throws DomainException
209
+	 * @throws DuplicateCollectionIdentifierException
210
+	 * @throws InvalidDataTypeException
211
+	 * @throws InvalidEntityException
212
+	 * @since 4.9.62.p
213
+	 */
214
+	public function addStylesheet(
215
+		$handle,
216
+		$source,
217
+		array $dependencies = array(),
218
+		$media = 'all',
219
+		$version = ''
220
+	) {
221
+		$asset = new StylesheetAsset(
222
+			$handle,
223
+			$source,
224
+			array_unique($dependencies),
225
+			$this->domain,
226
+			$media,
227
+			$version
228
+		);
229
+		$this->assets->add($asset, $handle);
230
+		return $asset;
231
+	}
232
+
233
+
234
+	/**
235
+	 * Used to register a css asset where everything is dynamically derived from the given handle.
236
+	 *
237
+	 * @param string       $handle
238
+	 * @param string|array $extra_dependencies
239
+	 * @return StylesheetAsset
240
+	 * @throws DuplicateCollectionIdentifierException
241
+	 * @throws InvalidDataTypeException
242
+	 * @throws InvalidEntityException
243
+	 * @throws DomainException
244
+	 */
245
+	public function addCss($handle, $extra_dependencies = [])
246
+	{
247
+		$details = $this->getAssetDetails(
248
+			Asset::TYPE_CSS,
249
+			$handle,
250
+			$extra_dependencies
251
+		);
252
+		return $this->addStylesheet(
253
+			$handle,
254
+			$this->registry->getCssUrl($this->domain->assetNamespace(), $handle),
255
+			$details['dependencies'],
256
+			'all',
257
+			$details['version']
258
+		);
259
+	}
260
+
261
+
262
+	/**
263
+	 * @param string $handle
264
+	 * @return bool
265
+	 * @since 4.9.62.p
266
+	 */
267
+	public function enqueueAsset($handle)
268
+	{
269
+		if ($this->assets->has($handle)) {
270
+			$asset = $this->assets->get($handle);
271
+			if ($asset->isRegistered()) {
272
+				$asset->enqueueAsset();
273
+				return true;
274
+			}
275
+		}
276
+		return false;
277
+	}
278
+
279
+
280
+	/**
281
+	 * @return  void
282
+	 * @since   $VID:$
283
+	 */
284
+	public function enqueueBrowserAssets()
285
+	{
286
+		foreach ($this->assets as $asset) {
287
+			if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
288
+				$asset->enqueueAsset();
289
+			}
290
+		}
291
+	}
292
+
293
+
294
+	/**
295
+	 * @param string $asset_type
296
+	 * @param string $handle
297
+	 * @param array  $extra_dependencies
298
+	 * @return array
299
+	 * @since 4.10.2.p
300
+	 */
301
+	private function getAssetDetails($asset_type, $handle, $extra_dependencies = [])
302
+	{
303
+		$getAssetDetails = '';
304
+		switch ($asset_type) {
305
+			case Asset::TYPE_JS :
306
+				$getAssetDetails = 'getJsAssetDetails';
307
+				break;
308
+			case Asset::TYPE_CSS :
309
+				$getAssetDetails = 'getCssAssetDetails';
310
+				break;
311
+		}
312
+		if ($getAssetDetails === '') {
313
+			return ['dependencies' => [], 'version' => ''];
314
+		}
315
+		$details = $this->registry->$getAssetDetails(
316
+			$this->domain->assetNamespace(),
317
+			$handle
318
+		);
319
+		$details['dependencies'] = isset($details['dependencies'])
320
+			? $details['dependencies']
321
+			: [];
322
+		$details['version'] = isset($details['version'])
323
+			? $details['version']
324
+			: '';
325
+		$details['dependencies'] = ! empty($extra_dependencies)
326
+			? array_merge($details['dependencies'], (array) $extra_dependencies)
327
+			: $details['dependencies'];
328
+		return $details;
329
+
330
+	}
331 331
 }
Please login to merge, or discard this patch.
core/services/assets/Registry.php 2 patches
Indentation   +785 added lines, -785 removed lines patch added patch discarded remove patch
@@ -26,796 +26,796 @@
 block discarded – undo
26 26
 class Registry
27 27
 {
28 28
 
29
-    const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
30
-
31
-    /**
32
-     * @var AssetCollection $assets
33
-     */
34
-    protected $assets;
35
-
36
-    /**
37
-     * @var I18nRegistry
38
-     */
39
-    private $i18n_registry;
40
-
41
-    /**
42
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
43
-     *
44
-     * @var array
45
-     */
46
-    protected $jsdata = array();
47
-
48
-    /**
49
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
50
-     * page source.
51
-     *
52
-     * @var array
53
-     */
54
-    private $script_handles_with_data = array();
55
-
56
-
57
-    /**
58
-     * Holds the manifest data obtained from registered manifest files.
59
-     * Manifests are maps of asset chunk name to actual built asset file names.
60
-     * Shape of this array is:
61
-     * array(
62
-     *  'some_namespace_slug' => array(
63
-     *      'some_chunk_name' => array(
64
-     *          'js' => 'filename.js'
65
-     *          'css' => 'filename.js'
66
-     *      ),
67
-     *      'url_base' => 'https://baseurl.com/to/assets
68
-     *  )
69
-     * )
70
-     *
71
-     * @var array
72
-     */
73
-    private $manifest_data = array();
74
-
75
-
76
-    /**
77
-     * Holds any dependency data obtained from registered dependency map json.
78
-     * Dependency map json is generated via the @wordpress/dependency-extraction-webpack-plugin via the webpack config.
79
-     * @see https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin
80
-     *
81
-     * @var array
82
-     */
83
-    private $dependencies_data = [];
84
-
85
-
86
-    /**
87
-     * This is a known array of possible wp css handles that correspond to what may be exposed as dependencies in our
88
-     * build process.  Currently the dependency export process in webpack does not consider css imports, so we derive
89
-     * them via the js dependencies (WP uses the same handle for both js and css). This is a list of known handles that
90
-     * are used for both js and css.
91
-     * @var array
92
-     */
93
-    private $wp_css_handle_dependencies = [
94
-        'wp-components',
95
-        'wp-block-editor',
96
-        'wp-block-library',
97
-        'wp-edit-post',
98
-        'wp-edit-widgets',
99
-        'wp-editor',
100
-        'wp-format-library',
101
-        'wp-list-reusable-blocks',
102
-        'wp-nux',
103
-    ];
104
-
105
-
106
-    /**
107
-     * Registry constructor.
108
-     * Hooking into WP actions for script registry.
109
-     *
110
-     * @param AssetCollection      $assets
111
-     * @param I18nRegistry         $i18n_registry
112
-     * @throws InvalidArgumentException
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     */
116
-    public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
117
-    {
118
-        $this->assets = $assets;
119
-        $this->i18n_registry = $i18n_registry;
120
-        add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
121
-        add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
122
-        add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 4);
123
-        add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 4);
124
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 5);
125
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 5);
126
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
127
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
128
-    }
129
-
130
-
131
-    /**
132
-     * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
133
-     * translation handling.
134
-     *
135
-     * @return I18nRegistry
136
-     */
137
-    public function getI18nRegistry()
138
-    {
139
-        return $this->i18n_registry;
140
-    }
141
-
142
-
143
-    /**
144
-     * Callback for the wp_enqueue_scripts actions used to register assets.
145
-     *
146
-     * @since 4.9.62.p
147
-     * @throws Exception
148
-     */
149
-    public function registerScriptsAndStyles()
150
-    {
151
-        try {
152
-            $this->registerScripts($this->assets->getJavascriptAssets());
153
-            $this->registerStyles($this->assets->getStylesheetAssets());
154
-        } catch (Exception $exception) {
155
-            new ExceptionStackTraceDisplay($exception);
156
-        }
157
-    }
158
-
159
-
160
-    /**
161
-     * Registers JS assets with WP core
162
-     *
163
-     * @param JavascriptAsset[] $scripts
164
-     * @throws AssetRegistrationException
165
-     * @throws InvalidDataTypeException
166
-     * @throws DomainException
167
-     * @since 4.9.62.p
168
-     */
169
-    public function registerScripts(array $scripts)
170
-    {
171
-        foreach ($scripts as $script) {
172
-            // skip to next script if this has already been done
173
-            if ($script->isRegistered()) {
174
-                continue;
175
-            }
176
-            do_action(
177
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
178
-                $script
179
-            );
180
-            $registered = wp_register_script(
181
-                $script->handle(),
182
-                $script->source(),
183
-                $script->dependencies(),
184
-                $script->version(),
185
-                $script->loadInFooter()
186
-            );
187
-            if (! $registered && $this->debug()) {
188
-                throw new AssetRegistrationException($script->handle());
189
-            }
190
-            $script->setRegistered($registered);
191
-            if ($script->requiresTranslation()) {
192
-                $this->registerTranslation($script->handle());
193
-            }
194
-            do_action(
195
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
196
-                $script
197
-            );
198
-        }
199
-    }
200
-
201
-
202
-    /**
203
-     * Registers CSS assets with WP core
204
-     *
205
-     * @param StylesheetAsset[] $styles
206
-     * @throws InvalidDataTypeException
207
-     * @throws DomainException
208
-     * @since 4.9.62.p
209
-     */
210
-    public function registerStyles(array $styles)
211
-    {
212
-        foreach ($styles as $style) {
213
-            // skip to next style if this has already been done
214
-            if ($style->isRegistered()) {
215
-                continue;
216
-            }
217
-            do_action(
218
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
219
-                $style
220
-            );
221
-            wp_register_style(
222
-                $style->handle(),
223
-                $style->source(),
224
-                $style->dependencies(),
225
-                $style->version(),
226
-                $style->media()
227
-            );
228
-            $style->setRegistered();
229
-            do_action(
230
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
231
-                $style
232
-            );
233
-        }
234
-    }
235
-
236
-
237
-    /**
238
-     * Call back for the script print in frontend and backend.
239
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
240
-     *
241
-     * @throws Exception
242
-     * @since 4.9.31.rc.015
243
-     */
244
-    public function enqueueData()
245
-    {
246
-        try {
247
-            $this->removeAlreadyRegisteredDataForScriptHandles();
248
-            wp_add_inline_script(
249
-                'eejs-core',
250
-                'var eejsdata=' . wp_json_encode(['data' => $this->jsdata]),
251
-                'before'
252
-            );
253
-            $scripts = $this->assets->getJavascriptAssetsWithData();
254
-            foreach ($scripts as $script) {
255
-                $this->addRegisteredScriptHandlesWithData($script->handle());
256
-                if ($script->hasInlineDataCallback()) {
257
-                    $localize = $script->inlineDataCallback();
258
-                    $localize();
259
-                }
260
-            }
261
-        } catch (Exception $exception) {
262
-            EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
263
-            new ExceptionStackTraceDisplay($exception);
264
-        }
265
-    }
266
-
267
-
268
-    /**
269
-     * Used to add data to eejs.data object.
270
-     * Note:  Overriding existing data is not allowed.
271
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
272
-     * If the data you add is something like this:
273
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
274
-     * It will be exposed in the page source as:
275
-     *  eejs.data.my_plugin_data.foo == gar
276
-     *
277
-     * @param string       $key   Key used to access your data
278
-     * @param string|array $value Value to attach to key
279
-     * @throws InvalidArgumentException
280
-     */
281
-    public function addData($key, $value)
282
-    {
283
-        if ($this->verifyDataNotExisting($key)) {
284
-            $this->jsdata[ $key ] = $value;
285
-        }
286
-    }
287
-
288
-
289
-    /**
290
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
291
-     * elements in an array.
292
-     *
293
-     * When you use this method, the value you include will be merged with the array on $key.
294
-     * So if the $key was 'test' and you added a value of ['my_data'] then it would be represented in the javascript
295
-     * object like this, eejs.data.test = [ my_data,
296
-     * ]
297
-     * If there has already been a scalar value attached to the data object given key (via addData for instance), then
298
-     * this will throw an exception.
299
-     *
300
-     * Caution: Only add data using this method if you are okay with the potential for additional data added on the same
301
-     * key potentially overriding the existing data on merge (specifically with associative arrays).
302
-     *
303
-     * @param string       $key   Key to attach data to.
304
-     * @param string|array $value Value being registered.
305
-     * @throws InvalidArgumentException
306
-     */
307
-    public function pushData($key, $value)
308
-    {
309
-        if (isset($this->jsdata[ $key ])
310
-            && ! is_array($this->jsdata[ $key ])
311
-        ) {
312
-            if (! $this->debug()) {
313
-                return;
314
-            }
315
-            throw new InvalidArgumentException(
316
-                sprintf(
317
-                    __(
318
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
29
+	const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
30
+
31
+	/**
32
+	 * @var AssetCollection $assets
33
+	 */
34
+	protected $assets;
35
+
36
+	/**
37
+	 * @var I18nRegistry
38
+	 */
39
+	private $i18n_registry;
40
+
41
+	/**
42
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
43
+	 *
44
+	 * @var array
45
+	 */
46
+	protected $jsdata = array();
47
+
48
+	/**
49
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
50
+	 * page source.
51
+	 *
52
+	 * @var array
53
+	 */
54
+	private $script_handles_with_data = array();
55
+
56
+
57
+	/**
58
+	 * Holds the manifest data obtained from registered manifest files.
59
+	 * Manifests are maps of asset chunk name to actual built asset file names.
60
+	 * Shape of this array is:
61
+	 * array(
62
+	 *  'some_namespace_slug' => array(
63
+	 *      'some_chunk_name' => array(
64
+	 *          'js' => 'filename.js'
65
+	 *          'css' => 'filename.js'
66
+	 *      ),
67
+	 *      'url_base' => 'https://baseurl.com/to/assets
68
+	 *  )
69
+	 * )
70
+	 *
71
+	 * @var array
72
+	 */
73
+	private $manifest_data = array();
74
+
75
+
76
+	/**
77
+	 * Holds any dependency data obtained from registered dependency map json.
78
+	 * Dependency map json is generated via the @wordpress/dependency-extraction-webpack-plugin via the webpack config.
79
+	 * @see https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin
80
+	 *
81
+	 * @var array
82
+	 */
83
+	private $dependencies_data = [];
84
+
85
+
86
+	/**
87
+	 * This is a known array of possible wp css handles that correspond to what may be exposed as dependencies in our
88
+	 * build process.  Currently the dependency export process in webpack does not consider css imports, so we derive
89
+	 * them via the js dependencies (WP uses the same handle for both js and css). This is a list of known handles that
90
+	 * are used for both js and css.
91
+	 * @var array
92
+	 */
93
+	private $wp_css_handle_dependencies = [
94
+		'wp-components',
95
+		'wp-block-editor',
96
+		'wp-block-library',
97
+		'wp-edit-post',
98
+		'wp-edit-widgets',
99
+		'wp-editor',
100
+		'wp-format-library',
101
+		'wp-list-reusable-blocks',
102
+		'wp-nux',
103
+	];
104
+
105
+
106
+	/**
107
+	 * Registry constructor.
108
+	 * Hooking into WP actions for script registry.
109
+	 *
110
+	 * @param AssetCollection      $assets
111
+	 * @param I18nRegistry         $i18n_registry
112
+	 * @throws InvalidArgumentException
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 */
116
+	public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
117
+	{
118
+		$this->assets = $assets;
119
+		$this->i18n_registry = $i18n_registry;
120
+		add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
121
+		add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
122
+		add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 4);
123
+		add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 4);
124
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 5);
125
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 5);
126
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
127
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
128
+	}
129
+
130
+
131
+	/**
132
+	 * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
133
+	 * translation handling.
134
+	 *
135
+	 * @return I18nRegistry
136
+	 */
137
+	public function getI18nRegistry()
138
+	{
139
+		return $this->i18n_registry;
140
+	}
141
+
142
+
143
+	/**
144
+	 * Callback for the wp_enqueue_scripts actions used to register assets.
145
+	 *
146
+	 * @since 4.9.62.p
147
+	 * @throws Exception
148
+	 */
149
+	public function registerScriptsAndStyles()
150
+	{
151
+		try {
152
+			$this->registerScripts($this->assets->getJavascriptAssets());
153
+			$this->registerStyles($this->assets->getStylesheetAssets());
154
+		} catch (Exception $exception) {
155
+			new ExceptionStackTraceDisplay($exception);
156
+		}
157
+	}
158
+
159
+
160
+	/**
161
+	 * Registers JS assets with WP core
162
+	 *
163
+	 * @param JavascriptAsset[] $scripts
164
+	 * @throws AssetRegistrationException
165
+	 * @throws InvalidDataTypeException
166
+	 * @throws DomainException
167
+	 * @since 4.9.62.p
168
+	 */
169
+	public function registerScripts(array $scripts)
170
+	{
171
+		foreach ($scripts as $script) {
172
+			// skip to next script if this has already been done
173
+			if ($script->isRegistered()) {
174
+				continue;
175
+			}
176
+			do_action(
177
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
178
+				$script
179
+			);
180
+			$registered = wp_register_script(
181
+				$script->handle(),
182
+				$script->source(),
183
+				$script->dependencies(),
184
+				$script->version(),
185
+				$script->loadInFooter()
186
+			);
187
+			if (! $registered && $this->debug()) {
188
+				throw new AssetRegistrationException($script->handle());
189
+			}
190
+			$script->setRegistered($registered);
191
+			if ($script->requiresTranslation()) {
192
+				$this->registerTranslation($script->handle());
193
+			}
194
+			do_action(
195
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
196
+				$script
197
+			);
198
+		}
199
+	}
200
+
201
+
202
+	/**
203
+	 * Registers CSS assets with WP core
204
+	 *
205
+	 * @param StylesheetAsset[] $styles
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws DomainException
208
+	 * @since 4.9.62.p
209
+	 */
210
+	public function registerStyles(array $styles)
211
+	{
212
+		foreach ($styles as $style) {
213
+			// skip to next style if this has already been done
214
+			if ($style->isRegistered()) {
215
+				continue;
216
+			}
217
+			do_action(
218
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
219
+				$style
220
+			);
221
+			wp_register_style(
222
+				$style->handle(),
223
+				$style->source(),
224
+				$style->dependencies(),
225
+				$style->version(),
226
+				$style->media()
227
+			);
228
+			$style->setRegistered();
229
+			do_action(
230
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
231
+				$style
232
+			);
233
+		}
234
+	}
235
+
236
+
237
+	/**
238
+	 * Call back for the script print in frontend and backend.
239
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
240
+	 *
241
+	 * @throws Exception
242
+	 * @since 4.9.31.rc.015
243
+	 */
244
+	public function enqueueData()
245
+	{
246
+		try {
247
+			$this->removeAlreadyRegisteredDataForScriptHandles();
248
+			wp_add_inline_script(
249
+				'eejs-core',
250
+				'var eejsdata=' . wp_json_encode(['data' => $this->jsdata]),
251
+				'before'
252
+			);
253
+			$scripts = $this->assets->getJavascriptAssetsWithData();
254
+			foreach ($scripts as $script) {
255
+				$this->addRegisteredScriptHandlesWithData($script->handle());
256
+				if ($script->hasInlineDataCallback()) {
257
+					$localize = $script->inlineDataCallback();
258
+					$localize();
259
+				}
260
+			}
261
+		} catch (Exception $exception) {
262
+			EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
263
+			new ExceptionStackTraceDisplay($exception);
264
+		}
265
+	}
266
+
267
+
268
+	/**
269
+	 * Used to add data to eejs.data object.
270
+	 * Note:  Overriding existing data is not allowed.
271
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
272
+	 * If the data you add is something like this:
273
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
274
+	 * It will be exposed in the page source as:
275
+	 *  eejs.data.my_plugin_data.foo == gar
276
+	 *
277
+	 * @param string       $key   Key used to access your data
278
+	 * @param string|array $value Value to attach to key
279
+	 * @throws InvalidArgumentException
280
+	 */
281
+	public function addData($key, $value)
282
+	{
283
+		if ($this->verifyDataNotExisting($key)) {
284
+			$this->jsdata[ $key ] = $value;
285
+		}
286
+	}
287
+
288
+
289
+	/**
290
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
291
+	 * elements in an array.
292
+	 *
293
+	 * When you use this method, the value you include will be merged with the array on $key.
294
+	 * So if the $key was 'test' and you added a value of ['my_data'] then it would be represented in the javascript
295
+	 * object like this, eejs.data.test = [ my_data,
296
+	 * ]
297
+	 * If there has already been a scalar value attached to the data object given key (via addData for instance), then
298
+	 * this will throw an exception.
299
+	 *
300
+	 * Caution: Only add data using this method if you are okay with the potential for additional data added on the same
301
+	 * key potentially overriding the existing data on merge (specifically with associative arrays).
302
+	 *
303
+	 * @param string       $key   Key to attach data to.
304
+	 * @param string|array $value Value being registered.
305
+	 * @throws InvalidArgumentException
306
+	 */
307
+	public function pushData($key, $value)
308
+	{
309
+		if (isset($this->jsdata[ $key ])
310
+			&& ! is_array($this->jsdata[ $key ])
311
+		) {
312
+			if (! $this->debug()) {
313
+				return;
314
+			}
315
+			throw new InvalidArgumentException(
316
+				sprintf(
317
+					__(
318
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
319 319
                          push values to this data element when it is an array.',
320
-                        'event_espresso'
321
-                    ),
322
-                    $key,
323
-                    __METHOD__
324
-                )
325
-            );
326
-        }
327
-        if ( ! isset( $this->jsdata[ $key ] ) ) {
328
-            $this->jsdata[ $key ] = is_array($value) ? $value : [$value];
329
-        } else {
330
-            $this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
331
-        }
332
-    }
333
-
334
-
335
-    /**
336
-     * Used to set content used by javascript for a template.
337
-     * Note: Overrides of existing registered templates are not allowed.
338
-     *
339
-     * @param string $template_reference
340
-     * @param string $template_content
341
-     * @throws InvalidArgumentException
342
-     */
343
-    public function addTemplate($template_reference, $template_content)
344
-    {
345
-        if (! isset($this->jsdata['templates'])) {
346
-            $this->jsdata['templates'] = array();
347
-        }
348
-        //no overrides allowed.
349
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
350
-            if (! $this->debug()) {
351
-                return;
352
-            }
353
-            throw new InvalidArgumentException(
354
-                sprintf(
355
-                    __(
356
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
357
-                        'event_espresso'
358
-                    ),
359
-                    $template_reference
360
-                )
361
-            );
362
-        }
363
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
364
-    }
365
-
366
-
367
-    /**
368
-     * Retrieve the template content already registered for the given reference.
369
-     *
370
-     * @param string $template_reference
371
-     * @return string
372
-     */
373
-    public function getTemplate($template_reference)
374
-    {
375
-        return isset($this->jsdata['templates'][ $template_reference ])
376
-            ? $this->jsdata['templates'][ $template_reference ]
377
-            : '';
378
-    }
379
-
380
-
381
-    /**
382
-     * Retrieve registered data.
383
-     *
384
-     * @param string $key Name of key to attach data to.
385
-     * @return mixed                If there is no for the given key, then false is returned.
386
-     */
387
-    public function getData($key)
388
-    {
389
-        return isset($this->jsdata[ $key ])
390
-            ? $this->jsdata[ $key ]
391
-            : false;
392
-    }
393
-
394
-
395
-    /**
396
-     * Verifies whether the given data exists already on the jsdata array.
397
-     * Overriding data is not allowed.
398
-     *
399
-     * @param string $key Index for data.
400
-     * @return bool        If valid then return true.
401
-     * @throws InvalidArgumentException if data already exists.
402
-     */
403
-    protected function verifyDataNotExisting($key)
404
-    {
405
-        if (isset($this->jsdata[ $key ])) {
406
-            if (! $this->debug()) {
407
-                return false;
408
-            }
409
-            if (is_array($this->jsdata[ $key ])) {
410
-                throw new InvalidArgumentException(
411
-                    sprintf(
412
-                        __(
413
-                            'The value for %1$s already exists in the Registry::eejs object.
320
+						'event_espresso'
321
+					),
322
+					$key,
323
+					__METHOD__
324
+				)
325
+			);
326
+		}
327
+		if ( ! isset( $this->jsdata[ $key ] ) ) {
328
+			$this->jsdata[ $key ] = is_array($value) ? $value : [$value];
329
+		} else {
330
+			$this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
331
+		}
332
+	}
333
+
334
+
335
+	/**
336
+	 * Used to set content used by javascript for a template.
337
+	 * Note: Overrides of existing registered templates are not allowed.
338
+	 *
339
+	 * @param string $template_reference
340
+	 * @param string $template_content
341
+	 * @throws InvalidArgumentException
342
+	 */
343
+	public function addTemplate($template_reference, $template_content)
344
+	{
345
+		if (! isset($this->jsdata['templates'])) {
346
+			$this->jsdata['templates'] = array();
347
+		}
348
+		//no overrides allowed.
349
+		if (isset($this->jsdata['templates'][ $template_reference ])) {
350
+			if (! $this->debug()) {
351
+				return;
352
+			}
353
+			throw new InvalidArgumentException(
354
+				sprintf(
355
+					__(
356
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
357
+						'event_espresso'
358
+					),
359
+					$template_reference
360
+				)
361
+			);
362
+		}
363
+		$this->jsdata['templates'][ $template_reference ] = $template_content;
364
+	}
365
+
366
+
367
+	/**
368
+	 * Retrieve the template content already registered for the given reference.
369
+	 *
370
+	 * @param string $template_reference
371
+	 * @return string
372
+	 */
373
+	public function getTemplate($template_reference)
374
+	{
375
+		return isset($this->jsdata['templates'][ $template_reference ])
376
+			? $this->jsdata['templates'][ $template_reference ]
377
+			: '';
378
+	}
379
+
380
+
381
+	/**
382
+	 * Retrieve registered data.
383
+	 *
384
+	 * @param string $key Name of key to attach data to.
385
+	 * @return mixed                If there is no for the given key, then false is returned.
386
+	 */
387
+	public function getData($key)
388
+	{
389
+		return isset($this->jsdata[ $key ])
390
+			? $this->jsdata[ $key ]
391
+			: false;
392
+	}
393
+
394
+
395
+	/**
396
+	 * Verifies whether the given data exists already on the jsdata array.
397
+	 * Overriding data is not allowed.
398
+	 *
399
+	 * @param string $key Index for data.
400
+	 * @return bool        If valid then return true.
401
+	 * @throws InvalidArgumentException if data already exists.
402
+	 */
403
+	protected function verifyDataNotExisting($key)
404
+	{
405
+		if (isset($this->jsdata[ $key ])) {
406
+			if (! $this->debug()) {
407
+				return false;
408
+			}
409
+			if (is_array($this->jsdata[ $key ])) {
410
+				throw new InvalidArgumentException(
411
+					sprintf(
412
+						__(
413
+							'The value for %1$s already exists in the Registry::eejs object.
414 414
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
415 415
                             %2$s method to push your value to the array.',
416
-                            'event_espresso'
417
-                        ),
418
-                        $key,
419
-                        'pushData()'
420
-                    )
421
-                );
422
-            }
423
-            throw new InvalidArgumentException(
424
-                sprintf(
425
-                    __(
426
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
416
+							'event_espresso'
417
+						),
418
+						$key,
419
+						'pushData()'
420
+					)
421
+				);
422
+			}
423
+			throw new InvalidArgumentException(
424
+				sprintf(
425
+					__(
426
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
427 427
                         allowed.  Consider attaching your value to a different key',
428
-                        'event_espresso'
429
-                    ),
430
-                    $key
431
-                )
432
-            );
433
-        }
434
-        return true;
435
-    }
436
-
437
-
438
-    /**
439
-     * Get the actual asset path for asset manifests.
440
-     * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
441
-     *
442
-     * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
443
-     *                           asset file location.
444
-     * @param string $chunk_name
445
-     * @param string $asset_type
446
-     * @return string
447
-     * @since 4.9.59.p
448
-     */
449
-    public function getAssetUrl($namespace, $chunk_name, $asset_type)
450
-    {
451
-        $asset_index = $chunk_name . '.' . $asset_type;
452
-        $url = isset(
453
-            $this->manifest_data[ $namespace ][ $asset_index ],
454
-            $this->manifest_data[ $namespace ]['url_base']
455
-        )
456
-            ? $this->manifest_data[ $namespace ]['url_base']
457
-              . $this->manifest_data[ $namespace ][ $asset_index ]
458
-            : '';
459
-        return apply_filters(
460
-            'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
461
-            $url,
462
-            $namespace,
463
-            $chunk_name,
464
-            $asset_type
465
-        );
466
-    }
467
-
468
-
469
-
470
-    /**
471
-     * Return the url to a js file for the given namespace and chunk name.
472
-     *
473
-     * @param string $namespace
474
-     * @param string $chunk_name
475
-     * @return string
476
-     */
477
-    public function getJsUrl($namespace, $chunk_name)
478
-    {
479
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
480
-    }
481
-
482
-
483
-    /**
484
-     * Return the url to a css file for the given namespace and chunk name.
485
-     *
486
-     * @param string $namespace
487
-     * @param string $chunk_name
488
-     * @return string
489
-     */
490
-    public function getCssUrl($namespace, $chunk_name)
491
-    {
492
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
493
-    }
494
-
495
-
496
-    /**
497
-     * Return the dependencies array and version string for a given asset $chunk_name
498
-     *
499
-     * @param string $namespace
500
-     * @param string $chunk_name
501
-     * @param string $asset_type
502
-     * @return array
503
-     * @since 4.9.82.p
504
-     */
505
-    private function getDetailsForAsset($namespace, $chunk_name, $asset_type)
506
-    {
507
-        $asset_index = $chunk_name . '.' . $asset_type;
508
-        if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
509
-            $path = isset($this->manifest_data[ $namespace ]['path'])
510
-                ? $this->manifest_data[ $namespace ]['path']
511
-                : '';
512
-            $dependencies_index = $chunk_name . '.' . Asset::TYPE_PHP;
513
-            $file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
514
-                ? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
515
-                :
516
-                '';
517
-            $this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
518
-                ? $this->getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
519
-                : [];
520
-        }
521
-        return $this->dependencies_data[ $namespace ][ $asset_index ];
522
-    }
523
-
524
-
525
-    /**
526
-     * Return dependencies array and version string according to asset type.
527
-     * For css assets, this filters the auto generated dependencies by css type.
528
-     *
529
-     * @param string $namespace
530
-     * @param string $asset_type
531
-     * @param string $file_path
532
-     * @param string $chunk_name
533
-     * @return array
534
-     * @since 4.9.82.p
535
-     */
536
-    private function getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
537
-    {
538
-        // $asset_dependencies = json_decode(file_get_contents($file_path), true);
539
-        $asset_details = require($file_path);
540
-        $asset_details['dependencies'] = isset($asset_details['dependencies'])
541
-            ? $asset_details['dependencies']
542
-            : [];
543
-        $asset_details['version'] = isset($asset_details['version'])
544
-            ? $asset_details['version']
545
-            : '';
546
-        if ($asset_type === Asset::TYPE_JS) {
547
-            $asset_details['dependencies'] =  $chunk_name === 'eejs-core'
548
-                ? $asset_details['dependencies']
549
-                : $asset_details['dependencies'] + [ CoreAssetManager::JS_HANDLE_JS_CORE ];
550
-            return $asset_details;
551
-        }
552
-        // for css we need to make sure there is actually a css file related to this chunk.
553
-        if (isset($this->manifest_data[ $namespace ])) {
554
-            // array of css chunk files for ee.
555
-            $css_chunks = array_map(
556
-                static function ($value) {
557
-                    return str_replace('.css', '', $value);
558
-                },
559
-                array_filter(
560
-                    array_keys($this->manifest_data[ $namespace ]),
561
-                    static function ($value) {
562
-                        return strpos($value, '.css') !== false;
563
-                    }
564
-                )
565
-            );
566
-            // add known wp chunks with css
567
-            $css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
568
-            // flip for easier search
569
-            $css_chunks = array_flip($css_chunks);
570
-
571
-            // now let's filter the dependencies for the incoming chunk to actual chunks that have styles
572
-            $asset_details['dependencies'] = array_filter(
573
-                $asset_details['dependencies'],
574
-                static function ($chunk_name) use ($css_chunks) {
575
-                    return isset($css_chunks[ $chunk_name ]);
576
-                }
577
-            );
578
-            return $asset_details;
579
-        }
580
-        return ['dependencies' => [], 'version' => ''];
581
-    }
582
-
583
-
584
-    /**
585
-     * Get the dependencies array and version string for the given js asset chunk name
586
-     *
587
-     * @param string $namespace
588
-     * @param string $chunk_name
589
-     * @return array
590
-     * @since 4.10.2.p
591
-     */
592
-    public function getJsAssetDetails($namespace, $chunk_name)
593
-    {
594
-        return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_JS);
595
-    }
596
-
597
-
598
-    /**
599
-     * Get the dependencies array and version string for the given css asset chunk name
600
-     *
601
-     * @param string $namespace
602
-     * @param string $chunk_name
603
-     * @return array
604
-     * @since 4.10.2.p
605
-     */
606
-    public function getCssAssetDetails($namespace, $chunk_name)
607
-    {
608
-        return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_CSS);
609
-    }
610
-
611
-
612
-    /**
613
-     * @throws Exception
614
-     * @throws InvalidArgumentException
615
-     * @throws InvalidFilePathException
616
-     * @since 4.9.62.p
617
-     */
618
-    public function registerManifestFiles()
619
-    {
620
-        try {
621
-            $manifest_files = $this->assets->getManifestFiles();
622
-            foreach ($manifest_files as $manifest_file) {
623
-                $this->registerManifestFile(
624
-                    $manifest_file->assetNamespace(),
625
-                    $manifest_file->urlBase(),
626
-                    $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
627
-                    $manifest_file->filepath()
628
-                );
629
-            }
630
-        } catch (Exception $exception) {
631
-            EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
632
-            new ExceptionStackTraceDisplay($exception);
633
-        }
634
-    }
635
-
636
-
637
-    /**
638
-     * Used to register a js/css manifest file with the registered_manifest_files property.
639
-     *
640
-     * @param string $namespace     Provided to associate the manifest file with a specific namespace.
641
-     * @param string $url_base      The url base for the manifest file location.
642
-     * @param string $manifest_file The absolute path to the manifest file.
643
-     * @param string $manifest_file_path  The path to the folder containing the manifest file. If not provided will be
644
-     *                                    default to `plugin_root/assets/dist`.
645
-     * @throws InvalidArgumentException
646
-     * @throws InvalidFilePathException
647
-     * @since 4.9.59.p
648
-     */
649
-    public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
650
-    {
651
-        if (isset($this->manifest_data[ $namespace ])) {
652
-            if (! $this->debug()) {
653
-                return;
654
-            }
655
-            throw new InvalidArgumentException(
656
-                sprintf(
657
-                    esc_html__(
658
-                        'The namespace for this manifest file has already been registered, choose a namespace other than %s',
659
-                        'event_espresso'
660
-                    ),
661
-                    $namespace
662
-                )
663
-            );
664
-        }
665
-        if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
666
-            if (is_admin()) {
667
-                EE_Error::add_error(
668
-                    sprintf(
669
-                        esc_html__(
670
-                            'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
671
-                            'event_espresso'
672
-                        ),
673
-                        'Event Espresso',
674
-                        $url_base,
675
-                        'plugins_url',
676
-                        'WP_PLUGIN_URL'
677
-                    ),
678
-                    __FILE__,
679
-                    __FUNCTION__,
680
-                    __LINE__
681
-                );
682
-            }
683
-            return;
684
-        }
685
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
686
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
687
-            $this->manifest_data[ $namespace ]['url_base'] = untrailingslashit($url_base);
688
-        }
689
-        if (! isset($this->manifest_data[ $namespace ]['path'])) {
690
-            $this->manifest_data[ $namespace ]['path'] = untrailingslashit($manifest_file_path);
691
-        }
692
-    }
693
-
694
-
695
-    /**
696
-     * Decodes json from the provided manifest file.
697
-     *
698
-     * @since 4.9.59.p
699
-     * @param string $manifest_file Path to manifest file.
700
-     * @return array
701
-     * @throws InvalidFilePathException
702
-     */
703
-    private function decodeManifestFile($manifest_file)
704
-    {
705
-        if (! file_exists($manifest_file)) {
706
-            throw new InvalidFilePathException($manifest_file);
707
-        }
708
-        return json_decode(file_get_contents($manifest_file), true);
709
-    }
710
-
711
-
712
-    /**
713
-     * This is used to set registered script handles that have data.
714
-     *
715
-     * @param string $script_handle
716
-     */
717
-    private function addRegisteredScriptHandlesWithData($script_handle)
718
-    {
719
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
720
-    }
721
-
722
-
723
-    /**i
428
+						'event_espresso'
429
+					),
430
+					$key
431
+				)
432
+			);
433
+		}
434
+		return true;
435
+	}
436
+
437
+
438
+	/**
439
+	 * Get the actual asset path for asset manifests.
440
+	 * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
441
+	 *
442
+	 * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
443
+	 *                           asset file location.
444
+	 * @param string $chunk_name
445
+	 * @param string $asset_type
446
+	 * @return string
447
+	 * @since 4.9.59.p
448
+	 */
449
+	public function getAssetUrl($namespace, $chunk_name, $asset_type)
450
+	{
451
+		$asset_index = $chunk_name . '.' . $asset_type;
452
+		$url = isset(
453
+			$this->manifest_data[ $namespace ][ $asset_index ],
454
+			$this->manifest_data[ $namespace ]['url_base']
455
+		)
456
+			? $this->manifest_data[ $namespace ]['url_base']
457
+			  . $this->manifest_data[ $namespace ][ $asset_index ]
458
+			: '';
459
+		return apply_filters(
460
+			'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
461
+			$url,
462
+			$namespace,
463
+			$chunk_name,
464
+			$asset_type
465
+		);
466
+	}
467
+
468
+
469
+
470
+	/**
471
+	 * Return the url to a js file for the given namespace and chunk name.
472
+	 *
473
+	 * @param string $namespace
474
+	 * @param string $chunk_name
475
+	 * @return string
476
+	 */
477
+	public function getJsUrl($namespace, $chunk_name)
478
+	{
479
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
480
+	}
481
+
482
+
483
+	/**
484
+	 * Return the url to a css file for the given namespace and chunk name.
485
+	 *
486
+	 * @param string $namespace
487
+	 * @param string $chunk_name
488
+	 * @return string
489
+	 */
490
+	public function getCssUrl($namespace, $chunk_name)
491
+	{
492
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
493
+	}
494
+
495
+
496
+	/**
497
+	 * Return the dependencies array and version string for a given asset $chunk_name
498
+	 *
499
+	 * @param string $namespace
500
+	 * @param string $chunk_name
501
+	 * @param string $asset_type
502
+	 * @return array
503
+	 * @since 4.9.82.p
504
+	 */
505
+	private function getDetailsForAsset($namespace, $chunk_name, $asset_type)
506
+	{
507
+		$asset_index = $chunk_name . '.' . $asset_type;
508
+		if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
509
+			$path = isset($this->manifest_data[ $namespace ]['path'])
510
+				? $this->manifest_data[ $namespace ]['path']
511
+				: '';
512
+			$dependencies_index = $chunk_name . '.' . Asset::TYPE_PHP;
513
+			$file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
514
+				? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
515
+				:
516
+				'';
517
+			$this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
518
+				? $this->getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
519
+				: [];
520
+		}
521
+		return $this->dependencies_data[ $namespace ][ $asset_index ];
522
+	}
523
+
524
+
525
+	/**
526
+	 * Return dependencies array and version string according to asset type.
527
+	 * For css assets, this filters the auto generated dependencies by css type.
528
+	 *
529
+	 * @param string $namespace
530
+	 * @param string $asset_type
531
+	 * @param string $file_path
532
+	 * @param string $chunk_name
533
+	 * @return array
534
+	 * @since 4.9.82.p
535
+	 */
536
+	private function getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
537
+	{
538
+		// $asset_dependencies = json_decode(file_get_contents($file_path), true);
539
+		$asset_details = require($file_path);
540
+		$asset_details['dependencies'] = isset($asset_details['dependencies'])
541
+			? $asset_details['dependencies']
542
+			: [];
543
+		$asset_details['version'] = isset($asset_details['version'])
544
+			? $asset_details['version']
545
+			: '';
546
+		if ($asset_type === Asset::TYPE_JS) {
547
+			$asset_details['dependencies'] =  $chunk_name === 'eejs-core'
548
+				? $asset_details['dependencies']
549
+				: $asset_details['dependencies'] + [ CoreAssetManager::JS_HANDLE_JS_CORE ];
550
+			return $asset_details;
551
+		}
552
+		// for css we need to make sure there is actually a css file related to this chunk.
553
+		if (isset($this->manifest_data[ $namespace ])) {
554
+			// array of css chunk files for ee.
555
+			$css_chunks = array_map(
556
+				static function ($value) {
557
+					return str_replace('.css', '', $value);
558
+				},
559
+				array_filter(
560
+					array_keys($this->manifest_data[ $namespace ]),
561
+					static function ($value) {
562
+						return strpos($value, '.css') !== false;
563
+					}
564
+				)
565
+			);
566
+			// add known wp chunks with css
567
+			$css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
568
+			// flip for easier search
569
+			$css_chunks = array_flip($css_chunks);
570
+
571
+			// now let's filter the dependencies for the incoming chunk to actual chunks that have styles
572
+			$asset_details['dependencies'] = array_filter(
573
+				$asset_details['dependencies'],
574
+				static function ($chunk_name) use ($css_chunks) {
575
+					return isset($css_chunks[ $chunk_name ]);
576
+				}
577
+			);
578
+			return $asset_details;
579
+		}
580
+		return ['dependencies' => [], 'version' => ''];
581
+	}
582
+
583
+
584
+	/**
585
+	 * Get the dependencies array and version string for the given js asset chunk name
586
+	 *
587
+	 * @param string $namespace
588
+	 * @param string $chunk_name
589
+	 * @return array
590
+	 * @since 4.10.2.p
591
+	 */
592
+	public function getJsAssetDetails($namespace, $chunk_name)
593
+	{
594
+		return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_JS);
595
+	}
596
+
597
+
598
+	/**
599
+	 * Get the dependencies array and version string for the given css asset chunk name
600
+	 *
601
+	 * @param string $namespace
602
+	 * @param string $chunk_name
603
+	 * @return array
604
+	 * @since 4.10.2.p
605
+	 */
606
+	public function getCssAssetDetails($namespace, $chunk_name)
607
+	{
608
+		return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_CSS);
609
+	}
610
+
611
+
612
+	/**
613
+	 * @throws Exception
614
+	 * @throws InvalidArgumentException
615
+	 * @throws InvalidFilePathException
616
+	 * @since 4.9.62.p
617
+	 */
618
+	public function registerManifestFiles()
619
+	{
620
+		try {
621
+			$manifest_files = $this->assets->getManifestFiles();
622
+			foreach ($manifest_files as $manifest_file) {
623
+				$this->registerManifestFile(
624
+					$manifest_file->assetNamespace(),
625
+					$manifest_file->urlBase(),
626
+					$manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
627
+					$manifest_file->filepath()
628
+				);
629
+			}
630
+		} catch (Exception $exception) {
631
+			EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
632
+			new ExceptionStackTraceDisplay($exception);
633
+		}
634
+	}
635
+
636
+
637
+	/**
638
+	 * Used to register a js/css manifest file with the registered_manifest_files property.
639
+	 *
640
+	 * @param string $namespace     Provided to associate the manifest file with a specific namespace.
641
+	 * @param string $url_base      The url base for the manifest file location.
642
+	 * @param string $manifest_file The absolute path to the manifest file.
643
+	 * @param string $manifest_file_path  The path to the folder containing the manifest file. If not provided will be
644
+	 *                                    default to `plugin_root/assets/dist`.
645
+	 * @throws InvalidArgumentException
646
+	 * @throws InvalidFilePathException
647
+	 * @since 4.9.59.p
648
+	 */
649
+	public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
650
+	{
651
+		if (isset($this->manifest_data[ $namespace ])) {
652
+			if (! $this->debug()) {
653
+				return;
654
+			}
655
+			throw new InvalidArgumentException(
656
+				sprintf(
657
+					esc_html__(
658
+						'The namespace for this manifest file has already been registered, choose a namespace other than %s',
659
+						'event_espresso'
660
+					),
661
+					$namespace
662
+				)
663
+			);
664
+		}
665
+		if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
666
+			if (is_admin()) {
667
+				EE_Error::add_error(
668
+					sprintf(
669
+						esc_html__(
670
+							'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
671
+							'event_espresso'
672
+						),
673
+						'Event Espresso',
674
+						$url_base,
675
+						'plugins_url',
676
+						'WP_PLUGIN_URL'
677
+					),
678
+					__FILE__,
679
+					__FUNCTION__,
680
+					__LINE__
681
+				);
682
+			}
683
+			return;
684
+		}
685
+		$this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
686
+		if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
687
+			$this->manifest_data[ $namespace ]['url_base'] = untrailingslashit($url_base);
688
+		}
689
+		if (! isset($this->manifest_data[ $namespace ]['path'])) {
690
+			$this->manifest_data[ $namespace ]['path'] = untrailingslashit($manifest_file_path);
691
+		}
692
+	}
693
+
694
+
695
+	/**
696
+	 * Decodes json from the provided manifest file.
697
+	 *
698
+	 * @since 4.9.59.p
699
+	 * @param string $manifest_file Path to manifest file.
700
+	 * @return array
701
+	 * @throws InvalidFilePathException
702
+	 */
703
+	private function decodeManifestFile($manifest_file)
704
+	{
705
+		if (! file_exists($manifest_file)) {
706
+			throw new InvalidFilePathException($manifest_file);
707
+		}
708
+		return json_decode(file_get_contents($manifest_file), true);
709
+	}
710
+
711
+
712
+	/**
713
+	 * This is used to set registered script handles that have data.
714
+	 *
715
+	 * @param string $script_handle
716
+	 */
717
+	private function addRegisteredScriptHandlesWithData($script_handle)
718
+	{
719
+		$this->script_handles_with_data[ $script_handle ] = $script_handle;
720
+	}
721
+
722
+
723
+	/**i
724 724
      * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
725 725
      * Dependency stored in WP_Scripts if its set.
726 726
      */
727
-    private function removeAlreadyRegisteredDataForScriptHandles()
728
-    {
729
-        if (empty($this->script_handles_with_data)) {
730
-            return;
731
-        }
732
-        foreach ($this->script_handles_with_data as $script_handle) {
733
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
734
-        }
735
-    }
736
-
737
-
738
-    /**
739
-     * Removes any data dependency registered in WP_Scripts if its set.
740
-     *
741
-     * @param string $script_handle
742
-     */
743
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
744
-    {
745
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
746
-            global $wp_scripts;
747
-            $unset_handle = false;
748
-            if ($wp_scripts->get_data($script_handle, 'data')) {
749
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
750
-                $unset_handle = true;
751
-            }
752
-            //deal with inline_scripts
753
-            if ($wp_scripts->get_data($script_handle, 'before')) {
754
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
755
-                $unset_handle = true;
756
-            }
757
-            if ($wp_scripts->get_data($script_handle, 'after')) {
758
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
759
-            }
760
-            if ($unset_handle) {
761
-                unset($this->script_handles_with_data[ $script_handle ]);
762
-            }
763
-        }
764
-    }
765
-
766
-
767
-    /**
768
-     * register translations for a registered script
769
-     *
770
-     * @param string $handle
771
-     */
772
-    public function registerTranslation($handle)
773
-    {
774
-        $this->i18n_registry->registerScriptI18n($handle);
775
-    }
776
-
777
-
778
-    /**
779
-     * @since 4.9.63.p
780
-     * @return bool
781
-     */
782
-    private function debug()
783
-    {
784
-        return apply_filters(
785
-            'FHEE__EventEspresso_core_services_assets_Registry__debug',
786
-            defined('EE_DEBUG') && EE_DEBUG
787
-        );
788
-    }
789
-
790
-
791
-    /**
792
-     * Get the dependencies array for the given js asset chunk name
793
-     *
794
-     * @param string $namespace
795
-     * @param string $chunk_name
796
-     * @return array
797
-     * @deprecated 4.10.2.p
798
-     * @since 4.9.82.p
799
-     */
800
-    public function getJsDependencies($namespace, $chunk_name)
801
-    {
802
-        $details = $this->getJsAssetDetails($namespace, $chunk_name);
803
-        return isset($details['dependencies']) ? $details['dependencies'] : [];
804
-    }
805
-
806
-
807
-    /**
808
-     * Get the dependencies array for the given css asset chunk name
809
-     *
810
-     * @param string $namespace
811
-     * @param string $chunk_name
812
-     * @return array
813
-     * @deprecated 4.10.2.p
814
-     * @since      4.9.82.p
815
-     */
816
-    public function getCssDependencies($namespace, $chunk_name)
817
-    {
818
-        $details = $this->getCssAssetDetails($namespace, $chunk_name);
819
-        return isset($details['dependencies']) ? $details['dependencies'] : [];
820
-    }
727
+	private function removeAlreadyRegisteredDataForScriptHandles()
728
+	{
729
+		if (empty($this->script_handles_with_data)) {
730
+			return;
731
+		}
732
+		foreach ($this->script_handles_with_data as $script_handle) {
733
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
734
+		}
735
+	}
736
+
737
+
738
+	/**
739
+	 * Removes any data dependency registered in WP_Scripts if its set.
740
+	 *
741
+	 * @param string $script_handle
742
+	 */
743
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
744
+	{
745
+		if (isset($this->script_handles_with_data[ $script_handle ])) {
746
+			global $wp_scripts;
747
+			$unset_handle = false;
748
+			if ($wp_scripts->get_data($script_handle, 'data')) {
749
+				unset($wp_scripts->registered[ $script_handle ]->extra['data']);
750
+				$unset_handle = true;
751
+			}
752
+			//deal with inline_scripts
753
+			if ($wp_scripts->get_data($script_handle, 'before')) {
754
+				unset($wp_scripts->registered[ $script_handle ]->extra['before']);
755
+				$unset_handle = true;
756
+			}
757
+			if ($wp_scripts->get_data($script_handle, 'after')) {
758
+				unset($wp_scripts->registered[ $script_handle ]->extra['after']);
759
+			}
760
+			if ($unset_handle) {
761
+				unset($this->script_handles_with_data[ $script_handle ]);
762
+			}
763
+		}
764
+	}
765
+
766
+
767
+	/**
768
+	 * register translations for a registered script
769
+	 *
770
+	 * @param string $handle
771
+	 */
772
+	public function registerTranslation($handle)
773
+	{
774
+		$this->i18n_registry->registerScriptI18n($handle);
775
+	}
776
+
777
+
778
+	/**
779
+	 * @since 4.9.63.p
780
+	 * @return bool
781
+	 */
782
+	private function debug()
783
+	{
784
+		return apply_filters(
785
+			'FHEE__EventEspresso_core_services_assets_Registry__debug',
786
+			defined('EE_DEBUG') && EE_DEBUG
787
+		);
788
+	}
789
+
790
+
791
+	/**
792
+	 * Get the dependencies array for the given js asset chunk name
793
+	 *
794
+	 * @param string $namespace
795
+	 * @param string $chunk_name
796
+	 * @return array
797
+	 * @deprecated 4.10.2.p
798
+	 * @since 4.9.82.p
799
+	 */
800
+	public function getJsDependencies($namespace, $chunk_name)
801
+	{
802
+		$details = $this->getJsAssetDetails($namespace, $chunk_name);
803
+		return isset($details['dependencies']) ? $details['dependencies'] : [];
804
+	}
805
+
806
+
807
+	/**
808
+	 * Get the dependencies array for the given css asset chunk name
809
+	 *
810
+	 * @param string $namespace
811
+	 * @param string $chunk_name
812
+	 * @return array
813
+	 * @deprecated 4.10.2.p
814
+	 * @since      4.9.82.p
815
+	 */
816
+	public function getCssDependencies($namespace, $chunk_name)
817
+	{
818
+		$details = $this->getCssAssetDetails($namespace, $chunk_name);
819
+		return isset($details['dependencies']) ? $details['dependencies'] : [];
820
+	}
821 821
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 $script->version(),
185 185
                 $script->loadInFooter()
186 186
             );
187
-            if (! $registered && $this->debug()) {
187
+            if ( ! $registered && $this->debug()) {
188 188
                 throw new AssetRegistrationException($script->handle());
189 189
             }
190 190
             $script->setRegistered($registered);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             $this->removeAlreadyRegisteredDataForScriptHandles();
248 248
             wp_add_inline_script(
249 249
                 'eejs-core',
250
-                'var eejsdata=' . wp_json_encode(['data' => $this->jsdata]),
250
+                'var eejsdata='.wp_json_encode(['data' => $this->jsdata]),
251 251
                 'before'
252 252
             );
253 253
             $scripts = $this->assets->getJavascriptAssetsWithData();
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     public function addData($key, $value)
282 282
     {
283 283
         if ($this->verifyDataNotExisting($key)) {
284
-            $this->jsdata[ $key ] = $value;
284
+            $this->jsdata[$key] = $value;
285 285
         }
286 286
     }
287 287
 
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
      */
307 307
     public function pushData($key, $value)
308 308
     {
309
-        if (isset($this->jsdata[ $key ])
310
-            && ! is_array($this->jsdata[ $key ])
309
+        if (isset($this->jsdata[$key])
310
+            && ! is_array($this->jsdata[$key])
311 311
         ) {
312
-            if (! $this->debug()) {
312
+            if ( ! $this->debug()) {
313 313
                 return;
314 314
             }
315 315
             throw new InvalidArgumentException(
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
                 )
325 325
             );
326 326
         }
327
-        if ( ! isset( $this->jsdata[ $key ] ) ) {
328
-            $this->jsdata[ $key ] = is_array($value) ? $value : [$value];
327
+        if ( ! isset($this->jsdata[$key])) {
328
+            $this->jsdata[$key] = is_array($value) ? $value : [$value];
329 329
         } else {
330
-            $this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
330
+            $this->jsdata[$key] = array_merge($this->jsdata[$key], (array) $value);
331 331
         }
332 332
     }
333 333
 
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
      */
343 343
     public function addTemplate($template_reference, $template_content)
344 344
     {
345
-        if (! isset($this->jsdata['templates'])) {
345
+        if ( ! isset($this->jsdata['templates'])) {
346 346
             $this->jsdata['templates'] = array();
347 347
         }
348 348
         //no overrides allowed.
349
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
350
-            if (! $this->debug()) {
349
+        if (isset($this->jsdata['templates'][$template_reference])) {
350
+            if ( ! $this->debug()) {
351 351
                 return;
352 352
             }
353 353
             throw new InvalidArgumentException(
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
                 )
361 361
             );
362 362
         }
363
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
363
+        $this->jsdata['templates'][$template_reference] = $template_content;
364 364
     }
365 365
 
366 366
 
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
      */
373 373
     public function getTemplate($template_reference)
374 374
     {
375
-        return isset($this->jsdata['templates'][ $template_reference ])
376
-            ? $this->jsdata['templates'][ $template_reference ]
375
+        return isset($this->jsdata['templates'][$template_reference])
376
+            ? $this->jsdata['templates'][$template_reference]
377 377
             : '';
378 378
     }
379 379
 
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
      */
387 387
     public function getData($key)
388 388
     {
389
-        return isset($this->jsdata[ $key ])
390
-            ? $this->jsdata[ $key ]
389
+        return isset($this->jsdata[$key])
390
+            ? $this->jsdata[$key]
391 391
             : false;
392 392
     }
393 393
 
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
      */
403 403
     protected function verifyDataNotExisting($key)
404 404
     {
405
-        if (isset($this->jsdata[ $key ])) {
406
-            if (! $this->debug()) {
405
+        if (isset($this->jsdata[$key])) {
406
+            if ( ! $this->debug()) {
407 407
                 return false;
408 408
             }
409
-            if (is_array($this->jsdata[ $key ])) {
409
+            if (is_array($this->jsdata[$key])) {
410 410
                 throw new InvalidArgumentException(
411 411
                     sprintf(
412 412
                         __(
@@ -448,13 +448,13 @@  discard block
 block discarded – undo
448 448
      */
449 449
     public function getAssetUrl($namespace, $chunk_name, $asset_type)
450 450
     {
451
-        $asset_index = $chunk_name . '.' . $asset_type;
451
+        $asset_index = $chunk_name.'.'.$asset_type;
452 452
         $url = isset(
453
-            $this->manifest_data[ $namespace ][ $asset_index ],
454
-            $this->manifest_data[ $namespace ]['url_base']
453
+            $this->manifest_data[$namespace][$asset_index],
454
+            $this->manifest_data[$namespace]['url_base']
455 455
         )
456
-            ? $this->manifest_data[ $namespace ]['url_base']
457
-              . $this->manifest_data[ $namespace ][ $asset_index ]
456
+            ? $this->manifest_data[$namespace]['url_base']
457
+              . $this->manifest_data[$namespace][$asset_index]
458 458
             : '';
459 459
         return apply_filters(
460 460
             'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
@@ -504,21 +504,21 @@  discard block
 block discarded – undo
504 504
      */
505 505
     private function getDetailsForAsset($namespace, $chunk_name, $asset_type)
506 506
     {
507
-        $asset_index = $chunk_name . '.' . $asset_type;
508
-        if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
509
-            $path = isset($this->manifest_data[ $namespace ]['path'])
510
-                ? $this->manifest_data[ $namespace ]['path']
507
+        $asset_index = $chunk_name.'.'.$asset_type;
508
+        if ( ! isset($this->dependencies_data[$namespace][$asset_index])) {
509
+            $path = isset($this->manifest_data[$namespace]['path'])
510
+                ? $this->manifest_data[$namespace]['path']
511 511
                 : '';
512
-            $dependencies_index = $chunk_name . '.' . Asset::TYPE_PHP;
513
-            $file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
514
-                ? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
512
+            $dependencies_index = $chunk_name.'.'.Asset::TYPE_PHP;
513
+            $file_path = isset($this->manifest_data[$namespace][$dependencies_index])
514
+                ? $path.$this->manifest_data[$namespace][$dependencies_index]
515 515
                 :
516 516
                 '';
517
-            $this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
517
+            $this->dependencies_data[$namespace][$asset_index] = $file_path !== '' && file_exists($file_path)
518 518
                 ? $this->getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
519 519
                 : [];
520 520
         }
521
-        return $this->dependencies_data[ $namespace ][ $asset_index ];
521
+        return $this->dependencies_data[$namespace][$asset_index];
522 522
     }
523 523
 
524 524
 
@@ -544,35 +544,35 @@  discard block
 block discarded – undo
544 544
             ? $asset_details['version']
545 545
             : '';
546 546
         if ($asset_type === Asset::TYPE_JS) {
547
-            $asset_details['dependencies'] =  $chunk_name === 'eejs-core'
547
+            $asset_details['dependencies'] = $chunk_name === 'eejs-core'
548 548
                 ? $asset_details['dependencies']
549
-                : $asset_details['dependencies'] + [ CoreAssetManager::JS_HANDLE_JS_CORE ];
549
+                : $asset_details['dependencies'] + [CoreAssetManager::JS_HANDLE_JS_CORE];
550 550
             return $asset_details;
551 551
         }
552 552
         // for css we need to make sure there is actually a css file related to this chunk.
553
-        if (isset($this->manifest_data[ $namespace ])) {
553
+        if (isset($this->manifest_data[$namespace])) {
554 554
             // array of css chunk files for ee.
555 555
             $css_chunks = array_map(
556
-                static function ($value) {
556
+                static function($value) {
557 557
                     return str_replace('.css', '', $value);
558 558
                 },
559 559
                 array_filter(
560
-                    array_keys($this->manifest_data[ $namespace ]),
561
-                    static function ($value) {
560
+                    array_keys($this->manifest_data[$namespace]),
561
+                    static function($value) {
562 562
                         return strpos($value, '.css') !== false;
563 563
                     }
564 564
                 )
565 565
             );
566 566
             // add known wp chunks with css
567
-            $css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
567
+            $css_chunks = array_merge($css_chunks, $this->wp_css_handle_dependencies);
568 568
             // flip for easier search
569 569
             $css_chunks = array_flip($css_chunks);
570 570
 
571 571
             // now let's filter the dependencies for the incoming chunk to actual chunks that have styles
572 572
             $asset_details['dependencies'] = array_filter(
573 573
                 $asset_details['dependencies'],
574
-                static function ($chunk_name) use ($css_chunks) {
575
-                    return isset($css_chunks[ $chunk_name ]);
574
+                static function($chunk_name) use ($css_chunks) {
575
+                    return isset($css_chunks[$chunk_name]);
576 576
                 }
577 577
             );
578 578
             return $asset_details;
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
                 $this->registerManifestFile(
624 624
                     $manifest_file->assetNamespace(),
625 625
                     $manifest_file->urlBase(),
626
-                    $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
626
+                    $manifest_file->filepath().Registry::FILE_NAME_BUILD_MANIFEST,
627 627
                     $manifest_file->filepath()
628 628
                 );
629 629
             }
@@ -648,8 +648,8 @@  discard block
 block discarded – undo
648 648
      */
649 649
     public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
650 650
     {
651
-        if (isset($this->manifest_data[ $namespace ])) {
652
-            if (! $this->debug()) {
651
+        if (isset($this->manifest_data[$namespace])) {
652
+            if ( ! $this->debug()) {
653 653
                 return;
654 654
             }
655 655
             throw new InvalidArgumentException(
@@ -682,12 +682,12 @@  discard block
 block discarded – undo
682 682
             }
683 683
             return;
684 684
         }
685
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
686
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
687
-            $this->manifest_data[ $namespace ]['url_base'] = untrailingslashit($url_base);
685
+        $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
686
+        if ( ! isset($this->manifest_data[$namespace]['url_base'])) {
687
+            $this->manifest_data[$namespace]['url_base'] = untrailingslashit($url_base);
688 688
         }
689
-        if (! isset($this->manifest_data[ $namespace ]['path'])) {
690
-            $this->manifest_data[ $namespace ]['path'] = untrailingslashit($manifest_file_path);
689
+        if ( ! isset($this->manifest_data[$namespace]['path'])) {
690
+            $this->manifest_data[$namespace]['path'] = untrailingslashit($manifest_file_path);
691 691
         }
692 692
     }
693 693
 
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
      */
703 703
     private function decodeManifestFile($manifest_file)
704 704
     {
705
-        if (! file_exists($manifest_file)) {
705
+        if ( ! file_exists($manifest_file)) {
706 706
             throw new InvalidFilePathException($manifest_file);
707 707
         }
708 708
         return json_decode(file_get_contents($manifest_file), true);
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
      */
717 717
     private function addRegisteredScriptHandlesWithData($script_handle)
718 718
     {
719
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
719
+        $this->script_handles_with_data[$script_handle] = $script_handle;
720 720
     }
721 721
 
722 722
 
@@ -742,23 +742,23 @@  discard block
 block discarded – undo
742 742
      */
743 743
     private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
744 744
     {
745
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
745
+        if (isset($this->script_handles_with_data[$script_handle])) {
746 746
             global $wp_scripts;
747 747
             $unset_handle = false;
748 748
             if ($wp_scripts->get_data($script_handle, 'data')) {
749
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
749
+                unset($wp_scripts->registered[$script_handle]->extra['data']);
750 750
                 $unset_handle = true;
751 751
             }
752 752
             //deal with inline_scripts
753 753
             if ($wp_scripts->get_data($script_handle, 'before')) {
754
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
754
+                unset($wp_scripts->registered[$script_handle]->extra['before']);
755 755
                 $unset_handle = true;
756 756
             }
757 757
             if ($wp_scripts->get_data($script_handle, 'after')) {
758
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
758
+                unset($wp_scripts->registered[$script_handle]->extra['after']);
759 759
             }
760 760
             if ($unset_handle) {
761
-                unset($this->script_handles_with_data[ $script_handle ]);
761
+                unset($this->script_handles_with_data[$script_handle]);
762 762
             }
763 763
         }
764 764
     }
Please login to merge, or discard this patch.
core/services/routing/RouteInterface.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -19,50 +19,50 @@
 block discarded – undo
19 19
 interface RouteInterface
20 20
 {
21 21
 
22
-    /**
23
-     * @return JsonDataNode
24
-     */
25
-    public function dataNode();
22
+	/**
23
+	 * @return JsonDataNode
24
+	 */
25
+	public function dataNode();
26 26
 
27 27
 
28
-    /**
29
-     * final method called by RouteHandler on Route which in turn calls requestHandler()
30
-     *
31
-     * @return bool
32
-     * @since   $VID:$
33
-     */
34
-    public function handleRequest();
28
+	/**
29
+	 * final method called by RouteHandler on Route which in turn calls requestHandler()
30
+	 *
31
+	 * @return bool
32
+	 * @since   $VID:$
33
+	 */
34
+	public function handleRequest();
35 35
 
36 36
 
37
-    /**
38
-     * a place to run any setup required for matchesCurrentRequest() which runs immediately after
39
-     *
40
-     * @since $VID:$
41
-     */
42
-    public function initialize();
37
+	/**
38
+	 * a place to run any setup required for matchesCurrentRequest() which runs immediately after
39
+	 *
40
+	 * @since $VID:$
41
+	 */
42
+	public function initialize();
43 43
 
44 44
 
45
-    /**
46
-     * returns true if the route has already been handled
47
-     *
48
-     * @return bool
49
-     */
50
-    public function isHandled();
45
+	/**
46
+	 * returns true if the route has already been handled
47
+	 *
48
+	 * @return bool
49
+	 */
50
+	public function isHandled();
51 51
 
52 52
 
53
-    /**
54
-     * returns true if the route has not yet been handled
55
-     *
56
-     * @return bool
57
-     */
58
-    public function isNotHandled();
53
+	/**
54
+	 * returns true if the route has not yet been handled
55
+	 *
56
+	 * @return bool
57
+	 */
58
+	public function isNotHandled();
59 59
 
60 60
 
61
-    /**
62
-     * returns true if the current request matches this route
63
-     *
64
-     * @return bool
65
-     * @since   $VID:$
66
-     */
67
-    public function matchesCurrentRequest();
61
+	/**
62
+	 * returns true if the current request matches this route
63
+	 *
64
+	 * @return bool
65
+	 * @since   $VID:$
66
+	 */
67
+	public function matchesCurrentRequest();
68 68
 }
Please login to merge, or discard this patch.