@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
74 | 74 | */ |
75 | 75 | $input_fields = []; |
76 | - if (! empty($this->args['where'])) { |
|
76 | + if ( ! empty($this->args['where'])) { |
|
77 | 77 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
78 | 78 | } |
79 | 79 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Merge the input_fields with the default query_args |
100 | 100 | */ |
101 | - if (! empty($input_fields)) { |
|
101 | + if ( ! empty($input_fields)) { |
|
102 | 102 | $where_params = array_merge($where_params, $input_fields); |
103 | 103 | } |
104 | 104 |
@@ -16,133 +16,133 @@ |
||
16 | 16 | */ |
17 | 17 | class VenueConnectionResolver extends AbstractConnectionResolver |
18 | 18 | { |
19 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | - /** |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public function get_loader_name() |
|
24 | - { |
|
25 | - return 'espresso_venue'; |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * @return EEM_Venue |
|
30 | - * @throws EE_Error |
|
31 | - * @throws InvalidArgumentException |
|
32 | - * @throws InvalidDataTypeException |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - * @throws ReflectionException |
|
35 | - */ |
|
36 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
37 | - public function get_query() |
|
38 | - { |
|
39 | - return EEM_Venue::instance(); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * Return an array of item IDs from the query |
|
45 | - * |
|
46 | - * @return array |
|
47 | - */ |
|
48 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
49 | - public function get_ids() |
|
50 | - { |
|
51 | - $results = $this->query->get_col($this->query_args); |
|
52 | - |
|
53 | - return ! empty($results) ? $results : []; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
59 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
60 | - * handle batch resolution of the posts. |
|
61 | - * |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
65 | - public function get_query_args() |
|
66 | - { |
|
67 | - $where_params = []; |
|
68 | - $query_args = []; |
|
69 | - |
|
70 | - $query_args['limit'] = $this->getLimit(); |
|
71 | - |
|
72 | - // Avoid multiple entries by join. |
|
73 | - $query_args['group_by'] = 'VNU_ID'; |
|
74 | - |
|
75 | - $query_args['default_where_conditions'] = 'minimum'; |
|
76 | - |
|
77 | - /** |
|
78 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
79 | - */ |
|
80 | - $input_fields = []; |
|
81 | - if (! empty($this->args['where'])) { |
|
82 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
87 | - * For example, if we're querying for datetime as a field of event query, this will automatically |
|
88 | - * set the query to pull datetimes that belong to that event. |
|
89 | - * We can set more cases for other source types. |
|
90 | - */ |
|
91 | - if (is_object($this->source)) { |
|
92 | - switch (true) { |
|
93 | - // Assumed to be an event |
|
94 | - case $this->source instanceof Post: |
|
95 | - $where_params['Event.EVT_ID'] = $this->source->ID; |
|
96 | - break; |
|
97 | - case $this->source instanceof EE_Event: |
|
98 | - $where_params['Event.EVT_ID'] = $this->source->ID(); |
|
99 | - break; |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Merge the input_fields with the default query_args |
|
105 | - */ |
|
106 | - if (! empty($input_fields)) { |
|
107 | - $where_params = array_merge($where_params, $input_fields); |
|
108 | - } |
|
109 | - |
|
110 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'VNU_ID'); |
|
111 | - |
|
112 | - $where_params = apply_filters( |
|
113 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_where_params', |
|
114 | - $where_params, |
|
115 | - $this->source, |
|
116 | - $this->args |
|
117 | - ); |
|
118 | - |
|
119 | - $query_args[] = $where_params; |
|
120 | - |
|
121 | - /** |
|
122 | - * Return the $query_args |
|
123 | - */ |
|
124 | - return apply_filters( |
|
125 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_query_args', |
|
126 | - $query_args, |
|
127 | - $this->source, |
|
128 | - $this->args |
|
129 | - ); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
135 | - * friendly keys. |
|
136 | - * |
|
137 | - * @param array $where_args |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - public function sanitizeInputFields($where_args) |
|
141 | - { |
|
142 | - return $this->sanitizeWhereArgsForInputFields( |
|
143 | - $where_args, |
|
144 | - [], |
|
145 | - [] |
|
146 | - ); |
|
147 | - } |
|
19 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | + /** |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public function get_loader_name() |
|
24 | + { |
|
25 | + return 'espresso_venue'; |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * @return EEM_Venue |
|
30 | + * @throws EE_Error |
|
31 | + * @throws InvalidArgumentException |
|
32 | + * @throws InvalidDataTypeException |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + * @throws ReflectionException |
|
35 | + */ |
|
36 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
37 | + public function get_query() |
|
38 | + { |
|
39 | + return EEM_Venue::instance(); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * Return an array of item IDs from the query |
|
45 | + * |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
49 | + public function get_ids() |
|
50 | + { |
|
51 | + $results = $this->query->get_col($this->query_args); |
|
52 | + |
|
53 | + return ! empty($results) ? $results : []; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
59 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
60 | + * handle batch resolution of the posts. |
|
61 | + * |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
65 | + public function get_query_args() |
|
66 | + { |
|
67 | + $where_params = []; |
|
68 | + $query_args = []; |
|
69 | + |
|
70 | + $query_args['limit'] = $this->getLimit(); |
|
71 | + |
|
72 | + // Avoid multiple entries by join. |
|
73 | + $query_args['group_by'] = 'VNU_ID'; |
|
74 | + |
|
75 | + $query_args['default_where_conditions'] = 'minimum'; |
|
76 | + |
|
77 | + /** |
|
78 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
79 | + */ |
|
80 | + $input_fields = []; |
|
81 | + if (! empty($this->args['where'])) { |
|
82 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
87 | + * For example, if we're querying for datetime as a field of event query, this will automatically |
|
88 | + * set the query to pull datetimes that belong to that event. |
|
89 | + * We can set more cases for other source types. |
|
90 | + */ |
|
91 | + if (is_object($this->source)) { |
|
92 | + switch (true) { |
|
93 | + // Assumed to be an event |
|
94 | + case $this->source instanceof Post: |
|
95 | + $where_params['Event.EVT_ID'] = $this->source->ID; |
|
96 | + break; |
|
97 | + case $this->source instanceof EE_Event: |
|
98 | + $where_params['Event.EVT_ID'] = $this->source->ID(); |
|
99 | + break; |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Merge the input_fields with the default query_args |
|
105 | + */ |
|
106 | + if (! empty($input_fields)) { |
|
107 | + $where_params = array_merge($where_params, $input_fields); |
|
108 | + } |
|
109 | + |
|
110 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'VNU_ID'); |
|
111 | + |
|
112 | + $where_params = apply_filters( |
|
113 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_where_params', |
|
114 | + $where_params, |
|
115 | + $this->source, |
|
116 | + $this->args |
|
117 | + ); |
|
118 | + |
|
119 | + $query_args[] = $where_params; |
|
120 | + |
|
121 | + /** |
|
122 | + * Return the $query_args |
|
123 | + */ |
|
124 | + return apply_filters( |
|
125 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_query_args', |
|
126 | + $query_args, |
|
127 | + $this->source, |
|
128 | + $this->args |
|
129 | + ); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
135 | + * friendly keys. |
|
136 | + * |
|
137 | + * @param array $where_args |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + public function sanitizeInputFields($where_args) |
|
141 | + { |
|
142 | + return $this->sanitizeWhereArgsForInputFields( |
|
143 | + $where_args, |
|
144 | + [], |
|
145 | + [] |
|
146 | + ); |
|
147 | + } |
|
148 | 148 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | public function initialize() |
37 | 37 | { |
38 | 38 | $current_user = wp_get_current_user(); |
39 | - if (! $current_user instanceof WP_User) { |
|
39 | + if ( ! $current_user instanceof WP_User) { |
|
40 | 40 | $current_user = new WP_User(); |
41 | 41 | } |
42 | 42 |
@@ -16,51 +16,51 @@ |
||
16 | 16 | */ |
17 | 17 | class CurrentUser extends JsonDataNode |
18 | 18 | { |
19 | - const NODE_NAME = 'currentUser'; |
|
19 | + const NODE_NAME = 'currentUser'; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @var Capabilities $capabilities |
|
23 | - */ |
|
24 | - private $capabilities; |
|
21 | + /** |
|
22 | + * @var Capabilities $capabilities |
|
23 | + */ |
|
24 | + private $capabilities; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param Capabilities $capabilities |
|
28 | - * @param JsonDataNodeValidator $validator |
|
29 | - */ |
|
30 | - public function __construct(Capabilities $capabilities, JsonDataNodeValidator $validator) |
|
31 | - { |
|
32 | - parent::__construct($validator); |
|
33 | - $this->capabilities = $capabilities; |
|
34 | - $this->setNodeName(CurrentUser::NODE_NAME); |
|
35 | - } |
|
26 | + /** |
|
27 | + * @param Capabilities $capabilities |
|
28 | + * @param JsonDataNodeValidator $validator |
|
29 | + */ |
|
30 | + public function __construct(Capabilities $capabilities, JsonDataNodeValidator $validator) |
|
31 | + { |
|
32 | + parent::__construct($validator); |
|
33 | + $this->capabilities = $capabilities; |
|
34 | + $this->setNodeName(CurrentUser::NODE_NAME); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @inheritDoc |
|
39 | - */ |
|
40 | - public function initialize() |
|
41 | - { |
|
42 | - $current_user = wp_get_current_user(); |
|
43 | - if (! $current_user instanceof WP_User) { |
|
44 | - $current_user = new WP_User(); |
|
45 | - } |
|
37 | + /** |
|
38 | + * @inheritDoc |
|
39 | + */ |
|
40 | + public function initialize() |
|
41 | + { |
|
42 | + $current_user = wp_get_current_user(); |
|
43 | + if (! $current_user instanceof WP_User) { |
|
44 | + $current_user = new WP_User(); |
|
45 | + } |
|
46 | 46 | |
47 | - if (class_exists(Relay::class)) { |
|
48 | - $this->addData('id', Relay::toGlobalId('user', $current_user->ID)); |
|
49 | - } |
|
50 | - $this->addData('databaseId', $current_user->ID); |
|
51 | - $this->addData('description', $current_user->description); |
|
52 | - $this->addData('email', $current_user->user_email); |
|
53 | - $this->addData('firstName', $current_user->first_name); |
|
54 | - $this->addData('isa', is_super_admin($current_user->ID)); |
|
55 | - $this->addData('lastName', $current_user->last_name); |
|
56 | - $this->addData('locale', get_user_locale($current_user->ID)); |
|
57 | - $this->addData('name', $current_user->display_name); |
|
58 | - $this->addData('nicename', $current_user->user_nicename); |
|
59 | - $this->addData('nickname', $current_user->nickname); |
|
60 | - $this->addData('username', $current_user->user_login); |
|
61 | - $this->addData('roles', $current_user->roles); |
|
62 | - $this->addData('__typename', 'User'); |
|
63 | - $this->addDataNode($this->capabilities); |
|
64 | - $this->setInitialized(true); |
|
65 | - } |
|
47 | + if (class_exists(Relay::class)) { |
|
48 | + $this->addData('id', Relay::toGlobalId('user', $current_user->ID)); |
|
49 | + } |
|
50 | + $this->addData('databaseId', $current_user->ID); |
|
51 | + $this->addData('description', $current_user->description); |
|
52 | + $this->addData('email', $current_user->user_email); |
|
53 | + $this->addData('firstName', $current_user->first_name); |
|
54 | + $this->addData('isa', is_super_admin($current_user->ID)); |
|
55 | + $this->addData('lastName', $current_user->last_name); |
|
56 | + $this->addData('locale', get_user_locale($current_user->ID)); |
|
57 | + $this->addData('name', $current_user->display_name); |
|
58 | + $this->addData('nicename', $current_user->user_nicename); |
|
59 | + $this->addData('nickname', $current_user->nickname); |
|
60 | + $this->addData('username', $current_user->user_login); |
|
61 | + $this->addData('roles', $current_user->roles); |
|
62 | + $this->addData('__typename', 'User'); |
|
63 | + $this->addDataNode($this->capabilities); |
|
64 | + $this->setInitialized(true); |
|
65 | + } |
|
66 | 66 | } |
@@ -44,27 +44,27 @@ |
||
44 | 44 | $args['PRC_name'] = sanitize_text_field($input['name']); |
45 | 45 | } |
46 | 46 | |
47 | - if (! empty($input['order'])) { |
|
47 | + if ( ! empty($input['order'])) { |
|
48 | 48 | $args['PRC_order'] = (int) $input['order']; |
49 | 49 | } |
50 | 50 | |
51 | - if (! empty($input['overrides'])) { |
|
51 | + if ( ! empty($input['overrides'])) { |
|
52 | 52 | $args['PRC_overrides'] = (int) $input['overrides']; |
53 | 53 | } |
54 | 54 | |
55 | - if (! empty($input['parent'])) { |
|
55 | + if ( ! empty($input['parent'])) { |
|
56 | 56 | $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
57 | 57 | $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
58 | 58 | } |
59 | 59 | |
60 | - if (! empty($input['priceType'])) { |
|
60 | + if ( ! empty($input['priceType'])) { |
|
61 | 61 | $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
62 | 62 | $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
63 | 63 | } |
64 | 64 | |
65 | - if (! empty($input['wpUser'])) { |
|
65 | + if ( ! empty($input['wpUser'])) { |
|
66 | 66 | $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
67 | - $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
67 | + $args['PRC_wp_user'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return apply_filters( |
@@ -12,64 +12,64 @@ |
||
12 | 12 | */ |
13 | 13 | class PriceMutation |
14 | 14 | { |
15 | - /** |
|
16 | - * Maps the GraphQL input to a format that the model functions can use |
|
17 | - * |
|
18 | - * @param array $input Data coming from the GraphQL mutation query input |
|
19 | - * @return array |
|
20 | - */ |
|
21 | - public static function prepareFields($input) |
|
22 | - { |
|
23 | - $args = []; |
|
15 | + /** |
|
16 | + * Maps the GraphQL input to a format that the model functions can use |
|
17 | + * |
|
18 | + * @param array $input Data coming from the GraphQL mutation query input |
|
19 | + * @return array |
|
20 | + */ |
|
21 | + public static function prepareFields($input) |
|
22 | + { |
|
23 | + $args = []; |
|
24 | 24 | |
25 | - // amount can be 0 |
|
26 | - if (array_key_exists('amount', $input)) { |
|
27 | - $args['PRC_amount'] = (float) $input['amount']; |
|
28 | - } |
|
25 | + // amount can be 0 |
|
26 | + if (array_key_exists('amount', $input)) { |
|
27 | + $args['PRC_amount'] = (float) $input['amount']; |
|
28 | + } |
|
29 | 29 | |
30 | - if (isset($input['description'])) { |
|
31 | - $args['PRC_desc'] = wp_kses_post($input['description']); |
|
32 | - } |
|
30 | + if (isset($input['description'])) { |
|
31 | + $args['PRC_desc'] = wp_kses_post($input['description']); |
|
32 | + } |
|
33 | 33 | |
34 | - if (array_key_exists('isDefault', $input)) { |
|
35 | - $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
36 | - } |
|
34 | + if (array_key_exists('isDefault', $input)) { |
|
35 | + $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
36 | + } |
|
37 | 37 | |
38 | - if (array_key_exists('isTrashed', $input)) { |
|
39 | - $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
40 | - } |
|
38 | + if (array_key_exists('isTrashed', $input)) { |
|
39 | + $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
40 | + } |
|
41 | 41 | |
42 | - if (isset($input['name'])) { |
|
43 | - $args['PRC_name'] = sanitize_text_field($input['name']); |
|
44 | - } |
|
42 | + if (isset($input['name'])) { |
|
43 | + $args['PRC_name'] = sanitize_text_field($input['name']); |
|
44 | + } |
|
45 | 45 | |
46 | - if (! empty($input['order'])) { |
|
47 | - $args['PRC_order'] = (int) $input['order']; |
|
48 | - } |
|
46 | + if (! empty($input['order'])) { |
|
47 | + $args['PRC_order'] = (int) $input['order']; |
|
48 | + } |
|
49 | 49 | |
50 | - if (! empty($input['overrides'])) { |
|
51 | - $args['PRC_overrides'] = (int) $input['overrides']; |
|
52 | - } |
|
50 | + if (! empty($input['overrides'])) { |
|
51 | + $args['PRC_overrides'] = (int) $input['overrides']; |
|
52 | + } |
|
53 | 53 | |
54 | - if (! empty($input['parent'])) { |
|
55 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
56 | - $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
57 | - } |
|
54 | + if (! empty($input['parent'])) { |
|
55 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
56 | + $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
57 | + } |
|
58 | 58 | |
59 | - if (! empty($input['priceType'])) { |
|
60 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
61 | - $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
62 | - } |
|
59 | + if (! empty($input['priceType'])) { |
|
60 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
61 | + $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
62 | + } |
|
63 | 63 | |
64 | - if (! empty($input['wpUser'])) { |
|
65 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
66 | - $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
67 | - } |
|
64 | + if (! empty($input['wpUser'])) { |
|
65 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
66 | + $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
67 | + } |
|
68 | 68 | |
69 | - return apply_filters( |
|
70 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__price_args', |
|
71 | - $args, |
|
72 | - $input |
|
73 | - ); |
|
74 | - } |
|
69 | + return apply_filters( |
|
70 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__price_args', |
|
71 | + $args, |
|
72 | + $input |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | // $errors = []; |
42 | 42 | |
43 | 43 | try { |
44 | - if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
44 | + if (empty($input['uniqueInputs']) || ! is_array($input['uniqueInputs'])) { |
|
45 | 45 | throw new OutOfBoundsException( |
46 | 46 | esc_html__('A valid input was not provided.', 'event_espresso') |
47 | 47 | ); |
@@ -9,69 +9,69 @@ |
||
9 | 9 | |
10 | 10 | class BulkEntityMutator extends EntityMutator |
11 | 11 | { |
12 | - /** |
|
13 | - * @var callable $entity_mutator . |
|
14 | - */ |
|
15 | - protected $entity_mutator; |
|
12 | + /** |
|
13 | + * @var callable $entity_mutator . |
|
14 | + */ |
|
15 | + protected $entity_mutator; |
|
16 | 16 | |
17 | - /** |
|
18 | - * BulkEntityMutator constructor. |
|
19 | - * |
|
20 | - * @param callable $entity_mutator The mutator for an entity. |
|
21 | - */ |
|
22 | - public function __construct(callable $entity_mutator) |
|
23 | - { |
|
24 | - $this->entity_mutator = $entity_mutator; |
|
25 | - } |
|
26 | - /** |
|
27 | - * Bulk updates entities. |
|
28 | - * |
|
29 | - * @param array $input The input for the mutation |
|
30 | - * @param \WPGraphQL\AppContext $context The AppContext passed down to all resolvers |
|
31 | - * @param \GraphQL\Type\Definition\ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
32 | - * @return array |
|
33 | - */ |
|
34 | - public function updateEntities($input, $context, $info) |
|
35 | - { |
|
17 | + /** |
|
18 | + * BulkEntityMutator constructor. |
|
19 | + * |
|
20 | + * @param callable $entity_mutator The mutator for an entity. |
|
21 | + */ |
|
22 | + public function __construct(callable $entity_mutator) |
|
23 | + { |
|
24 | + $this->entity_mutator = $entity_mutator; |
|
25 | + } |
|
26 | + /** |
|
27 | + * Bulk updates entities. |
|
28 | + * |
|
29 | + * @param array $input The input for the mutation |
|
30 | + * @param \WPGraphQL\AppContext $context The AppContext passed down to all resolvers |
|
31 | + * @param \GraphQL\Type\Definition\ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
32 | + * @return array |
|
33 | + */ |
|
34 | + public function updateEntities($input, $context, $info) |
|
35 | + { |
|
36 | 36 | |
37 | - $updated = []; |
|
38 | - $failed = []; |
|
39 | - // TODO Add meaningful error messages for every failure. |
|
40 | - // $errors = []; |
|
37 | + $updated = []; |
|
38 | + $failed = []; |
|
39 | + // TODO Add meaningful error messages for every failure. |
|
40 | + // $errors = []; |
|
41 | 41 | |
42 | - try { |
|
43 | - if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
44 | - throw new OutOfBoundsException( |
|
45 | - esc_html__('A valid input was not provided.', 'event_espresso') |
|
46 | - ); |
|
47 | - } |
|
42 | + try { |
|
43 | + if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
44 | + throw new OutOfBoundsException( |
|
45 | + esc_html__('A valid input was not provided.', 'event_espresso') |
|
46 | + ); |
|
47 | + } |
|
48 | 48 | |
49 | - $sharedInput = ! empty($input['sharedInput']) ? $input['sharedInput'] : []; |
|
49 | + $sharedInput = ! empty($input['sharedInput']) ? $input['sharedInput'] : []; |
|
50 | 50 | |
51 | - foreach ($input['uniqueInputs'] as $uniqueInput) { |
|
52 | - try { |
|
53 | - // values in $uniqueInput will override those in $sharedInput |
|
54 | - $finalInput = array_merge($sharedInput, $uniqueInput); |
|
55 | - // mutate the individual entity. |
|
56 | - $mutator = $this->entity_mutator; |
|
57 | - $mutator($finalInput, $context, $info); |
|
58 | - // we are here it means the update was successful. |
|
59 | - $updated[] = $uniqueInput['id']; |
|
60 | - } catch (Exception $e) { |
|
61 | - // sorry mate, couldn't help you :( |
|
62 | - $failed[] = $uniqueInput['id']; |
|
63 | - } |
|
64 | - } |
|
65 | - } catch (Exception $exception) { |
|
66 | - EntityMutator::handleExceptions( |
|
67 | - $exception, |
|
68 | - esc_html__( |
|
69 | - 'Could not perform the update because of the following error(s)', |
|
70 | - 'event_espresso' |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
51 | + foreach ($input['uniqueInputs'] as $uniqueInput) { |
|
52 | + try { |
|
53 | + // values in $uniqueInput will override those in $sharedInput |
|
54 | + $finalInput = array_merge($sharedInput, $uniqueInput); |
|
55 | + // mutate the individual entity. |
|
56 | + $mutator = $this->entity_mutator; |
|
57 | + $mutator($finalInput, $context, $info); |
|
58 | + // we are here it means the update was successful. |
|
59 | + $updated[] = $uniqueInput['id']; |
|
60 | + } catch (Exception $e) { |
|
61 | + // sorry mate, couldn't help you :( |
|
62 | + $failed[] = $uniqueInput['id']; |
|
63 | + } |
|
64 | + } |
|
65 | + } catch (Exception $exception) { |
|
66 | + EntityMutator::handleExceptions( |
|
67 | + $exception, |
|
68 | + esc_html__( |
|
69 | + 'Could not perform the update because of the following error(s)', |
|
70 | + 'event_espresso' |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | 74 | |
75 | - return compact('updated', 'failed'); |
|
76 | - } |
|
75 | + return compact('updated', 'failed'); |
|
76 | + } |
|
77 | 77 | } |
@@ -4,97 +4,97 @@ |
||
4 | 4 | |
5 | 5 | class PhpToUnicode |
6 | 6 | { |
7 | - /** |
|
8 | - * array where keys are PHP date format parameters |
|
9 | - * and values are Unicode Date Format substitutions |
|
10 | - */ |
|
11 | - public static $date_formats = [ |
|
12 | - // YEAR |
|
13 | - 'y' => 'yy', // 00, 01, ..., 99 |
|
14 | - 'Y' => 'yyyy', // 2000, 2001, ..., 2099 |
|
15 | - 'o' => 'GGGG', // ISO "week-numbering year" 2000, 2001, ..., 2099 |
|
16 | - // MONTH |
|
17 | - 'M' => 'MMM', // Jan, Feb, ..., Dec |
|
18 | - 'n' => 'M', // 1, 2, ..., 12 |
|
19 | - 'm' => 'MM', // 01, 02, ..., 12 |
|
20 | - 'F' => 'MMMM', // January, February, ..., December |
|
21 | - // DAY |
|
22 | - 'd' => 'dd', // 01, 02, ..., 31 |
|
23 | - 'D' => 'eee', // Sun, Mon, ..., Sat |
|
24 | - 'jS' => 'do', // 1st, 2nd, ..., 31st |
|
25 | - 'j' => 'd', // 1, 2, ..., 31 |
|
26 | - 'l' => 'eeee', // Sunday, Monday, ..., Saturday |
|
27 | - 'N' => 'e', // Day of week 0, 1, ..., 6 |
|
28 | - 'w' => 'i', // ISO Day of week 1, 2, ..., 7 |
|
29 | - 'z' => 'D', // day of the year 0 - 365 to 1 - 366 |
|
30 | - // WEEK |
|
31 | - 'W' => 'w', |
|
32 | - ]; |
|
7 | + /** |
|
8 | + * array where keys are PHP date format parameters |
|
9 | + * and values are Unicode Date Format substitutions |
|
10 | + */ |
|
11 | + public static $date_formats = [ |
|
12 | + // YEAR |
|
13 | + 'y' => 'yy', // 00, 01, ..., 99 |
|
14 | + 'Y' => 'yyyy', // 2000, 2001, ..., 2099 |
|
15 | + 'o' => 'GGGG', // ISO "week-numbering year" 2000, 2001, ..., 2099 |
|
16 | + // MONTH |
|
17 | + 'M' => 'MMM', // Jan, Feb, ..., Dec |
|
18 | + 'n' => 'M', // 1, 2, ..., 12 |
|
19 | + 'm' => 'MM', // 01, 02, ..., 12 |
|
20 | + 'F' => 'MMMM', // January, February, ..., December |
|
21 | + // DAY |
|
22 | + 'd' => 'dd', // 01, 02, ..., 31 |
|
23 | + 'D' => 'eee', // Sun, Mon, ..., Sat |
|
24 | + 'jS' => 'do', // 1st, 2nd, ..., 31st |
|
25 | + 'j' => 'd', // 1, 2, ..., 31 |
|
26 | + 'l' => 'eeee', // Sunday, Monday, ..., Saturday |
|
27 | + 'N' => 'e', // Day of week 0, 1, ..., 6 |
|
28 | + 'w' => 'i', // ISO Day of week 1, 2, ..., 7 |
|
29 | + 'z' => 'D', // day of the year 0 - 365 to 1 - 366 |
|
30 | + // WEEK |
|
31 | + 'W' => 'w', |
|
32 | + ]; |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * array where keys are PHP time format parameters |
|
37 | - * and values are Unicode Time Format substitutions |
|
38 | - */ |
|
39 | - public static $time_formats = [ |
|
40 | - // 'a' => 'a', // am, pm, no pecific JS alternative |
|
41 | - 'A' => 'a', // AM, PM |
|
42 | - // HOUR |
|
43 | - // convert "g" to an intermediary format |
|
44 | - // to avoid its result getting replaced by "h" |
|
45 | - 'g' => '@', // 1, 2, ..., 12 |
|
46 | - 'h' => 'hh', // 01, 02, ..., 12 |
|
47 | - '@' => 'h', // 1, 2, ..., 12 |
|
48 | - 'G' => '#', // 0, 1, ... 23 |
|
49 | - 'H' => 'HH', // 00, 01, ... 23 |
|
50 | - '#' => 'H', // 0, 1, ... 23 |
|
51 | - // MINUTES & SECONDS |
|
52 | - 'i' => 'mm', // minutes 00, 01, ..., 59 |
|
53 | - 's' => 'ss', // seconds 00, 01, ..., 59 |
|
54 | - 'v' => 'SSS', // milliseconds 000, 001, ..., 999 |
|
55 | - 'u' => 'SSS', // microseconds (not in unicode) 000, 001, ..., 999 |
|
56 | - ]; |
|
35 | + /** |
|
36 | + * array where keys are PHP time format parameters |
|
37 | + * and values are Unicode Time Format substitutions |
|
38 | + */ |
|
39 | + public static $time_formats = [ |
|
40 | + // 'a' => 'a', // am, pm, no pecific JS alternative |
|
41 | + 'A' => 'a', // AM, PM |
|
42 | + // HOUR |
|
43 | + // convert "g" to an intermediary format |
|
44 | + // to avoid its result getting replaced by "h" |
|
45 | + 'g' => '@', // 1, 2, ..., 12 |
|
46 | + 'h' => 'hh', // 01, 02, ..., 12 |
|
47 | + '@' => 'h', // 1, 2, ..., 12 |
|
48 | + 'G' => '#', // 0, 1, ... 23 |
|
49 | + 'H' => 'HH', // 00, 01, ... 23 |
|
50 | + '#' => 'H', // 0, 1, ... 23 |
|
51 | + // MINUTES & SECONDS |
|
52 | + 'i' => 'mm', // minutes 00, 01, ..., 59 |
|
53 | + 's' => 'ss', // seconds 00, 01, ..., 59 |
|
54 | + 'v' => 'SSS', // milliseconds 000, 001, ..., 999 |
|
55 | + 'u' => 'SSS', // microseconds (not in unicode) 000, 001, ..., 999 |
|
56 | + ]; |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * array where keys are PHP timezone format parameters |
|
61 | - * and values are Unicode Timezone Format substitutions |
|
62 | - */ |
|
63 | - public static $timezone_formats = [ |
|
64 | - 'Z' => 'ZZ', // -0100, +0000, ..., +1200 |
|
65 | - 'e' => 'Z', // Timezone identifier UTC, GMT, Atlantic/Azores to -01:00, +00:00, ... +12:00 |
|
66 | - 'T' => 'Z', // Timezone abbreviation EST, MDT to -01:00, +00:00, ... +12:00 |
|
67 | - 'P' => 'Z', // -01:00, +00:00, ... +12:00 |
|
68 | - 'O' => 'ZZ', // -0100, +0000, ..., +1200 |
|
69 | - ]; |
|
59 | + /** |
|
60 | + * array where keys are PHP timezone format parameters |
|
61 | + * and values are Unicode Timezone Format substitutions |
|
62 | + */ |
|
63 | + public static $timezone_formats = [ |
|
64 | + 'Z' => 'ZZ', // -0100, +0000, ..., +1200 |
|
65 | + 'e' => 'Z', // Timezone identifier UTC, GMT, Atlantic/Azores to -01:00, +00:00, ... +12:00 |
|
66 | + 'T' => 'Z', // Timezone abbreviation EST, MDT to -01:00, +00:00, ... +12:00 |
|
67 | + 'P' => 'Z', // -01:00, +00:00, ... +12:00 |
|
68 | + 'O' => 'ZZ', // -0100, +0000, ..., +1200 |
|
69 | + ]; |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * @param string $date_format |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public function convertDateFormat($date_format) |
|
77 | - { |
|
78 | - foreach (PhpToUnicode::$date_formats as $find => $replace) { |
|
79 | - $date_format = (string) str_replace($find, $replace, $date_format); |
|
80 | - } |
|
81 | - return $date_format; |
|
82 | - } |
|
72 | + /** |
|
73 | + * @param string $date_format |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public function convertDateFormat($date_format) |
|
77 | + { |
|
78 | + foreach (PhpToUnicode::$date_formats as $find => $replace) { |
|
79 | + $date_format = (string) str_replace($find, $replace, $date_format); |
|
80 | + } |
|
81 | + return $date_format; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @param string $time_format |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function convertTimeFormat($time_format) |
|
90 | - { |
|
91 | - foreach (PhpToUnicode::$time_formats as $find => $replace) { |
|
92 | - $time_format = (string) str_replace($find, $replace, $time_format); |
|
93 | - } |
|
94 | - // and just in case the timezone has been added |
|
95 | - foreach (PhpToUnicode::$timezone_formats as $find => $replace) { |
|
96 | - $time_format = (string) str_replace($find, $replace, $time_format); |
|
97 | - } |
|
98 | - return $time_format; |
|
99 | - } |
|
85 | + /** |
|
86 | + * @param string $time_format |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function convertTimeFormat($time_format) |
|
90 | + { |
|
91 | + foreach (PhpToUnicode::$time_formats as $find => $replace) { |
|
92 | + $time_format = (string) str_replace($find, $replace, $time_format); |
|
93 | + } |
|
94 | + // and just in case the timezone has been added |
|
95 | + foreach (PhpToUnicode::$timezone_formats as $find => $replace) { |
|
96 | + $time_format = (string) str_replace($find, $replace, $time_format); |
|
97 | + } |
|
98 | + return $time_format; |
|
99 | + } |
|
100 | 100 | } |
@@ -10,23 +10,23 @@ discard block |
||
10 | 10 | */ |
11 | 11 | public static $date_formats = [ |
12 | 12 | // YEAR |
13 | - 'y' => 'yy', // 00, 01, ..., 99 |
|
14 | - 'Y' => 'yyyy', // 2000, 2001, ..., 2099 |
|
15 | - 'o' => 'GGGG', // ISO "week-numbering year" 2000, 2001, ..., 2099 |
|
13 | + 'y' => 'yy', // 00, 01, ..., 99 |
|
14 | + 'Y' => 'yyyy', // 2000, 2001, ..., 2099 |
|
15 | + 'o' => 'GGGG', // ISO "week-numbering year" 2000, 2001, ..., 2099 |
|
16 | 16 | // MONTH |
17 | - 'M' => 'MMM', // Jan, Feb, ..., Dec |
|
18 | - 'n' => 'M', // 1, 2, ..., 12 |
|
19 | - 'm' => 'MM', // 01, 02, ..., 12 |
|
20 | - 'F' => 'MMMM', // January, February, ..., December |
|
17 | + 'M' => 'MMM', // Jan, Feb, ..., Dec |
|
18 | + 'n' => 'M', // 1, 2, ..., 12 |
|
19 | + 'm' => 'MM', // 01, 02, ..., 12 |
|
20 | + 'F' => 'MMMM', // January, February, ..., December |
|
21 | 21 | // DAY |
22 | - 'd' => 'dd', // 01, 02, ..., 31 |
|
23 | - 'D' => 'eee', // Sun, Mon, ..., Sat |
|
24 | - 'jS' => 'do', // 1st, 2nd, ..., 31st |
|
25 | - 'j' => 'd', // 1, 2, ..., 31 |
|
26 | - 'l' => 'eeee', // Sunday, Monday, ..., Saturday |
|
27 | - 'N' => 'e', // Day of week 0, 1, ..., 6 |
|
28 | - 'w' => 'i', // ISO Day of week 1, 2, ..., 7 |
|
29 | - 'z' => 'D', // day of the year 0 - 365 to 1 - 366 |
|
22 | + 'd' => 'dd', // 01, 02, ..., 31 |
|
23 | + 'D' => 'eee', // Sun, Mon, ..., Sat |
|
24 | + 'jS' => 'do', // 1st, 2nd, ..., 31st |
|
25 | + 'j' => 'd', // 1, 2, ..., 31 |
|
26 | + 'l' => 'eeee', // Sunday, Monday, ..., Saturday |
|
27 | + 'N' => 'e', // Day of week 0, 1, ..., 6 |
|
28 | + 'w' => 'i', // ISO Day of week 1, 2, ..., 7 |
|
29 | + 'z' => 'D', // day of the year 0 - 365 to 1 - 366 |
|
30 | 30 | // WEEK |
31 | 31 | 'W' => 'w', |
32 | 32 | ]; |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | // HOUR |
43 | 43 | // convert "g" to an intermediary format |
44 | 44 | // to avoid its result getting replaced by "h" |
45 | - 'g' => '@', // 1, 2, ..., 12 |
|
46 | - 'h' => 'hh', // 01, 02, ..., 12 |
|
47 | - '@' => 'h', // 1, 2, ..., 12 |
|
48 | - 'G' => '#', // 0, 1, ... 23 |
|
49 | - 'H' => 'HH', // 00, 01, ... 23 |
|
50 | - '#' => 'H', // 0, 1, ... 23 |
|
45 | + 'g' => '@', // 1, 2, ..., 12 |
|
46 | + 'h' => 'hh', // 01, 02, ..., 12 |
|
47 | + '@' => 'h', // 1, 2, ..., 12 |
|
48 | + 'G' => '#', // 0, 1, ... 23 |
|
49 | + 'H' => 'HH', // 00, 01, ... 23 |
|
50 | + '#' => 'H', // 0, 1, ... 23 |
|
51 | 51 | // MINUTES & SECONDS |
52 | - 'i' => 'mm', // minutes 00, 01, ..., 59 |
|
53 | - 's' => 'ss', // seconds 00, 01, ..., 59 |
|
54 | - 'v' => 'SSS', // milliseconds 000, 001, ..., 999 |
|
55 | - 'u' => 'SSS', // microseconds (not in unicode) 000, 001, ..., 999 |
|
52 | + 'i' => 'mm', // minutes 00, 01, ..., 59 |
|
53 | + 's' => 'ss', // seconds 00, 01, ..., 59 |
|
54 | + 'v' => 'SSS', // milliseconds 000, 001, ..., 999 |
|
55 | + 'u' => 'SSS', // microseconds (not in unicode) 000, 001, ..., 999 |
|
56 | 56 | ]; |
57 | 57 | |
58 | 58 | |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | * and values are Unicode Timezone Format substitutions |
62 | 62 | */ |
63 | 63 | public static $timezone_formats = [ |
64 | - 'Z' => 'ZZ', // -0100, +0000, ..., +1200 |
|
65 | - 'e' => 'Z', // Timezone identifier UTC, GMT, Atlantic/Azores to -01:00, +00:00, ... +12:00 |
|
66 | - 'T' => 'Z', // Timezone abbreviation EST, MDT to -01:00, +00:00, ... +12:00 |
|
67 | - 'P' => 'Z', // -01:00, +00:00, ... +12:00 |
|
68 | - 'O' => 'ZZ', // -0100, +0000, ..., +1200 |
|
64 | + 'Z' => 'ZZ', // -0100, +0000, ..., +1200 |
|
65 | + 'e' => 'Z', // Timezone identifier UTC, GMT, Atlantic/Azores to -01:00, +00:00, ... +12:00 |
|
66 | + 'T' => 'Z', // Timezone abbreviation EST, MDT to -01:00, +00:00, ... +12:00 |
|
67 | + 'P' => 'Z', // -01:00, +00:00, ... +12:00 |
|
68 | + 'O' => 'ZZ', // -0100, +0000, ..., +1200 |
|
69 | 69 | ]; |
70 | 70 | |
71 | 71 |
@@ -16,32 +16,32 @@ |
||
16 | 16 | class ManifestFile extends Asset |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Asset constructor. |
|
21 | - * |
|
22 | - * @param DomainInterface $domain |
|
23 | - * @throws InvalidDataTypeException |
|
24 | - */ |
|
25 | - public function __construct(DomainInterface $domain) |
|
26 | - { |
|
27 | - parent::__construct(Asset::TYPE_MANIFEST, $domain->assetNamespace(), $domain); |
|
28 | - } |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @return string |
|
33 | - */ |
|
34 | - public function urlBase() |
|
35 | - { |
|
36 | - return $this->domain->distributionAssetsUrl(); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function filepath() |
|
44 | - { |
|
45 | - return $this->domain->distributionAssetsPath(); |
|
46 | - } |
|
19 | + /** |
|
20 | + * Asset constructor. |
|
21 | + * |
|
22 | + * @param DomainInterface $domain |
|
23 | + * @throws InvalidDataTypeException |
|
24 | + */ |
|
25 | + public function __construct(DomainInterface $domain) |
|
26 | + { |
|
27 | + parent::__construct(Asset::TYPE_MANIFEST, $domain->assetNamespace(), $domain); |
|
28 | + } |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @return string |
|
33 | + */ |
|
34 | + public function urlBase() |
|
35 | + { |
|
36 | + return $this->domain->distributionAssetsUrl(); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function filepath() |
|
44 | + { |
|
45 | + return $this->domain->distributionAssetsPath(); |
|
46 | + } |
|
47 | 47 | } |
@@ -7,19 +7,19 @@ |
||
7 | 7 | abstract class Factory implements FactoryInterface |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * @var LoaderInterface $loader |
|
12 | - */ |
|
13 | - protected $loader; |
|
10 | + /** |
|
11 | + * @var LoaderInterface $loader |
|
12 | + */ |
|
13 | + protected $loader; |
|
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * RouteFactory constructor. |
|
18 | - * |
|
19 | - * @param LoaderInterface $loader |
|
20 | - */ |
|
21 | - public function __construct(LoaderInterface $loader) |
|
22 | - { |
|
23 | - $this->loader = $loader; |
|
24 | - } |
|
16 | + /** |
|
17 | + * RouteFactory constructor. |
|
18 | + * |
|
19 | + * @param LoaderInterface $loader |
|
20 | + */ |
|
21 | + public function __construct(LoaderInterface $loader) |
|
22 | + { |
|
23 | + $this->loader = $loader; |
|
24 | + } |
|
25 | 25 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | $fqcn = str_replace('\\', '_', $fqcn); |
72 | 72 | return $fqcn === $object_identifier |
73 | - || strpos($object_identifier, $fqcn . ObjectIdentifier::DELIMITER) === 0; |
|
73 | + || strpos($object_identifier, $fqcn.ObjectIdentifier::DELIMITER) === 0; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | ) |
91 | 91 | ? $this->getIdentifierForArguments($arguments) |
92 | 92 | : ''; |
93 | - if (! empty($identifier)) { |
|
94 | - $fqcn .= ObjectIdentifier::DELIMITER . md5($identifier); |
|
93 | + if ( ! empty($identifier)) { |
|
94 | + $fqcn .= ObjectIdentifier::DELIMITER.md5($identifier); |
|
95 | 95 | } |
96 | 96 | $fqcn = str_replace('\\', '_', $fqcn); |
97 | 97 | return $fqcn; |
@@ -15,119 +15,119 @@ |
||
15 | 15 | */ |
16 | 16 | class ObjectIdentifier |
17 | 17 | { |
18 | - /** |
|
19 | - * used to separate the FQCN from the class's arguments identifier |
|
20 | - */ |
|
21 | - const DELIMITER = '____'; |
|
18 | + /** |
|
19 | + * used to separate the FQCN from the class's arguments identifier |
|
20 | + */ |
|
21 | + const DELIMITER = '____'; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var ClassInterfaceCache $class_cache |
|
25 | - */ |
|
26 | - private $class_cache; |
|
23 | + /** |
|
24 | + * @var ClassInterfaceCache $class_cache |
|
25 | + */ |
|
26 | + private $class_cache; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * ObjectIdentifier constructor. |
|
31 | - * |
|
32 | - * @param ClassInterfaceCache $class_cache |
|
33 | - */ |
|
34 | - public function __construct(ClassInterfaceCache $class_cache) |
|
35 | - { |
|
36 | - $this->class_cache = $class_cache; |
|
37 | - } |
|
29 | + /** |
|
30 | + * ObjectIdentifier constructor. |
|
31 | + * |
|
32 | + * @param ClassInterfaceCache $class_cache |
|
33 | + */ |
|
34 | + public function __construct(ClassInterfaceCache $class_cache) |
|
35 | + { |
|
36 | + $this->class_cache = $class_cache; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * Returns true if the supplied $object_identifier contains |
|
42 | - * the delimiter used to separate an fqcn from the arguments hash |
|
43 | - * |
|
44 | - * @param string $object_identifier |
|
45 | - * @return bool |
|
46 | - */ |
|
47 | - public function hasArguments($object_identifier) |
|
48 | - { |
|
49 | - // type casting to bool instead of using strpos() !== false |
|
50 | - // because an object identifier should never begin with the delimiter |
|
51 | - // therefore the delimiter should NOT be found at position 0 |
|
52 | - return (bool) strpos($object_identifier, ObjectIdentifier::DELIMITER); |
|
53 | - } |
|
40 | + /** |
|
41 | + * Returns true if the supplied $object_identifier contains |
|
42 | + * the delimiter used to separate an fqcn from the arguments hash |
|
43 | + * |
|
44 | + * @param string $object_identifier |
|
45 | + * @return bool |
|
46 | + */ |
|
47 | + public function hasArguments($object_identifier) |
|
48 | + { |
|
49 | + // type casting to bool instead of using strpos() !== false |
|
50 | + // because an object identifier should never begin with the delimiter |
|
51 | + // therefore the delimiter should NOT be found at position 0 |
|
52 | + return (bool) strpos($object_identifier, ObjectIdentifier::DELIMITER); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Returns true if the supplied FQCN equals the supplied $object_identifier |
|
58 | - * OR the supplied FQCN matches the FQCN portion of the supplied $object_identifier |
|
59 | - * AND that $object_identifier is for an object with arguments. |
|
60 | - * This allows a request for an object using a FQCN to match |
|
61 | - * a previously instantiated object with arguments |
|
62 | - * without having to know those arguments. |
|
63 | - * |
|
64 | - * @param string $fqcn |
|
65 | - * @param string $object_identifier |
|
66 | - * @return bool |
|
67 | - */ |
|
68 | - public function fqcnMatchesObjectIdentifier($fqcn, $object_identifier) |
|
69 | - { |
|
70 | - $fqcn = str_replace('\\', '_', $fqcn); |
|
71 | - return $fqcn === $object_identifier |
|
72 | - || strpos($object_identifier, $fqcn . ObjectIdentifier::DELIMITER) === 0; |
|
73 | - } |
|
56 | + /** |
|
57 | + * Returns true if the supplied FQCN equals the supplied $object_identifier |
|
58 | + * OR the supplied FQCN matches the FQCN portion of the supplied $object_identifier |
|
59 | + * AND that $object_identifier is for an object with arguments. |
|
60 | + * This allows a request for an object using a FQCN to match |
|
61 | + * a previously instantiated object with arguments |
|
62 | + * without having to know those arguments. |
|
63 | + * |
|
64 | + * @param string $fqcn |
|
65 | + * @param string $object_identifier |
|
66 | + * @return bool |
|
67 | + */ |
|
68 | + public function fqcnMatchesObjectIdentifier($fqcn, $object_identifier) |
|
69 | + { |
|
70 | + $fqcn = str_replace('\\', '_', $fqcn); |
|
71 | + return $fqcn === $object_identifier |
|
72 | + || strpos($object_identifier, $fqcn . ObjectIdentifier::DELIMITER) === 0; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * build a string representation of an object's FQCN and arguments |
|
78 | - * |
|
79 | - * @param string $fqcn |
|
80 | - * @param array $arguments |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - public function getIdentifier($fqcn, $arguments = array()) |
|
84 | - { |
|
85 | - // only build identifier from arguments if class is not ReservedInstanceInterface |
|
86 | - $identifier = ! $this->class_cache->hasInterface( |
|
87 | - $fqcn, |
|
88 | - 'EventEspresso\core\interfaces\ReservedInstanceInterface' |
|
89 | - ) |
|
90 | - ? $this->getIdentifierForArguments($arguments) |
|
91 | - : ''; |
|
92 | - if (! empty($identifier)) { |
|
93 | - $fqcn .= ObjectIdentifier::DELIMITER . md5($identifier); |
|
94 | - } |
|
95 | - $fqcn = str_replace('\\', '_', $fqcn); |
|
96 | - return $fqcn; |
|
97 | - } |
|
76 | + /** |
|
77 | + * build a string representation of an object's FQCN and arguments |
|
78 | + * |
|
79 | + * @param string $fqcn |
|
80 | + * @param array $arguments |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + public function getIdentifier($fqcn, $arguments = array()) |
|
84 | + { |
|
85 | + // only build identifier from arguments if class is not ReservedInstanceInterface |
|
86 | + $identifier = ! $this->class_cache->hasInterface( |
|
87 | + $fqcn, |
|
88 | + 'EventEspresso\core\interfaces\ReservedInstanceInterface' |
|
89 | + ) |
|
90 | + ? $this->getIdentifierForArguments($arguments) |
|
91 | + : ''; |
|
92 | + if (! empty($identifier)) { |
|
93 | + $fqcn .= ObjectIdentifier::DELIMITER . md5($identifier); |
|
94 | + } |
|
95 | + $fqcn = str_replace('\\', '_', $fqcn); |
|
96 | + return $fqcn; |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | - /** |
|
101 | - * build a string representation of a object's arguments |
|
102 | - * (mostly because Closures can't be serialized) |
|
103 | - * |
|
104 | - * @param array $arguments |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - protected function getIdentifierForArguments($arguments) |
|
108 | - { |
|
109 | - if (empty($arguments)) { |
|
110 | - return ''; |
|
111 | - } |
|
112 | - $identifier = ''; |
|
113 | - foreach ($arguments as $key => $argument) { |
|
114 | - // don't include arguments used to assist with loading legacy classes |
|
115 | - if (is_string($key) && strpos($key, 'EE_Registry::create') === 0) { |
|
116 | - continue; |
|
117 | - } |
|
118 | - switch (true) { |
|
119 | - case is_object($argument): |
|
120 | - case $argument instanceof Closure: |
|
121 | - $identifier .= spl_object_hash($argument); |
|
122 | - break; |
|
123 | - case is_array($argument): |
|
124 | - $identifier .= $this->getIdentifierForArguments($argument); |
|
125 | - break; |
|
126 | - default: |
|
127 | - $identifier .= $argument; |
|
128 | - break; |
|
129 | - } |
|
130 | - } |
|
131 | - return $identifier; |
|
132 | - } |
|
100 | + /** |
|
101 | + * build a string representation of a object's arguments |
|
102 | + * (mostly because Closures can't be serialized) |
|
103 | + * |
|
104 | + * @param array $arguments |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + protected function getIdentifierForArguments($arguments) |
|
108 | + { |
|
109 | + if (empty($arguments)) { |
|
110 | + return ''; |
|
111 | + } |
|
112 | + $identifier = ''; |
|
113 | + foreach ($arguments as $key => $argument) { |
|
114 | + // don't include arguments used to assist with loading legacy classes |
|
115 | + if (is_string($key) && strpos($key, 'EE_Registry::create') === 0) { |
|
116 | + continue; |
|
117 | + } |
|
118 | + switch (true) { |
|
119 | + case is_object($argument): |
|
120 | + case $argument instanceof Closure: |
|
121 | + $identifier .= spl_object_hash($argument); |
|
122 | + break; |
|
123 | + case is_array($argument): |
|
124 | + $identifier .= $this->getIdentifierForArguments($argument); |
|
125 | + break; |
|
126 | + default: |
|
127 | + $identifier .= $argument; |
|
128 | + break; |
|
129 | + } |
|
130 | + } |
|
131 | + return $identifier; |
|
132 | + } |
|
133 | 133 | } |
@@ -13,94 +13,94 @@ |
||
13 | 13 | class Barista implements BaristaInterface |
14 | 14 | { |
15 | 15 | |
16 | - const DEPENDENCY_LIST_REGISTERED = 'registered'; |
|
16 | + const DEPENDENCY_LIST_REGISTERED = 'registered'; |
|
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @var AssetManifestInterface |
|
21 | - */ |
|
22 | - private $asset_manifest; |
|
19 | + /** |
|
20 | + * @var AssetManifestInterface |
|
21 | + */ |
|
22 | + private $asset_manifest; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var bool |
|
26 | - */ |
|
27 | - protected $initialized = false; |
|
24 | + /** |
|
25 | + * @var bool |
|
26 | + */ |
|
27 | + protected $initialized = false; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * Barista constructor. |
|
32 | - * |
|
33 | - * @param AssetManifestInterface $asset_manifest |
|
34 | - */ |
|
35 | - public function __construct(AssetManifestInterface $asset_manifest) |
|
36 | - { |
|
37 | - $this->asset_manifest = $asset_manifest; |
|
38 | - } |
|
30 | + /** |
|
31 | + * Barista constructor. |
|
32 | + * |
|
33 | + * @param AssetManifestInterface $asset_manifest |
|
34 | + */ |
|
35 | + public function __construct(AssetManifestInterface $asset_manifest) |
|
36 | + { |
|
37 | + $this->asset_manifest = $asset_manifest; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public function initialize() |
|
45 | - { |
|
46 | - if (! $this->initialized) { |
|
47 | - $this->asset_manifest->initialize(); |
|
48 | - add_action('wp_enqueue_scripts', [$this, 'registerScripts'], 0); |
|
49 | - add_action('admin_enqueue_scripts', [$this, 'registerScripts'], 0); |
|
50 | - add_action('wp_enqueue_scripts', [$this, 'registerStyles'], 0); |
|
51 | - add_action('admin_enqueue_scripts', [$this, 'registerStyles'], 0); |
|
52 | - $this->initialized = true; |
|
53 | - } |
|
54 | - } |
|
41 | + /** |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public function initialize() |
|
45 | + { |
|
46 | + if (! $this->initialized) { |
|
47 | + $this->asset_manifest->initialize(); |
|
48 | + add_action('wp_enqueue_scripts', [$this, 'registerScripts'], 0); |
|
49 | + add_action('admin_enqueue_scripts', [$this, 'registerScripts'], 0); |
|
50 | + add_action('wp_enqueue_scripts', [$this, 'registerStyles'], 0); |
|
51 | + add_action('admin_enqueue_scripts', [$this, 'registerStyles'], 0); |
|
52 | + $this->initialized = true; |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Registers all the WordPress packages scripts that are in the standardized |
|
59 | - * `build/` location. |
|
60 | - * |
|
61 | - * @return void |
|
62 | - * @throws Exception |
|
63 | - */ |
|
64 | - public function registerScripts() |
|
65 | - { |
|
66 | - try { |
|
67 | - $entry_points = $this->asset_manifest->getEntryPoints(); |
|
68 | - foreach ($entry_points as $entry_point) { |
|
69 | - if ($this->asset_manifest->hasAsset($entry_point)) { |
|
70 | - $handle = $this->asset_manifest->getAssetHandle($entry_point); |
|
71 | - $source = $this->asset_manifest->getAssetUrl($entry_point); |
|
72 | - $dependencies = $this->asset_manifest->getAssetDependencies($entry_point); |
|
73 | - $version = $this->asset_manifest->getAssetVersion($entry_point); |
|
74 | - wp_register_script($handle, $source, $dependencies, $version, true); |
|
75 | - } |
|
76 | - } |
|
77 | - } catch (Exception $exception) { |
|
78 | - wp_die(new ExceptionStackTraceDisplay($exception)); |
|
79 | - } |
|
80 | - } |
|
57 | + /** |
|
58 | + * Registers all the WordPress packages scripts that are in the standardized |
|
59 | + * `build/` location. |
|
60 | + * |
|
61 | + * @return void |
|
62 | + * @throws Exception |
|
63 | + */ |
|
64 | + public function registerScripts() |
|
65 | + { |
|
66 | + try { |
|
67 | + $entry_points = $this->asset_manifest->getEntryPoints(); |
|
68 | + foreach ($entry_points as $entry_point) { |
|
69 | + if ($this->asset_manifest->hasAsset($entry_point)) { |
|
70 | + $handle = $this->asset_manifest->getAssetHandle($entry_point); |
|
71 | + $source = $this->asset_manifest->getAssetUrl($entry_point); |
|
72 | + $dependencies = $this->asset_manifest->getAssetDependencies($entry_point); |
|
73 | + $version = $this->asset_manifest->getAssetVersion($entry_point); |
|
74 | + wp_register_script($handle, $source, $dependencies, $version, true); |
|
75 | + } |
|
76 | + } |
|
77 | + } catch (Exception $exception) { |
|
78 | + wp_die(new ExceptionStackTraceDisplay($exception)); |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Registers all the packages and domain styles that are in the build folder. |
|
85 | - * |
|
86 | - * @return void |
|
87 | - * @throws Exception |
|
88 | - */ |
|
89 | - public function registerStyles() |
|
90 | - { |
|
91 | - try { |
|
92 | - $entry_points = $this->asset_manifest->getEntryPoints(); |
|
93 | - foreach ($entry_points as $entry_point) { |
|
94 | - if ($this->asset_manifest->hasAsset($entry_point, AssetManifest::ASSET_EXT_CSS)) { |
|
95 | - $handle = $this->asset_manifest->getAssetHandle($entry_point); |
|
96 | - $source = $this->asset_manifest->getAssetUrl($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
97 | - $dependencies = $this->asset_manifest->getAssetDependencies($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
98 | - $version = $this->asset_manifest->getAssetVersion($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
99 | - wp_register_style($handle, $source, $dependencies, $version, 'all'); |
|
100 | - } |
|
101 | - } |
|
102 | - } catch (Exception $exception) { |
|
103 | - wp_die(new ExceptionStackTraceDisplay($exception)); |
|
104 | - } |
|
105 | - } |
|
83 | + /** |
|
84 | + * Registers all the packages and domain styles that are in the build folder. |
|
85 | + * |
|
86 | + * @return void |
|
87 | + * @throws Exception |
|
88 | + */ |
|
89 | + public function registerStyles() |
|
90 | + { |
|
91 | + try { |
|
92 | + $entry_points = $this->asset_manifest->getEntryPoints(); |
|
93 | + foreach ($entry_points as $entry_point) { |
|
94 | + if ($this->asset_manifest->hasAsset($entry_point, AssetManifest::ASSET_EXT_CSS)) { |
|
95 | + $handle = $this->asset_manifest->getAssetHandle($entry_point); |
|
96 | + $source = $this->asset_manifest->getAssetUrl($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
97 | + $dependencies = $this->asset_manifest->getAssetDependencies($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
98 | + $version = $this->asset_manifest->getAssetVersion($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
99 | + wp_register_style($handle, $source, $dependencies, $version, 'all'); |
|
100 | + } |
|
101 | + } |
|
102 | + } catch (Exception $exception) { |
|
103 | + wp_die(new ExceptionStackTraceDisplay($exception)); |
|
104 | + } |
|
105 | + } |
|
106 | 106 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | */ |
44 | 44 | public function initialize() |
45 | 45 | { |
46 | - if (! $this->initialized) { |
|
46 | + if ( ! $this->initialized) { |
|
47 | 47 | $this->asset_manifest->initialize(); |
48 | 48 | add_action('wp_enqueue_scripts', [$this, 'registerScripts'], 0); |
49 | 49 | add_action('admin_enqueue_scripts', [$this, 'registerScripts'], 0); |