@@ -18,31 +18,31 @@ |
||
18 | 18 | class DataLoaderManager implements GQLManagerInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
23 | - */ |
|
24 | - private $data_loaders; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * @param DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
29 | - */ |
|
30 | - public function __construct(DataLoaderCollection $data_loaders) |
|
31 | - { |
|
32 | - $this->data_loaders = $data_loaders; |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @throws CollectionDetailsException |
|
38 | - * @throws CollectionLoaderException |
|
39 | - * @since $VID:$ |
|
40 | - */ |
|
41 | - public function init() |
|
42 | - { |
|
43 | - $data_loaders = $this->data_loaders->getDataLoaders(); |
|
44 | - foreach ($data_loaders as $data_loader) { |
|
45 | - add_filter('graphql_data_loaders', [$data_loader, 'registerLoaders'], 10, 2); |
|
46 | - } |
|
47 | - } |
|
21 | + /** |
|
22 | + * @var DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
23 | + */ |
|
24 | + private $data_loaders; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * @param DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
29 | + */ |
|
30 | + public function __construct(DataLoaderCollection $data_loaders) |
|
31 | + { |
|
32 | + $this->data_loaders = $data_loaders; |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @throws CollectionDetailsException |
|
38 | + * @throws CollectionLoaderException |
|
39 | + * @since $VID:$ |
|
40 | + */ |
|
41 | + public function init() |
|
42 | + { |
|
43 | + $data_loaders = $this->data_loaders->getDataLoaders(); |
|
44 | + foreach ($data_loaders as $data_loader) { |
|
45 | + add_filter('graphql_data_loaders', [$data_loader, 'registerLoaders'], 10, 2); |
|
46 | + } |
|
47 | + } |
|
48 | 48 | } |
@@ -21,72 +21,72 @@ |
||
21 | 21 | class DataLoaderCollection extends Collection |
22 | 22 | { |
23 | 23 | |
24 | - const COLLECTION_NAME = 'espresso_graphql_data_loaders'; |
|
24 | + const COLLECTION_NAME = 'espresso_graphql_data_loaders'; |
|
25 | 25 | |
26 | - const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\loaders\GQLDataDomainInterface'; |
|
26 | + const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\loaders\GQLDataDomainInterface'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var CollectionLoader $loader |
|
30 | - */ |
|
31 | - protected $loader; |
|
28 | + /** |
|
29 | + * @var CollectionLoader $loader |
|
30 | + */ |
|
31 | + protected $loader; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * DataLoaderCollection constructor |
|
36 | - * |
|
37 | - * @throws InvalidInterfaceException |
|
38 | - */ |
|
39 | - public function __construct() |
|
40 | - { |
|
41 | - parent::__construct( |
|
42 | - DataLoaderCollection::COLLECTION_INTERFACE, |
|
43 | - DataLoaderCollection::COLLECTION_NAME |
|
44 | - ); |
|
45 | - } |
|
34 | + /** |
|
35 | + * DataLoaderCollection constructor |
|
36 | + * |
|
37 | + * @throws InvalidInterfaceException |
|
38 | + */ |
|
39 | + public function __construct() |
|
40 | + { |
|
41 | + parent::__construct( |
|
42 | + DataLoaderCollection::COLLECTION_INTERFACE, |
|
43 | + DataLoaderCollection::COLLECTION_NAME |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @throws CollectionDetailsException |
|
50 | - * @throws CollectionLoaderException |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - private function loadCollection() |
|
54 | - { |
|
55 | - if (! $this->loader instanceof CollectionLoader) { |
|
56 | - $this->loader = new CollectionLoader( |
|
57 | - new CollectionDetails( |
|
58 | - // collection name |
|
59 | - DataLoaderCollection::COLLECTION_NAME, |
|
60 | - // collection interface |
|
61 | - DataLoaderCollection::COLLECTION_INTERFACE, |
|
62 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
63 | - apply_filters( |
|
64 | - 'FHEE__EventEspresso_core_services_graphql_DataLoaderCollection__loadCollection__collection_FQCNs', |
|
65 | - ['EventEspresso\core\domain\services\graphql\data\domains'] |
|
66 | - ), |
|
67 | - // filepaths to classes to add |
|
68 | - array(), |
|
69 | - // file mask to use if parsing folder for files to add |
|
70 | - '', |
|
71 | - // what to use as identifier for collection entities |
|
72 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
73 | - CollectionDetails::ID_CLASS_NAME |
|
74 | - ), |
|
75 | - $this |
|
76 | - ); |
|
77 | - } |
|
78 | - } |
|
48 | + /** |
|
49 | + * @throws CollectionDetailsException |
|
50 | + * @throws CollectionLoaderException |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + private function loadCollection() |
|
54 | + { |
|
55 | + if (! $this->loader instanceof CollectionLoader) { |
|
56 | + $this->loader = new CollectionLoader( |
|
57 | + new CollectionDetails( |
|
58 | + // collection name |
|
59 | + DataLoaderCollection::COLLECTION_NAME, |
|
60 | + // collection interface |
|
61 | + DataLoaderCollection::COLLECTION_INTERFACE, |
|
62 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
63 | + apply_filters( |
|
64 | + 'FHEE__EventEspresso_core_services_graphql_DataLoaderCollection__loadCollection__collection_FQCNs', |
|
65 | + ['EventEspresso\core\domain\services\graphql\data\domains'] |
|
66 | + ), |
|
67 | + // filepaths to classes to add |
|
68 | + array(), |
|
69 | + // file mask to use if parsing folder for files to add |
|
70 | + '', |
|
71 | + // what to use as identifier for collection entities |
|
72 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
73 | + CollectionDetails::ID_CLASS_NAME |
|
74 | + ), |
|
75 | + $this |
|
76 | + ); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * @return CollectionInterface |
|
83 | - * @throws CollectionDetailsException |
|
84 | - * @throws CollectionLoaderException |
|
85 | - * @since $VID:$ |
|
86 | - */ |
|
87 | - public function getDataLoaders() |
|
88 | - { |
|
89 | - $this->loadCollection(); |
|
90 | - return $this->loader->getCollection(); |
|
91 | - } |
|
81 | + /** |
|
82 | + * @return CollectionInterface |
|
83 | + * @throws CollectionDetailsException |
|
84 | + * @throws CollectionLoaderException |
|
85 | + * @since $VID:$ |
|
86 | + */ |
|
87 | + public function getDataLoaders() |
|
88 | + { |
|
89 | + $this->loadCollection(); |
|
90 | + return $this->loader->getCollection(); |
|
91 | + } |
|
92 | 92 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | private function loadCollection() |
51 | 51 | { |
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
53 | 53 | $this->loader = new CollectionLoader( |
54 | 54 | new CollectionDetails( |
55 | 55 | // collection name |
@@ -18,40 +18,40 @@ |
||
18 | 18 | class ConnectionsManager implements GQLManagerInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var ConnectionCollection|ConnectionInterface[] $connections |
|
23 | - */ |
|
24 | - private $connections; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * ConnectionsManager constructor. |
|
29 | - * |
|
30 | - * @param ConnectionCollection|ConnectionInterface[] $connections |
|
31 | - */ |
|
32 | - public function __construct(ConnectionCollection $connections) |
|
33 | - { |
|
34 | - $this->connections = $connections; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @throws CollectionDetailsException |
|
40 | - * @throws CollectionLoaderException |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function init() |
|
44 | - { |
|
45 | - $this->connections->loadConnections(); |
|
46 | - add_action('graphql_register_types', [$this, 'registerConnections'], 20); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - public function registerConnections() |
|
51 | - { |
|
52 | - // loop through the collection of types and register their fields |
|
53 | - foreach ($this->connections as $connection) { |
|
54 | - register_graphql_connection($connection->config()); |
|
55 | - } |
|
56 | - } |
|
21 | + /** |
|
22 | + * @var ConnectionCollection|ConnectionInterface[] $connections |
|
23 | + */ |
|
24 | + private $connections; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * ConnectionsManager constructor. |
|
29 | + * |
|
30 | + * @param ConnectionCollection|ConnectionInterface[] $connections |
|
31 | + */ |
|
32 | + public function __construct(ConnectionCollection $connections) |
|
33 | + { |
|
34 | + $this->connections = $connections; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @throws CollectionDetailsException |
|
40 | + * @throws CollectionLoaderException |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function init() |
|
44 | + { |
|
45 | + $this->connections->loadConnections(); |
|
46 | + add_action('graphql_register_types', [$this, 'registerConnections'], 20); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + public function registerConnections() |
|
51 | + { |
|
52 | + // loop through the collection of types and register their fields |
|
53 | + foreach ($this->connections as $connection) { |
|
54 | + register_graphql_connection($connection->config()); |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
@@ -20,32 +20,32 @@ |
||
20 | 20 | class ReactAssetManager extends AssetManager |
21 | 21 | { |
22 | 22 | |
23 | - const REACT_VERSION = '16.13.1'; |
|
24 | - |
|
25 | - const JS_HANDLE_REACT = 'react'; |
|
26 | - |
|
27 | - const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * @throws InvalidDataTypeException |
|
32 | - * @throws InvalidEntityException |
|
33 | - * @throws DuplicateCollectionIdentifierException |
|
34 | - * @throws DomainException |
|
35 | - */ |
|
36 | - public function addAssets() |
|
37 | - { |
|
38 | - $this->addVendorJavascript( |
|
39 | - ReactAssetManager::JS_HANDLE_REACT, |
|
40 | - [], |
|
41 | - true, |
|
42 | - ReactAssetManager::REACT_VERSION |
|
43 | - ); |
|
44 | - $this->addVendorJavascript( |
|
45 | - ReactAssetManager::JS_HANDLE_REACT_DOM, |
|
46 | - [ReactAssetManager::JS_HANDLE_REACT], |
|
47 | - true, |
|
48 | - ReactAssetManager::REACT_VERSION |
|
49 | - ); |
|
50 | - } |
|
23 | + const REACT_VERSION = '16.13.1'; |
|
24 | + |
|
25 | + const JS_HANDLE_REACT = 'react'; |
|
26 | + |
|
27 | + const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * @throws InvalidDataTypeException |
|
32 | + * @throws InvalidEntityException |
|
33 | + * @throws DuplicateCollectionIdentifierException |
|
34 | + * @throws DomainException |
|
35 | + */ |
|
36 | + public function addAssets() |
|
37 | + { |
|
38 | + $this->addVendorJavascript( |
|
39 | + ReactAssetManager::JS_HANDLE_REACT, |
|
40 | + [], |
|
41 | + true, |
|
42 | + ReactAssetManager::REACT_VERSION |
|
43 | + ); |
|
44 | + $this->addVendorJavascript( |
|
45 | + ReactAssetManager::JS_HANDLE_REACT_DOM, |
|
46 | + [ReactAssetManager::JS_HANDLE_REACT], |
|
47 | + true, |
|
48 | + ReactAssetManager::REACT_VERSION |
|
49 | + ); |
|
50 | + } |
|
51 | 51 | } |
@@ -16,66 +16,66 @@ |
||
16 | 16 | class ExitModal |
17 | 17 | { |
18 | 18 | |
19 | - const TYPE_FORM_URL = 'https://eventespresso.typeform.com/to/O1DDym'; |
|
19 | + const TYPE_FORM_URL = 'https://eventespresso.typeform.com/to/O1DDym'; |
|
20 | 20 | |
21 | - /** |
|
22 | - * ExitModal constructor. |
|
23 | - */ |
|
24 | - public function __construct() |
|
25 | - { |
|
26 | - } |
|
21 | + /** |
|
22 | + * ExitModal constructor. |
|
23 | + */ |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @return array |
|
31 | - * @since $VID:$ |
|
32 | - */ |
|
33 | - public function getExitSurveyInfo() |
|
34 | - { |
|
35 | - $current_user = new WP_User(get_current_user_id()); |
|
36 | - $query_args = [ |
|
37 | - 'emailAddress' => htmlspecialchars($current_user->user_email), |
|
38 | - 'website' => htmlspecialchars(site_url()), |
|
39 | - ]; |
|
40 | - // add user's first name if one exists |
|
41 | - $first_name = $current_user->user_firstname; |
|
42 | - if ($first_name) { |
|
43 | - $query_args['firstName'] = htmlspecialchars($first_name); |
|
44 | - } |
|
45 | - return [ |
|
46 | - 'isModalActive' => $this->isModalActive(), |
|
47 | - 'typeFormUrl' => add_query_arg($query_args, ExitModal::TYPE_FORM_URL) |
|
48 | - ]; |
|
49 | - } |
|
29 | + /** |
|
30 | + * @return array |
|
31 | + * @since $VID:$ |
|
32 | + */ |
|
33 | + public function getExitSurveyInfo() |
|
34 | + { |
|
35 | + $current_user = new WP_User(get_current_user_id()); |
|
36 | + $query_args = [ |
|
37 | + 'emailAddress' => htmlspecialchars($current_user->user_email), |
|
38 | + 'website' => htmlspecialchars(site_url()), |
|
39 | + ]; |
|
40 | + // add user's first name if one exists |
|
41 | + $first_name = $current_user->user_firstname; |
|
42 | + if ($first_name) { |
|
43 | + $query_args['firstName'] = htmlspecialchars($first_name); |
|
44 | + } |
|
45 | + return [ |
|
46 | + 'isModalActive' => $this->isModalActive(), |
|
47 | + 'typeFormUrl' => add_query_arg($query_args, ExitModal::TYPE_FORM_URL) |
|
48 | + ]; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Exposes a filter switch for turning off the enqueueing of the modal script. |
|
54 | - * @return bool |
|
55 | - */ |
|
56 | - private function isModalActive() |
|
57 | - { |
|
58 | - return filter_var( |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_domain_services_admin_ExitModal__isModalActive', |
|
61 | - true |
|
62 | - ), |
|
63 | - FILTER_VALIDATE_BOOLEAN |
|
64 | - ); |
|
65 | - } |
|
52 | + /** |
|
53 | + * Exposes a filter switch for turning off the enqueueing of the modal script. |
|
54 | + * @return bool |
|
55 | + */ |
|
56 | + private function isModalActive() |
|
57 | + { |
|
58 | + return filter_var( |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_domain_services_admin_ExitModal__isModalActive', |
|
61 | + true |
|
62 | + ), |
|
63 | + FILTER_VALIDATE_BOOLEAN |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @deprecated $VID:$ |
|
70 | - */ |
|
71 | - public function modalContainer() |
|
72 | - { |
|
73 | - } |
|
68 | + /** |
|
69 | + * @deprecated $VID:$ |
|
70 | + */ |
|
71 | + public function modalContainer() |
|
72 | + { |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @deprecated $VID:$ |
|
77 | - */ |
|
78 | - public function enqueues() |
|
79 | - { |
|
80 | - } |
|
75 | + /** |
|
76 | + * @deprecated $VID:$ |
|
77 | + */ |
|
78 | + public function enqueues() |
|
79 | + { |
|
80 | + } |
|
81 | 81 | } |
@@ -12,146 +12,146 @@ |
||
12 | 12 | class EE_Taxes extends EE_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * This is used for when EE_Taxes is used statically by the admin |
|
17 | - * |
|
18 | - * @var array |
|
19 | - */ |
|
20 | - private static $_subtotal = []; |
|
15 | + /** |
|
16 | + * This is used for when EE_Taxes is used statically by the admin |
|
17 | + * |
|
18 | + * @var array |
|
19 | + */ |
|
20 | + private static $_subtotal = []; |
|
21 | 21 | |
22 | - /** |
|
23 | - * This holds an array of EE_Price objects that are of PRT_ID == 4 (tax price types) |
|
24 | - * |
|
25 | - * @var EE_Price[] |
|
26 | - */ |
|
27 | - private static $_default_taxes = []; |
|
22 | + /** |
|
23 | + * This holds an array of EE_Price objects that are of PRT_ID == 4 (tax price types) |
|
24 | + * |
|
25 | + * @var EE_Price[] |
|
26 | + */ |
|
27 | + private static $_default_taxes = []; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * This method simply calculates the total taxes for a given ticket (by pulling the prices attached to the ticket |
|
32 | - * and applying default taxes to it). Note: this is just an intermediary helper method added to facilitate quick |
|
33 | - * calc of taxes for tickets listed in the event editor. |
|
34 | - * |
|
35 | - * @param EE_Ticket $ticket incoming EE_Ticket |
|
36 | - * @return float total taxes to apply to ticket. |
|
37 | - * @throws EE_Error |
|
38 | - * @throws ReflectionException |
|
39 | - */ |
|
40 | - public static function get_total_taxes_for_admin(EE_Ticket $ticket) |
|
41 | - { |
|
42 | - $tax = 0; |
|
43 | - $total_tax = 0; |
|
44 | - // This first checks to see if the given ticket is taxable. |
|
45 | - if (! $ticket->taxable()) { |
|
46 | - return $tax; |
|
47 | - } |
|
48 | - // get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
|
49 | - $subtotal = EE_Taxes::get_subtotal_for_admin($ticket); |
|
50 | - // get taxes |
|
51 | - $taxes = EE_Taxes::get_taxes_for_admin(); |
|
52 | - // apply taxes to subtotal |
|
53 | - foreach ($taxes as $tax) { |
|
54 | - // assuming taxes are not cumulative |
|
55 | - $total_tax += $subtotal * $tax->amount() / 100; |
|
56 | - } |
|
57 | - return $total_tax; |
|
58 | - } |
|
30 | + /** |
|
31 | + * This method simply calculates the total taxes for a given ticket (by pulling the prices attached to the ticket |
|
32 | + * and applying default taxes to it). Note: this is just an intermediary helper method added to facilitate quick |
|
33 | + * calc of taxes for tickets listed in the event editor. |
|
34 | + * |
|
35 | + * @param EE_Ticket $ticket incoming EE_Ticket |
|
36 | + * @return float total taxes to apply to ticket. |
|
37 | + * @throws EE_Error |
|
38 | + * @throws ReflectionException |
|
39 | + */ |
|
40 | + public static function get_total_taxes_for_admin(EE_Ticket $ticket) |
|
41 | + { |
|
42 | + $tax = 0; |
|
43 | + $total_tax = 0; |
|
44 | + // This first checks to see if the given ticket is taxable. |
|
45 | + if (! $ticket->taxable()) { |
|
46 | + return $tax; |
|
47 | + } |
|
48 | + // get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
|
49 | + $subtotal = EE_Taxes::get_subtotal_for_admin($ticket); |
|
50 | + // get taxes |
|
51 | + $taxes = EE_Taxes::get_taxes_for_admin(); |
|
52 | + // apply taxes to subtotal |
|
53 | + foreach ($taxes as $tax) { |
|
54 | + // assuming taxes are not cumulative |
|
55 | + $total_tax += $subtotal * $tax->amount() / 100; |
|
56 | + } |
|
57 | + return $total_tax; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * Gets the total percentage of tax that should be applied to taxable line items |
|
63 | - * |
|
64 | - * @return float the percentage of tax that should be added to taxable items |
|
65 | - * @throws EE_Error |
|
66 | - * @throws ReflectionException |
|
67 | - * eg 20 for %20 tax (NOT 0.20, which |
|
68 | - */ |
|
69 | - public static function get_total_taxes_percentage() |
|
70 | - { |
|
71 | - $total_tax_percent = 0; |
|
72 | - foreach (EE_Taxes::get_taxes_for_admin() as $tax_price) { |
|
73 | - $total_tax_percent += $tax_price->get('PRC_amount'); |
|
74 | - } |
|
75 | - return $total_tax_percent; |
|
76 | - } |
|
61 | + /** |
|
62 | + * Gets the total percentage of tax that should be applied to taxable line items |
|
63 | + * |
|
64 | + * @return float the percentage of tax that should be added to taxable items |
|
65 | + * @throws EE_Error |
|
66 | + * @throws ReflectionException |
|
67 | + * eg 20 for %20 tax (NOT 0.20, which |
|
68 | + */ |
|
69 | + public static function get_total_taxes_percentage() |
|
70 | + { |
|
71 | + $total_tax_percent = 0; |
|
72 | + foreach (EE_Taxes::get_taxes_for_admin() as $tax_price) { |
|
73 | + $total_tax_percent += $tax_price->get('PRC_amount'); |
|
74 | + } |
|
75 | + return $total_tax_percent; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @param EE_Ticket $ticket |
|
81 | - * @return float |
|
82 | - * @throws EE_Error |
|
83 | - * @throws ReflectionException |
|
84 | - */ |
|
85 | - public static function get_subtotal_for_admin(EE_Ticket $ticket) |
|
86 | - { |
|
87 | - $TKT_ID = $ticket->ID(); |
|
88 | - return isset(EE_Taxes::$_subtotal[ $TKT_ID ]) |
|
89 | - ? EE_Taxes::$_subtotal[ $TKT_ID ] |
|
90 | - : EE_Taxes::_get_subtotal_for_admin($ticket); |
|
91 | - } |
|
79 | + /** |
|
80 | + * @param EE_Ticket $ticket |
|
81 | + * @return float |
|
82 | + * @throws EE_Error |
|
83 | + * @throws ReflectionException |
|
84 | + */ |
|
85 | + public static function get_subtotal_for_admin(EE_Ticket $ticket) |
|
86 | + { |
|
87 | + $TKT_ID = $ticket->ID(); |
|
88 | + return isset(EE_Taxes::$_subtotal[ $TKT_ID ]) |
|
89 | + ? EE_Taxes::$_subtotal[ $TKT_ID ] |
|
90 | + : EE_Taxes::_get_subtotal_for_admin($ticket); |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * simply take an incoming ticket and calculate the subtotal for the ticket |
|
96 | - * |
|
97 | - * @param EE_Ticket $ticket |
|
98 | - * @return float subtotal calculated from all EE_Price[] on Ticket. |
|
99 | - * @throws EE_Error |
|
100 | - * @throws ReflectionException |
|
101 | - */ |
|
102 | - private static function _get_subtotal_for_admin(EE_Ticket $ticket) |
|
103 | - { |
|
104 | - $subtotal = 0; |
|
105 | - // get all prices |
|
106 | - $prices = $ticket->get_many_related( |
|
107 | - 'Price', |
|
108 | - [ |
|
109 | - 'default_where_conditions' => 'none', |
|
110 | - 'order_by' => ['PRC_order' => 'ASC'], |
|
111 | - ] |
|
112 | - ); |
|
113 | - // let's loop through them (base price is always the first item) |
|
114 | - foreach ($prices as $price) { |
|
115 | - if ($price instanceof EE_Price) { |
|
116 | - $price_type = $price->type_obj(); |
|
117 | - if ($price_type instanceof EE_Price_Type) { |
|
118 | - switch ($price->type_obj()->base_type()) { |
|
119 | - case 1: // base price |
|
120 | - case 3: // surcharges |
|
121 | - $subtotal += $price->is_percent() |
|
122 | - ? $subtotal * $price->get('PRC_amount') / 100 |
|
123 | - : $price->get('PRC_amount'); |
|
124 | - break; |
|
125 | - case 2: // discounts |
|
126 | - $subtotal -= $price->is_percent() |
|
127 | - ? $subtotal * $price->get('PRC_amount') / 100 |
|
128 | - : $price->get('PRC_amount'); |
|
129 | - break; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
133 | - } |
|
134 | - $TKT_ID = $ticket->ID(); |
|
135 | - EE_Taxes::$_subtotal[ $TKT_ID ] = $subtotal; |
|
136 | - return $subtotal; |
|
137 | - } |
|
94 | + /** |
|
95 | + * simply take an incoming ticket and calculate the subtotal for the ticket |
|
96 | + * |
|
97 | + * @param EE_Ticket $ticket |
|
98 | + * @return float subtotal calculated from all EE_Price[] on Ticket. |
|
99 | + * @throws EE_Error |
|
100 | + * @throws ReflectionException |
|
101 | + */ |
|
102 | + private static function _get_subtotal_for_admin(EE_Ticket $ticket) |
|
103 | + { |
|
104 | + $subtotal = 0; |
|
105 | + // get all prices |
|
106 | + $prices = $ticket->get_many_related( |
|
107 | + 'Price', |
|
108 | + [ |
|
109 | + 'default_where_conditions' => 'none', |
|
110 | + 'order_by' => ['PRC_order' => 'ASC'], |
|
111 | + ] |
|
112 | + ); |
|
113 | + // let's loop through them (base price is always the first item) |
|
114 | + foreach ($prices as $price) { |
|
115 | + if ($price instanceof EE_Price) { |
|
116 | + $price_type = $price->type_obj(); |
|
117 | + if ($price_type instanceof EE_Price_Type) { |
|
118 | + switch ($price->type_obj()->base_type()) { |
|
119 | + case 1: // base price |
|
120 | + case 3: // surcharges |
|
121 | + $subtotal += $price->is_percent() |
|
122 | + ? $subtotal * $price->get('PRC_amount') / 100 |
|
123 | + : $price->get('PRC_amount'); |
|
124 | + break; |
|
125 | + case 2: // discounts |
|
126 | + $subtotal -= $price->is_percent() |
|
127 | + ? $subtotal * $price->get('PRC_amount') / 100 |
|
128 | + : $price->get('PRC_amount'); |
|
129 | + break; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | + } |
|
134 | + $TKT_ID = $ticket->ID(); |
|
135 | + EE_Taxes::$_subtotal[ $TKT_ID ] = $subtotal; |
|
136 | + return $subtotal; |
|
137 | + } |
|
138 | 138 | |
139 | 139 | |
140 | - /** |
|
141 | - * get all default prices that are a Tax price type (PRT_ID = 4) and return |
|
142 | - * |
|
143 | - * @return EE_Price[] EE_Price objects that have PRT_ID == 4 |
|
144 | - * @throws EE_Error |
|
145 | - */ |
|
146 | - public static function get_taxes_for_admin() |
|
147 | - { |
|
148 | - if (empty(EE_Taxes::$_default_taxes)) { |
|
149 | - /** @var EEM_Price $price_model */ |
|
150 | - $price_model = LoaderFactory::getLoader()->getShared('EEM_Price'); |
|
151 | - EE_Taxes::$_default_taxes = $price_model->get_all( |
|
152 | - [['Price_Type.PBT_ID' => 4]] |
|
153 | - ); |
|
154 | - } |
|
155 | - return EE_Taxes::$_default_taxes; |
|
156 | - } |
|
140 | + /** |
|
141 | + * get all default prices that are a Tax price type (PRT_ID = 4) and return |
|
142 | + * |
|
143 | + * @return EE_Price[] EE_Price objects that have PRT_ID == 4 |
|
144 | + * @throws EE_Error |
|
145 | + */ |
|
146 | + public static function get_taxes_for_admin() |
|
147 | + { |
|
148 | + if (empty(EE_Taxes::$_default_taxes)) { |
|
149 | + /** @var EEM_Price $price_model */ |
|
150 | + $price_model = LoaderFactory::getLoader()->getShared('EEM_Price'); |
|
151 | + EE_Taxes::$_default_taxes = $price_model->get_all( |
|
152 | + [['Price_Type.PBT_ID' => 4]] |
|
153 | + ); |
|
154 | + } |
|
155 | + return EE_Taxes::$_default_taxes; |
|
156 | + } |
|
157 | 157 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $tax = 0; |
43 | 43 | $total_tax = 0; |
44 | 44 | // This first checks to see if the given ticket is taxable. |
45 | - if (! $ticket->taxable()) { |
|
45 | + if ( ! $ticket->taxable()) { |
|
46 | 46 | return $tax; |
47 | 47 | } |
48 | 48 | // get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | public static function get_subtotal_for_admin(EE_Ticket $ticket) |
86 | 86 | { |
87 | 87 | $TKT_ID = $ticket->ID(); |
88 | - return isset(EE_Taxes::$_subtotal[ $TKT_ID ]) |
|
89 | - ? EE_Taxes::$_subtotal[ $TKT_ID ] |
|
88 | + return isset(EE_Taxes::$_subtotal[$TKT_ID]) |
|
89 | + ? EE_Taxes::$_subtotal[$TKT_ID] |
|
90 | 90 | : EE_Taxes::_get_subtotal_for_admin($ticket); |
91 | 91 | } |
92 | 92 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | } |
134 | 134 | $TKT_ID = $ticket->ID(); |
135 | - EE_Taxes::$_subtotal[ $TKT_ID ] = $subtotal; |
|
135 | + EE_Taxes::$_subtotal[$TKT_ID] = $subtotal; |
|
136 | 136 | return $subtotal; |
137 | 137 | } |
138 | 138 |
@@ -17,70 +17,70 @@ |
||
17 | 17 | class PluginUpsells |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var DomainInterface |
|
22 | - */ |
|
23 | - private $domain; |
|
20 | + /** |
|
21 | + * @var DomainInterface |
|
22 | + */ |
|
23 | + private $domain; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * PluginUpsells constructor. |
|
28 | - * |
|
29 | - * @param DomainInterface $domain |
|
30 | - */ |
|
31 | - public function __construct(DomainInterface $domain) |
|
32 | - { |
|
33 | - $this->domain = $domain; |
|
34 | - } |
|
26 | + /** |
|
27 | + * PluginUpsells constructor. |
|
28 | + * |
|
29 | + * @param DomainInterface $domain |
|
30 | + */ |
|
31 | + public function __construct(DomainInterface $domain) |
|
32 | + { |
|
33 | + $this->domain = $domain; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Hook in various upsells for the decaf version of EE. |
|
39 | - */ |
|
40 | - public function decafUpsells() |
|
41 | - { |
|
42 | - if ($this->domain instanceof CaffeinatedInterface && ! $this->domain->isCaffeinated()) { |
|
43 | - add_action('after_plugin_row', array($this, 'doPremiumUpsell'), 10); |
|
44 | - } |
|
45 | - } |
|
37 | + /** |
|
38 | + * Hook in various upsells for the decaf version of EE. |
|
39 | + */ |
|
40 | + public function decafUpsells() |
|
41 | + { |
|
42 | + if ($this->domain instanceof CaffeinatedInterface && ! $this->domain->isCaffeinated()) { |
|
43 | + add_action('after_plugin_row', array($this, 'doPremiumUpsell'), 10); |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Callback for `after_plugin_row` to add upsell info |
|
50 | - * |
|
51 | - * @param string $plugin_file |
|
52 | - * @throws DomainException |
|
53 | - */ |
|
54 | - public function doPremiumUpsell($plugin_file) |
|
55 | - { |
|
56 | - if ($plugin_file === $this->domain->pluginBasename()) { |
|
57 | - echo ' |
|
48 | + /** |
|
49 | + * Callback for `after_plugin_row` to add upsell info |
|
50 | + * |
|
51 | + * @param string $plugin_file |
|
52 | + * @throws DomainException |
|
53 | + */ |
|
54 | + public function doPremiumUpsell($plugin_file) |
|
55 | + { |
|
56 | + if ($plugin_file === $this->domain->pluginBasename()) { |
|
57 | + echo ' |
|
58 | 58 | <tr class="ee-upsell-plugin-list-table active"> |
59 | 59 | <th scope="row" class="check-column"></th> |
60 | 60 | <td class="column-primary"> |
61 | 61 | <div class="ee-upsell-col" style="padding:10px 0;"> |
62 | 62 | <a href="https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link""> |
63 | 63 | <button class="button button-secondary" style="background:#008dcb; border:1px solid #008dcb; color:#fff; ">' |
64 | - . esc_html__('Upgrade for Support', 'event_espresso') |
|
65 | - . '</button> |
|
64 | + . esc_html__('Upgrade for Support', 'event_espresso') |
|
65 | + . '</button> |
|
66 | 66 | </a> |
67 | 67 | </div> |
68 | 68 | </td> |
69 | 69 | <td class="column-description"> |
70 | 70 | <div class="ee-upsell-col plugin-description" style="font-size: .85rem; line-height: 1.2rem; padding:5px 0;">' |
71 | - . sprintf( |
|
72 | - esc_html__( |
|
73 | - 'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s!%3$sDon\'t have an Event Espresso support license key? Support the project and buy one today!', |
|
74 | - 'event_espresso' |
|
75 | - ), |
|
76 | - '<strong>', |
|
77 | - '</strong>', |
|
78 | - '<br />' |
|
79 | - ) . |
|
80 | - '</div> |
|
71 | + . sprintf( |
|
72 | + esc_html__( |
|
73 | + 'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s!%3$sDon\'t have an Event Espresso support license key? Support the project and buy one today!', |
|
74 | + 'event_espresso' |
|
75 | + ), |
|
76 | + '<strong>', |
|
77 | + '</strong>', |
|
78 | + '<br />' |
|
79 | + ) . |
|
80 | + '</div> |
|
81 | 81 | </td> |
82 | 82 | </tr> |
83 | 83 | '; |
84 | - } |
|
85 | - } |
|
84 | + } |
|
85 | + } |
|
86 | 86 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | '<strong>', |
77 | 77 | '</strong>', |
78 | 78 | '<br />' |
79 | - ) . |
|
79 | + ). |
|
80 | 80 | '</div> |
81 | 81 | </td> |
82 | 82 | </tr> |
@@ -21,209 +21,209 @@ |
||
21 | 21 | abstract class Block implements BlockInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * BlockAssetManager that this editor block uses for asset registration |
|
26 | - * |
|
27 | - * @var BlockAssetManagerInterface $block_asset_manager |
|
28 | - */ |
|
29 | - protected $block_asset_manager; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var RequestInterface $request |
|
33 | - */ |
|
34 | - protected $request; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var array $attributes |
|
38 | - */ |
|
39 | - private $attributes; |
|
40 | - |
|
41 | - /** |
|
42 | - * If set to true, then the block will render its content client side |
|
43 | - * If false, then the block will render its content server side using the renderBlock() method |
|
44 | - * |
|
45 | - * @var bool $dynamic |
|
46 | - */ |
|
47 | - private $dynamic = false; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var string $block_type |
|
51 | - */ |
|
52 | - private $block_type; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var array $supported_routes |
|
56 | - */ |
|
57 | - private $supported_routes; |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Block constructor. |
|
62 | - * |
|
63 | - * @param BlockAssetManagerInterface $block_asset_manager |
|
64 | - * @param RequestInterface $request |
|
65 | - */ |
|
66 | - public function __construct(BlockAssetManagerInterface $block_asset_manager, RequestInterface $request) |
|
67 | - { |
|
68 | - $this->block_asset_manager = $block_asset_manager; |
|
69 | - $this->request = $request; |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public function blockType() |
|
77 | - { |
|
78 | - return $this->block_type; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function namespacedBlockType() |
|
86 | - { |
|
87 | - return Block::NAME_SPACE . '/' . $this->block_type; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @param string $block_type |
|
93 | - */ |
|
94 | - protected function setBlockType($block_type) |
|
95 | - { |
|
96 | - $this->block_type = $block_type; |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * BlockAssetManager that this editor block uses for asset registration |
|
102 | - * |
|
103 | - * @return BlockAssetManagerInterface |
|
104 | - */ |
|
105 | - public function assetManager() |
|
106 | - { |
|
107 | - return $this->block_asset_manager; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * returns an array of fully qualified class names |
|
113 | - * for RouteMatchSpecificationInterface objects |
|
114 | - * that specify routes that the block should be loaded for. |
|
115 | - * |
|
116 | - * @return array |
|
117 | - */ |
|
118 | - public function supportedRoutes() |
|
119 | - { |
|
120 | - return $this->supported_routes; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @param array $supported_routes |
|
126 | - */ |
|
127 | - protected function setSupportedRoutes(array $supported_routes) |
|
128 | - { |
|
129 | - $this->supported_routes = $supported_routes; |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * @return array |
|
135 | - */ |
|
136 | - public function attributes() |
|
137 | - { |
|
138 | - return $this->attributes; |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @param array $attributes |
|
144 | - */ |
|
145 | - public function setAttributes(array $attributes) |
|
146 | - { |
|
147 | - $this->attributes = $attributes; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * @return bool |
|
153 | - */ |
|
154 | - public function isDynamic() |
|
155 | - { |
|
156 | - return $this->dynamic; |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * @param bool $dynamic |
|
162 | - */ |
|
163 | - public function setDynamic($dynamic = true) |
|
164 | - { |
|
165 | - $this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * Registers the Editor Block with WP core; |
|
171 | - * Returns the registered block type on success, or false on failure. |
|
172 | - * |
|
173 | - * @return WP_Block_Type|false |
|
174 | - */ |
|
175 | - public function registerBlock() |
|
176 | - { |
|
177 | - $args = array( |
|
178 | - 'attributes' => $this->attributes(), |
|
179 | - 'editor_script' => $this->block_asset_manager->getEditorScriptHandle(), |
|
180 | - 'script' => $this->block_asset_manager->getScriptHandle(), |
|
181 | - ); |
|
182 | - if ($this->isDynamic()) { |
|
183 | - $args['render_callback'] = array($this, 'renderBlock'); |
|
184 | - } |
|
185 | - return register_block_type( |
|
186 | - new WP_Block_Type( |
|
187 | - $this->namespacedBlockType(), |
|
188 | - $args |
|
189 | - ) |
|
190 | - ); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * @return WP_Block_Type|false The registered block type on success, or false on failure. |
|
196 | - */ |
|
197 | - public function unRegisterBlock() |
|
198 | - { |
|
199 | - return unregister_block_type($this->namespacedBlockType()); |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * @return array |
|
206 | - */ |
|
207 | - public function getEditorContainer() |
|
208 | - { |
|
209 | - return array( |
|
210 | - $this->namespacedBlockType(), |
|
211 | - array(), |
|
212 | - ); |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * @since $VID:$ |
|
218 | - */ |
|
219 | - protected function loadGraphQLRelayAutoloader() |
|
220 | - { |
|
221 | - if (! class_exists('GraphQLRelay')) { |
|
222 | - $autoloader = EE_THIRD_PARTY . 'wp-graphql/vendor/autoload.php'; |
|
223 | - if (! file_exists($autoloader)) { |
|
224 | - return; |
|
225 | - } |
|
226 | - require_once $autoloader; |
|
227 | - } |
|
228 | - } |
|
24 | + /** |
|
25 | + * BlockAssetManager that this editor block uses for asset registration |
|
26 | + * |
|
27 | + * @var BlockAssetManagerInterface $block_asset_manager |
|
28 | + */ |
|
29 | + protected $block_asset_manager; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var RequestInterface $request |
|
33 | + */ |
|
34 | + protected $request; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var array $attributes |
|
38 | + */ |
|
39 | + private $attributes; |
|
40 | + |
|
41 | + /** |
|
42 | + * If set to true, then the block will render its content client side |
|
43 | + * If false, then the block will render its content server side using the renderBlock() method |
|
44 | + * |
|
45 | + * @var bool $dynamic |
|
46 | + */ |
|
47 | + private $dynamic = false; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var string $block_type |
|
51 | + */ |
|
52 | + private $block_type; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var array $supported_routes |
|
56 | + */ |
|
57 | + private $supported_routes; |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Block constructor. |
|
62 | + * |
|
63 | + * @param BlockAssetManagerInterface $block_asset_manager |
|
64 | + * @param RequestInterface $request |
|
65 | + */ |
|
66 | + public function __construct(BlockAssetManagerInterface $block_asset_manager, RequestInterface $request) |
|
67 | + { |
|
68 | + $this->block_asset_manager = $block_asset_manager; |
|
69 | + $this->request = $request; |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public function blockType() |
|
77 | + { |
|
78 | + return $this->block_type; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function namespacedBlockType() |
|
86 | + { |
|
87 | + return Block::NAME_SPACE . '/' . $this->block_type; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @param string $block_type |
|
93 | + */ |
|
94 | + protected function setBlockType($block_type) |
|
95 | + { |
|
96 | + $this->block_type = $block_type; |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * BlockAssetManager that this editor block uses for asset registration |
|
102 | + * |
|
103 | + * @return BlockAssetManagerInterface |
|
104 | + */ |
|
105 | + public function assetManager() |
|
106 | + { |
|
107 | + return $this->block_asset_manager; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * returns an array of fully qualified class names |
|
113 | + * for RouteMatchSpecificationInterface objects |
|
114 | + * that specify routes that the block should be loaded for. |
|
115 | + * |
|
116 | + * @return array |
|
117 | + */ |
|
118 | + public function supportedRoutes() |
|
119 | + { |
|
120 | + return $this->supported_routes; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @param array $supported_routes |
|
126 | + */ |
|
127 | + protected function setSupportedRoutes(array $supported_routes) |
|
128 | + { |
|
129 | + $this->supported_routes = $supported_routes; |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * @return array |
|
135 | + */ |
|
136 | + public function attributes() |
|
137 | + { |
|
138 | + return $this->attributes; |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @param array $attributes |
|
144 | + */ |
|
145 | + public function setAttributes(array $attributes) |
|
146 | + { |
|
147 | + $this->attributes = $attributes; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * @return bool |
|
153 | + */ |
|
154 | + public function isDynamic() |
|
155 | + { |
|
156 | + return $this->dynamic; |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * @param bool $dynamic |
|
162 | + */ |
|
163 | + public function setDynamic($dynamic = true) |
|
164 | + { |
|
165 | + $this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * Registers the Editor Block with WP core; |
|
171 | + * Returns the registered block type on success, or false on failure. |
|
172 | + * |
|
173 | + * @return WP_Block_Type|false |
|
174 | + */ |
|
175 | + public function registerBlock() |
|
176 | + { |
|
177 | + $args = array( |
|
178 | + 'attributes' => $this->attributes(), |
|
179 | + 'editor_script' => $this->block_asset_manager->getEditorScriptHandle(), |
|
180 | + 'script' => $this->block_asset_manager->getScriptHandle(), |
|
181 | + ); |
|
182 | + if ($this->isDynamic()) { |
|
183 | + $args['render_callback'] = array($this, 'renderBlock'); |
|
184 | + } |
|
185 | + return register_block_type( |
|
186 | + new WP_Block_Type( |
|
187 | + $this->namespacedBlockType(), |
|
188 | + $args |
|
189 | + ) |
|
190 | + ); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * @return WP_Block_Type|false The registered block type on success, or false on failure. |
|
196 | + */ |
|
197 | + public function unRegisterBlock() |
|
198 | + { |
|
199 | + return unregister_block_type($this->namespacedBlockType()); |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * @return array |
|
206 | + */ |
|
207 | + public function getEditorContainer() |
|
208 | + { |
|
209 | + return array( |
|
210 | + $this->namespacedBlockType(), |
|
211 | + array(), |
|
212 | + ); |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * @since $VID:$ |
|
218 | + */ |
|
219 | + protected function loadGraphQLRelayAutoloader() |
|
220 | + { |
|
221 | + if (! class_exists('GraphQLRelay')) { |
|
222 | + $autoloader = EE_THIRD_PARTY . 'wp-graphql/vendor/autoload.php'; |
|
223 | + if (! file_exists($autoloader)) { |
|
224 | + return; |
|
225 | + } |
|
226 | + require_once $autoloader; |
|
227 | + } |
|
228 | + } |
|
229 | 229 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function namespacedBlockType() |
86 | 86 | { |
87 | - return Block::NAME_SPACE . '/' . $this->block_type; |
|
87 | + return Block::NAME_SPACE.'/'.$this->block_type; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | */ |
219 | 219 | protected function loadGraphQLRelayAutoloader() |
220 | 220 | { |
221 | - if (! class_exists('GraphQLRelay')) { |
|
222 | - $autoloader = EE_THIRD_PARTY . 'wp-graphql/vendor/autoload.php'; |
|
223 | - if (! file_exists($autoloader)) { |
|
221 | + if ( ! class_exists('GraphQLRelay')) { |
|
222 | + $autoloader = EE_THIRD_PARTY.'wp-graphql/vendor/autoload.php'; |
|
223 | + if ( ! file_exists($autoloader)) { |
|
224 | 224 | return; |
225 | 225 | } |
226 | 226 | require_once $autoloader; |
@@ -183,7 +183,7 @@ |
||
183 | 183 | $this->resolveDependenciesForClass($param_class); |
184 | 184 | } |
185 | 185 | $param_class = $this->resolveAlias($param_class); |
186 | - $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
186 | + $dependencies[$param_class] = EE_Dependency_Map::load_from_cache; |
|
187 | 187 | } |
188 | 188 | $this->dependencyMap()->registerDependencies($fqcn, $dependencies); |
189 | 189 | } |
@@ -23,168 +23,168 @@ |
||
23 | 23 | class DependencyResolver implements DependencyResolverInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var Mirror $mirror |
|
28 | - */ |
|
29 | - private $mirror; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var ClassInterfaceCache $class_cache |
|
33 | - */ |
|
34 | - protected $class_cache; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var EE_Dependency_Map $dependency_map |
|
38 | - */ |
|
39 | - private $dependency_map; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var ClassAlias[] $aliases |
|
43 | - */ |
|
44 | - protected $aliases = array(); |
|
45 | - |
|
46 | - /** |
|
47 | - * @var array $namespace_roots |
|
48 | - */ |
|
49 | - protected $namespace_roots = array(); |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * RouteMatchSpecificationDependencyResolver constructor. |
|
54 | - * |
|
55 | - * @param Mirror $mirror |
|
56 | - * @param ClassInterfaceCache $class_cache |
|
57 | - * @param EE_Dependency_Map $dependency_map |
|
58 | - */ |
|
59 | - public function __construct( |
|
60 | - Mirror $mirror, |
|
61 | - ClassInterfaceCache $class_cache, |
|
62 | - EE_Dependency_Map $dependency_map |
|
63 | - ) { |
|
64 | - $this->mirror = $mirror; |
|
65 | - $this->class_cache = $class_cache; |
|
66 | - $this->dependency_map = $dependency_map; |
|
67 | - $this->initialize(); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Used to configure and/or setup any aliases or namespace roots required by the DependencyResolver |
|
73 | - * |
|
74 | - * @throws InvalidAliasException |
|
75 | - * @since 4.9.71.p |
|
76 | - */ |
|
77 | - public function initialize() |
|
78 | - { |
|
79 | - // nothing to do here for default resolver |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @return Mirror |
|
85 | - */ |
|
86 | - public function mirror() |
|
87 | - { |
|
88 | - return $this->mirror; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @return ClassInterfaceCache |
|
93 | - */ |
|
94 | - public function classCache() |
|
95 | - { |
|
96 | - return $this->class_cache; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @return EE_Dependency_Map |
|
101 | - */ |
|
102 | - public function dependencyMap() |
|
103 | - { |
|
104 | - return $this->dependency_map; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
109 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
110 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
111 | - * @throws InvalidAliasException |
|
112 | - */ |
|
113 | - public function addAlias($fqcn, $alias, $for_class = '') |
|
114 | - { |
|
115 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function resolveAlias($param_fqcn) |
|
123 | - { |
|
124 | - return $this->class_cache->getFqnForAlias($param_fqcn); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Primarily used to indicate the namespace root for composite objects |
|
129 | - * so that dependencies requiring the same DependencyResolver can be acquired |
|
130 | - * for example: |
|
131 | - * Vendor\path\to\class\A, Vendor\path\to\class\B, and Vendor\path\to\class\C |
|
132 | - * may all implement Vendor\path\to\Interface, |
|
133 | - * but Vendor\path\to\class\C could be a composite object |
|
134 | - * that requires Vendor\path\to\class\A and Vendor\path\to\class\B, |
|
135 | - * and needs both of those dependencies resolved, which would therefore require |
|
136 | - * the use of the same DependencyResolver. |
|
137 | - * |
|
138 | - * By specifying a namespace root of "Vendor\path\to\", |
|
139 | - * then all classes that are descendants of that namespace |
|
140 | - * will use DependencyResolver to acquire the classes they need |
|
141 | - * |
|
142 | - * @param string $namespace_root Partial namespace used for detecting other classes |
|
143 | - * that should employ this same DependencyResolver |
|
144 | - */ |
|
145 | - public function addNamespaceRoot($namespace_root) |
|
146 | - { |
|
147 | - $this->namespace_roots[] = $namespace_root; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Returns true if the parameter FQCN belongs to one of |
|
152 | - * the namespaces that utilizes this DependencyResolver |
|
153 | - * |
|
154 | - * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
155 | - * @return boolean |
|
156 | - * @since 4.9.71.p |
|
157 | - */ |
|
158 | - public function dependencyRecursionExists($param_fqcn) |
|
159 | - { |
|
160 | - foreach ($this->namespace_roots as $namespace_root) { |
|
161 | - if (strpos($param_fqcn, $namespace_root) !== false) { |
|
162 | - return true; |
|
163 | - } |
|
164 | - } |
|
165 | - return false; |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @param string $fqcn Fully Qualified Class Name |
|
171 | - * @throws InvalidDataTypeException |
|
172 | - * @throws ReflectionException |
|
173 | - * @since 4.9.71.p |
|
174 | - */ |
|
175 | - public function resolveDependenciesForClass($fqcn) |
|
176 | - { |
|
177 | - $dependencies = array(); |
|
178 | - $params = $this->mirror()->getParameters($fqcn); |
|
179 | - foreach ($params as $index => $param) { |
|
180 | - // is this a dependency for a specific class ? |
|
181 | - $param_class = $this->mirror()->getParameterClassName($param, $fqcn, $index); |
|
182 | - if ($this->dependencyRecursionExists($param_class)) { |
|
183 | - $this->resolveDependenciesForClass($param_class); |
|
184 | - } |
|
185 | - $param_class = $this->resolveAlias($param_class); |
|
186 | - $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
187 | - } |
|
188 | - $this->dependencyMap()->registerDependencies($fqcn, $dependencies); |
|
189 | - } |
|
26 | + /** |
|
27 | + * @var Mirror $mirror |
|
28 | + */ |
|
29 | + private $mirror; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var ClassInterfaceCache $class_cache |
|
33 | + */ |
|
34 | + protected $class_cache; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var EE_Dependency_Map $dependency_map |
|
38 | + */ |
|
39 | + private $dependency_map; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var ClassAlias[] $aliases |
|
43 | + */ |
|
44 | + protected $aliases = array(); |
|
45 | + |
|
46 | + /** |
|
47 | + * @var array $namespace_roots |
|
48 | + */ |
|
49 | + protected $namespace_roots = array(); |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * RouteMatchSpecificationDependencyResolver constructor. |
|
54 | + * |
|
55 | + * @param Mirror $mirror |
|
56 | + * @param ClassInterfaceCache $class_cache |
|
57 | + * @param EE_Dependency_Map $dependency_map |
|
58 | + */ |
|
59 | + public function __construct( |
|
60 | + Mirror $mirror, |
|
61 | + ClassInterfaceCache $class_cache, |
|
62 | + EE_Dependency_Map $dependency_map |
|
63 | + ) { |
|
64 | + $this->mirror = $mirror; |
|
65 | + $this->class_cache = $class_cache; |
|
66 | + $this->dependency_map = $dependency_map; |
|
67 | + $this->initialize(); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Used to configure and/or setup any aliases or namespace roots required by the DependencyResolver |
|
73 | + * |
|
74 | + * @throws InvalidAliasException |
|
75 | + * @since 4.9.71.p |
|
76 | + */ |
|
77 | + public function initialize() |
|
78 | + { |
|
79 | + // nothing to do here for default resolver |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @return Mirror |
|
85 | + */ |
|
86 | + public function mirror() |
|
87 | + { |
|
88 | + return $this->mirror; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @return ClassInterfaceCache |
|
93 | + */ |
|
94 | + public function classCache() |
|
95 | + { |
|
96 | + return $this->class_cache; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @return EE_Dependency_Map |
|
101 | + */ |
|
102 | + public function dependencyMap() |
|
103 | + { |
|
104 | + return $this->dependency_map; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
109 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
110 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
111 | + * @throws InvalidAliasException |
|
112 | + */ |
|
113 | + public function addAlias($fqcn, $alias, $for_class = '') |
|
114 | + { |
|
115 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function resolveAlias($param_fqcn) |
|
123 | + { |
|
124 | + return $this->class_cache->getFqnForAlias($param_fqcn); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Primarily used to indicate the namespace root for composite objects |
|
129 | + * so that dependencies requiring the same DependencyResolver can be acquired |
|
130 | + * for example: |
|
131 | + * Vendor\path\to\class\A, Vendor\path\to\class\B, and Vendor\path\to\class\C |
|
132 | + * may all implement Vendor\path\to\Interface, |
|
133 | + * but Vendor\path\to\class\C could be a composite object |
|
134 | + * that requires Vendor\path\to\class\A and Vendor\path\to\class\B, |
|
135 | + * and needs both of those dependencies resolved, which would therefore require |
|
136 | + * the use of the same DependencyResolver. |
|
137 | + * |
|
138 | + * By specifying a namespace root of "Vendor\path\to\", |
|
139 | + * then all classes that are descendants of that namespace |
|
140 | + * will use DependencyResolver to acquire the classes they need |
|
141 | + * |
|
142 | + * @param string $namespace_root Partial namespace used for detecting other classes |
|
143 | + * that should employ this same DependencyResolver |
|
144 | + */ |
|
145 | + public function addNamespaceRoot($namespace_root) |
|
146 | + { |
|
147 | + $this->namespace_roots[] = $namespace_root; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Returns true if the parameter FQCN belongs to one of |
|
152 | + * the namespaces that utilizes this DependencyResolver |
|
153 | + * |
|
154 | + * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
155 | + * @return boolean |
|
156 | + * @since 4.9.71.p |
|
157 | + */ |
|
158 | + public function dependencyRecursionExists($param_fqcn) |
|
159 | + { |
|
160 | + foreach ($this->namespace_roots as $namespace_root) { |
|
161 | + if (strpos($param_fqcn, $namespace_root) !== false) { |
|
162 | + return true; |
|
163 | + } |
|
164 | + } |
|
165 | + return false; |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @param string $fqcn Fully Qualified Class Name |
|
171 | + * @throws InvalidDataTypeException |
|
172 | + * @throws ReflectionException |
|
173 | + * @since 4.9.71.p |
|
174 | + */ |
|
175 | + public function resolveDependenciesForClass($fqcn) |
|
176 | + { |
|
177 | + $dependencies = array(); |
|
178 | + $params = $this->mirror()->getParameters($fqcn); |
|
179 | + foreach ($params as $index => $param) { |
|
180 | + // is this a dependency for a specific class ? |
|
181 | + $param_class = $this->mirror()->getParameterClassName($param, $fqcn, $index); |
|
182 | + if ($this->dependencyRecursionExists($param_class)) { |
|
183 | + $this->resolveDependenciesForClass($param_class); |
|
184 | + } |
|
185 | + $param_class = $this->resolveAlias($param_class); |
|
186 | + $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
187 | + } |
|
188 | + $this->dependencyMap()->registerDependencies($fqcn, $dependencies); |
|
189 | + } |
|
190 | 190 | } |