@@ -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(array $input): array |
|
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(array $input): array |
|
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 | ); |
@@ -10,69 +10,69 @@ |
||
10 | 10 | class BulkEntityMutator extends EntityMutator |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @var callable $entity_mutator . |
|
15 | - */ |
|
16 | - protected $entity_mutator; |
|
13 | + /** |
|
14 | + * @var callable $entity_mutator . |
|
15 | + */ |
|
16 | + protected $entity_mutator; |
|
17 | 17 | |
18 | - /** |
|
19 | - * BulkEntityMutator constructor. |
|
20 | - * |
|
21 | - * @param callable $entity_mutator The mutator for an entity. |
|
22 | - */ |
|
23 | - public function __construct(callable $entity_mutator) |
|
24 | - { |
|
25 | - $this->entity_mutator = $entity_mutator; |
|
26 | - } |
|
27 | - /** |
|
28 | - * Bulk updates entities. |
|
29 | - * |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - public function updateEntities(array $input, AppContext $context, ResolveInfo $info): array |
|
36 | - { |
|
18 | + /** |
|
19 | + * BulkEntityMutator constructor. |
|
20 | + * |
|
21 | + * @param callable $entity_mutator The mutator for an entity. |
|
22 | + */ |
|
23 | + public function __construct(callable $entity_mutator) |
|
24 | + { |
|
25 | + $this->entity_mutator = $entity_mutator; |
|
26 | + } |
|
27 | + /** |
|
28 | + * Bulk updates entities. |
|
29 | + * |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + public function updateEntities(array $input, AppContext $context, ResolveInfo $info): array |
|
36 | + { |
|
37 | 37 | |
38 | - $updated = []; |
|
39 | - $failed = []; |
|
40 | - // TODO Add meaningful error messages for every failure. |
|
41 | - // $errors = []; |
|
38 | + $updated = []; |
|
39 | + $failed = []; |
|
40 | + // TODO Add meaningful error messages for every failure. |
|
41 | + // $errors = []; |
|
42 | 42 | |
43 | - try { |
|
44 | - if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
45 | - throw new OutOfBoundsException( |
|
46 | - esc_html__('A valid input was not provided.', 'event_espresso') |
|
47 | - ); |
|
48 | - } |
|
43 | + try { |
|
44 | + if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
45 | + throw new OutOfBoundsException( |
|
46 | + esc_html__('A valid input was not provided.', 'event_espresso') |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | |
50 | - $sharedInput = ! empty($input['sharedInput']) ? $input['sharedInput'] : []; |
|
50 | + $sharedInput = ! empty($input['sharedInput']) ? $input['sharedInput'] : []; |
|
51 | 51 | |
52 | - foreach ($input['uniqueInputs'] as $uniqueInput) { |
|
53 | - try { |
|
54 | - // values in $uniqueInput will override those in $sharedInput |
|
55 | - $finalInput = array_merge($sharedInput, $uniqueInput); |
|
56 | - // mutate the individual entity. |
|
57 | - $mutator = $this->entity_mutator; |
|
58 | - $mutator($finalInput, $context, $info); |
|
59 | - // we are here it means the update was successful. |
|
60 | - $updated[] = $uniqueInput['id']; |
|
61 | - } catch (Exception $e) { |
|
62 | - // sorry mate, couldn't help you :( |
|
63 | - $failed[] = $uniqueInput['id']; |
|
64 | - } |
|
65 | - } |
|
66 | - } catch (Exception $exception) { |
|
67 | - EntityMutator::handleExceptions( |
|
68 | - $exception, |
|
69 | - esc_html__( |
|
70 | - 'Could not perform the update because of the following error(s)', |
|
71 | - 'event_espresso' |
|
72 | - ) |
|
73 | - ); |
|
74 | - } |
|
52 | + foreach ($input['uniqueInputs'] as $uniqueInput) { |
|
53 | + try { |
|
54 | + // values in $uniqueInput will override those in $sharedInput |
|
55 | + $finalInput = array_merge($sharedInput, $uniqueInput); |
|
56 | + // mutate the individual entity. |
|
57 | + $mutator = $this->entity_mutator; |
|
58 | + $mutator($finalInput, $context, $info); |
|
59 | + // we are here it means the update was successful. |
|
60 | + $updated[] = $uniqueInput['id']; |
|
61 | + } catch (Exception $e) { |
|
62 | + // sorry mate, couldn't help you :( |
|
63 | + $failed[] = $uniqueInput['id']; |
|
64 | + } |
|
65 | + } |
|
66 | + } catch (Exception $exception) { |
|
67 | + EntityMutator::handleExceptions( |
|
68 | + $exception, |
|
69 | + esc_html__( |
|
70 | + 'Could not perform the update because of the following error(s)', |
|
71 | + 'event_espresso' |
|
72 | + ) |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | |
76 | - return compact('updated', 'failed'); |
|
77 | - } |
|
76 | + return compact('updated', 'failed'); |
|
77 | + } |
|
78 | 78 | } |
@@ -8,17 +8,17 @@ |
||
8 | 8 | class TicketBulkUpdate extends EntityMutator |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * Defines the mutation data modification closure. |
|
13 | - * |
|
14 | - * @param EEM_Ticket $model |
|
15 | - * @param Ticket $type |
|
16 | - * @return callable |
|
17 | - */ |
|
18 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
19 | - { |
|
20 | - $entityMutator = TicketUpdate::mutateAndGetPayload($model, $type); |
|
21 | - $bulkMutator = new BulkEntityMutator($entityMutator); |
|
22 | - return array($bulkMutator, 'updateEntities'); |
|
23 | - } |
|
11 | + /** |
|
12 | + * Defines the mutation data modification closure. |
|
13 | + * |
|
14 | + * @param EEM_Ticket $model |
|
15 | + * @param Ticket $type |
|
16 | + * @return callable |
|
17 | + */ |
|
18 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
19 | + { |
|
20 | + $entityMutator = TicketUpdate::mutateAndGetPayload($model, $type); |
|
21 | + $bulkMutator = new BulkEntityMutator($entityMutator); |
|
22 | + return array($bulkMutator, 'updateEntities'); |
|
23 | + } |
|
24 | 24 | } |
@@ -18,75 +18,75 @@ |
||
18 | 18 | */ |
19 | 19 | interface AssetManagerInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * @since 4.9.71.p |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public function assetNamespace(); |
|
21 | + /** |
|
22 | + * @since 4.9.71.p |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public function assetNamespace(); |
|
26 | 26 | |
27 | - /** |
|
28 | - * @since 4.9.62.p |
|
29 | - */ |
|
30 | - public function addAssets(); |
|
27 | + /** |
|
28 | + * @since 4.9.62.p |
|
29 | + */ |
|
30 | + public function addAssets(); |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @param string $handle |
|
35 | - * @param string $source |
|
36 | - * @param array $dependencies |
|
37 | - * @param bool $load_in_footer |
|
38 | - * @return JavascriptAsset |
|
39 | - * @throws DuplicateCollectionIdentifierException |
|
40 | - * @throws InvalidDataTypeException |
|
41 | - * @throws InvalidEntityException |
|
42 | - * @since 4.9.62.p |
|
43 | - */ |
|
44 | - public function addJavascript( |
|
45 | - $handle, |
|
46 | - $source, |
|
47 | - array $dependencies = array(), |
|
48 | - $load_in_footer = true |
|
49 | - ); |
|
33 | + /** |
|
34 | + * @param string $handle |
|
35 | + * @param string $source |
|
36 | + * @param array $dependencies |
|
37 | + * @param bool $load_in_footer |
|
38 | + * @return JavascriptAsset |
|
39 | + * @throws DuplicateCollectionIdentifierException |
|
40 | + * @throws InvalidDataTypeException |
|
41 | + * @throws InvalidEntityException |
|
42 | + * @since 4.9.62.p |
|
43 | + */ |
|
44 | + public function addJavascript( |
|
45 | + $handle, |
|
46 | + $source, |
|
47 | + array $dependencies = array(), |
|
48 | + $load_in_footer = true |
|
49 | + ); |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @since 4.9.71.p |
|
54 | - * @param string $handle |
|
55 | - * @param array $dependencies |
|
56 | - * @param bool $load_in_footer |
|
57 | - * @return JavascriptAsset |
|
58 | - */ |
|
59 | - public function addVendorJavascript( |
|
60 | - $handle, |
|
61 | - array $dependencies = array(), |
|
62 | - $load_in_footer = true |
|
63 | - ); |
|
52 | + /** |
|
53 | + * @since 4.9.71.p |
|
54 | + * @param string $handle |
|
55 | + * @param array $dependencies |
|
56 | + * @param bool $load_in_footer |
|
57 | + * @return JavascriptAsset |
|
58 | + */ |
|
59 | + public function addVendorJavascript( |
|
60 | + $handle, |
|
61 | + array $dependencies = array(), |
|
62 | + $load_in_footer = true |
|
63 | + ); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * @param string $handle |
|
69 | - * @param string $source |
|
70 | - * @param array $dependencies |
|
71 | - * @param string $media |
|
72 | - * @return StylesheetAsset |
|
73 | - * @throws DuplicateCollectionIdentifierException |
|
74 | - * @throws InvalidDataTypeException |
|
75 | - * @throws InvalidEntityException |
|
76 | - * @since 4.9.62.p |
|
77 | - */ |
|
78 | - public function addStylesheet( |
|
79 | - $handle, |
|
80 | - $source, |
|
81 | - array $dependencies = array(), |
|
82 | - $media = 'all' |
|
83 | - ); |
|
67 | + /** |
|
68 | + * @param string $handle |
|
69 | + * @param string $source |
|
70 | + * @param array $dependencies |
|
71 | + * @param string $media |
|
72 | + * @return StylesheetAsset |
|
73 | + * @throws DuplicateCollectionIdentifierException |
|
74 | + * @throws InvalidDataTypeException |
|
75 | + * @throws InvalidEntityException |
|
76 | + * @since 4.9.62.p |
|
77 | + */ |
|
78 | + public function addStylesheet( |
|
79 | + $handle, |
|
80 | + $source, |
|
81 | + array $dependencies = array(), |
|
82 | + $media = 'all' |
|
83 | + ); |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * @param string $handle |
|
88 | - * @return bool |
|
89 | - * @since 4.9.62.p |
|
90 | - */ |
|
91 | - public function enqueueAsset($handle); |
|
86 | + /** |
|
87 | + * @param string $handle |
|
88 | + * @return bool |
|
89 | + * @since 4.9.62.p |
|
90 | + */ |
|
91 | + public function enqueueAsset($handle); |
|
92 | 92 | } |
@@ -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, array $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, array $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(array $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(array $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 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function create($fqcn, array $arguments = []) |
55 | 55 | { |
56 | - if (! isset($arguments[0]) || ! $arguments[0] instanceof DomainInterface) { |
|
56 | + if ( ! isset($arguments[0]) || ! $arguments[0] instanceof DomainInterface) { |
|
57 | 57 | throw new InvalidArgumentException( |
58 | 58 | esc_html__( |
59 | 59 | 'In order to generate an AssetManifest class you need to supply an array where the first argument is an instance of DomainInterface.', |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | private function getAssetManifestForDomain($manifest_fqcn, DomainInterface $domain) |
74 | 74 | { |
75 | 75 | $domain_fqcn = get_class($domain); |
76 | - if (! isset(AssetManifestFactory::$manifests[ $domain_fqcn ])) { |
|
76 | + if ( ! isset(AssetManifestFactory::$manifests[$domain_fqcn])) { |
|
77 | 77 | $asset_manifest = new $manifest_fqcn($domain); |
78 | - if (! $asset_manifest instanceof AssetManifestInterface || ! $asset_manifest instanceof $manifest_fqcn) { |
|
78 | + if ( ! $asset_manifest instanceof AssetManifestInterface || ! $asset_manifest instanceof $manifest_fqcn) { |
|
79 | 79 | throw new DomainException( |
80 | 80 | sprintf( |
81 | 81 | esc_html__( |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | } |
89 | 89 | // we still need to share this with the core loader to facilitate automatic dependency injection |
90 | 90 | $this->loader->share(AssetManifest::class, $asset_manifest, [$domain]); |
91 | - AssetManifestFactory::$manifests[ $domain_fqcn ] = $asset_manifest; |
|
91 | + AssetManifestFactory::$manifests[$domain_fqcn] = $asset_manifest; |
|
92 | 92 | } |
93 | - return AssetManifestFactory::$manifests[ $domain_fqcn ]; |
|
93 | + return AssetManifestFactory::$manifests[$domain_fqcn]; |
|
94 | 94 | } |
95 | 95 | } |
@@ -16,86 +16,86 @@ |
||
16 | 16 | */ |
17 | 17 | class AssetManifestFactory implements FactoryInterface |
18 | 18 | { |
19 | - /** |
|
20 | - * @var AssetManifestInterface[] |
|
21 | - */ |
|
22 | - private static $manifests = []; |
|
19 | + /** |
|
20 | + * @var AssetManifestInterface[] |
|
21 | + */ |
|
22 | + private static $manifests = []; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var LoaderInterface $loader |
|
26 | - */ |
|
27 | - protected $loader; |
|
24 | + /** |
|
25 | + * @var LoaderInterface $loader |
|
26 | + */ |
|
27 | + protected $loader; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * AssetManifestFactory constructor. |
|
32 | - * |
|
33 | - * @param LoaderInterface $loader |
|
34 | - */ |
|
35 | - public function __construct(LoaderInterface $loader) |
|
36 | - { |
|
37 | - $this->loader = $loader; |
|
38 | - } |
|
30 | + /** |
|
31 | + * AssetManifestFactory constructor. |
|
32 | + * |
|
33 | + * @param LoaderInterface $loader |
|
34 | + */ |
|
35 | + public function __construct(LoaderInterface $loader) |
|
36 | + { |
|
37 | + $this->loader = $loader; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * returns the applicable AssetManifest for the provided Domain |
|
43 | - * |
|
44 | - * @param DomainInterface $domain |
|
45 | - * @return AssetManifestInterface |
|
46 | - */ |
|
47 | - public function createFromDomainObject(DomainInterface $domain) |
|
48 | - { |
|
49 | - return $this->getAssetManifestForDomain(AssetManifest::class, $domain); |
|
50 | - } |
|
41 | + /** |
|
42 | + * returns the applicable AssetManifest for the provided Domain |
|
43 | + * |
|
44 | + * @param DomainInterface $domain |
|
45 | + * @return AssetManifestInterface |
|
46 | + */ |
|
47 | + public function createFromDomainObject(DomainInterface $domain) |
|
48 | + { |
|
49 | + return $this->getAssetManifestForDomain(AssetManifest::class, $domain); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * for creating an atypical AssetManifest for the Domain provided in the $arguments array |
|
55 | - * |
|
56 | - * @param string $fqcn Fully Qualified Class Name |
|
57 | - * @param array $arguments [optional] array of data required for construction |
|
58 | - * @return AssetManifestInterface |
|
59 | - */ |
|
60 | - public function create($fqcn, array $arguments = []) |
|
61 | - { |
|
62 | - if (! isset($arguments[0]) || ! $arguments[0] instanceof DomainInterface) { |
|
63 | - throw new InvalidArgumentException( |
|
64 | - esc_html__( |
|
65 | - 'In order to generate an AssetManifest class you need to supply an array where the first argument is an instance of DomainInterface.', |
|
66 | - 'event_espresso' |
|
67 | - ) |
|
68 | - ); |
|
69 | - } |
|
70 | - return $this->getAssetManifestForDomain($fqcn, $arguments[0]); |
|
71 | - } |
|
53 | + /** |
|
54 | + * for creating an atypical AssetManifest for the Domain provided in the $arguments array |
|
55 | + * |
|
56 | + * @param string $fqcn Fully Qualified Class Name |
|
57 | + * @param array $arguments [optional] array of data required for construction |
|
58 | + * @return AssetManifestInterface |
|
59 | + */ |
|
60 | + public function create($fqcn, array $arguments = []) |
|
61 | + { |
|
62 | + if (! isset($arguments[0]) || ! $arguments[0] instanceof DomainInterface) { |
|
63 | + throw new InvalidArgumentException( |
|
64 | + esc_html__( |
|
65 | + 'In order to generate an AssetManifest class you need to supply an array where the first argument is an instance of DomainInterface.', |
|
66 | + 'event_espresso' |
|
67 | + ) |
|
68 | + ); |
|
69 | + } |
|
70 | + return $this->getAssetManifestForDomain($fqcn, $arguments[0]); |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * @param string $manifest_fqcn |
|
76 | - * @param DomainInterface $domain |
|
77 | - * @return AssetManifestInterface |
|
78 | - */ |
|
79 | - private function getAssetManifestForDomain($manifest_fqcn, DomainInterface $domain) |
|
80 | - { |
|
81 | - $domain_fqcn = get_class($domain); |
|
82 | - if (! isset(AssetManifestFactory::$manifests[ $domain_fqcn ])) { |
|
83 | - $asset_manifest = new $manifest_fqcn($domain); |
|
84 | - if (! $asset_manifest instanceof AssetManifestInterface || ! $asset_manifest instanceof $manifest_fqcn) { |
|
85 | - throw new DomainException( |
|
86 | - sprintf( |
|
87 | - esc_html__( |
|
88 | - 'The requested AssetManifest class "%1$s" could not be loaded.', |
|
89 | - 'event_espresso' |
|
90 | - ), |
|
91 | - $manifest_fqcn |
|
92 | - ) |
|
93 | - ); |
|
94 | - } |
|
95 | - // we still need to share this with the core loader to facilitate automatic dependency injection |
|
96 | - $this->loader->share(AssetManifest::class, $asset_manifest, [$domain]); |
|
97 | - AssetManifestFactory::$manifests[ $domain_fqcn ] = $asset_manifest; |
|
98 | - } |
|
99 | - return AssetManifestFactory::$manifests[ $domain_fqcn ]; |
|
100 | - } |
|
74 | + /** |
|
75 | + * @param string $manifest_fqcn |
|
76 | + * @param DomainInterface $domain |
|
77 | + * @return AssetManifestInterface |
|
78 | + */ |
|
79 | + private function getAssetManifestForDomain($manifest_fqcn, DomainInterface $domain) |
|
80 | + { |
|
81 | + $domain_fqcn = get_class($domain); |
|
82 | + if (! isset(AssetManifestFactory::$manifests[ $domain_fqcn ])) { |
|
83 | + $asset_manifest = new $manifest_fqcn($domain); |
|
84 | + if (! $asset_manifest instanceof AssetManifestInterface || ! $asset_manifest instanceof $manifest_fqcn) { |
|
85 | + throw new DomainException( |
|
86 | + sprintf( |
|
87 | + esc_html__( |
|
88 | + 'The requested AssetManifest class "%1$s" could not be loaded.', |
|
89 | + 'event_espresso' |
|
90 | + ), |
|
91 | + $manifest_fqcn |
|
92 | + ) |
|
93 | + ); |
|
94 | + } |
|
95 | + // we still need to share this with the core loader to facilitate automatic dependency injection |
|
96 | + $this->loader->share(AssetManifest::class, $asset_manifest, [$domain]); |
|
97 | + AssetManifestFactory::$manifests[ $domain_fqcn ] = $asset_manifest; |
|
98 | + } |
|
99 | + return AssetManifestFactory::$manifests[ $domain_fqcn ]; |
|
100 | + } |
|
101 | 101 | } |
@@ -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); |