@@ -15,66 +15,66 @@ |
||
15 | 15 | class CapCheck implements CapCheckInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var string|array $capability |
|
20 | - */ |
|
21 | - private $capability; |
|
18 | + /** |
|
19 | + * @var string|array $capability |
|
20 | + */ |
|
21 | + private $capability; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var string $context |
|
25 | - */ |
|
26 | - private $context; |
|
23 | + /** |
|
24 | + * @var string $context |
|
25 | + */ |
|
26 | + private $context; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var int|string $ID |
|
30 | - */ |
|
31 | - private $ID; |
|
28 | + /** |
|
29 | + * @var int|string $ID |
|
30 | + */ |
|
31 | + private $ID; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
36 | - * or an array of capability strings |
|
37 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
38 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
39 | - * @throws InvalidDataTypeException |
|
40 | - */ |
|
41 | - public function __construct($capability, $context, $ID = 0) |
|
42 | - { |
|
43 | - if (! (is_string($capability) || is_array($capability))) { |
|
44 | - throw new InvalidDataTypeException('$capability', $capability, 'string or array'); |
|
45 | - } |
|
46 | - if (! is_string($context)) { |
|
47 | - throw new InvalidDataTypeException('$context', $context, 'string'); |
|
48 | - } |
|
49 | - $this->capability = $capability; |
|
50 | - $this->context = strtolower(str_replace(' ', '_', $context)); |
|
51 | - $this->ID = $ID; |
|
52 | - } |
|
34 | + /** |
|
35 | + * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
36 | + * or an array of capability strings |
|
37 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
38 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
39 | + * @throws InvalidDataTypeException |
|
40 | + */ |
|
41 | + public function __construct($capability, $context, $ID = 0) |
|
42 | + { |
|
43 | + if (! (is_string($capability) || is_array($capability))) { |
|
44 | + throw new InvalidDataTypeException('$capability', $capability, 'string or array'); |
|
45 | + } |
|
46 | + if (! is_string($context)) { |
|
47 | + throw new InvalidDataTypeException('$context', $context, 'string'); |
|
48 | + } |
|
49 | + $this->capability = $capability; |
|
50 | + $this->context = strtolower(str_replace(' ', '_', $context)); |
|
51 | + $this->ID = $ID; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * @return string|array |
|
57 | - */ |
|
58 | - public function capability() |
|
59 | - { |
|
60 | - return $this->capability; |
|
61 | - } |
|
55 | + /** |
|
56 | + * @return string|array |
|
57 | + */ |
|
58 | + public function capability() |
|
59 | + { |
|
60 | + return $this->capability; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function context() |
|
68 | - { |
|
69 | - return $this->context; |
|
70 | - } |
|
64 | + /** |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function context() |
|
68 | + { |
|
69 | + return $this->context; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * @return int|string |
|
75 | - */ |
|
76 | - public function ID() |
|
77 | - { |
|
78 | - return $this->ID; |
|
79 | - } |
|
73 | + /** |
|
74 | + * @return int|string |
|
75 | + */ |
|
76 | + public function ID() |
|
77 | + { |
|
78 | + return $this->ID; |
|
79 | + } |
|
80 | 80 | } |
@@ -40,10 +40,10 @@ |
||
40 | 40 | */ |
41 | 41 | public function __construct($capability, $context, $ID = 0) |
42 | 42 | { |
43 | - if (! (is_string($capability) || is_array($capability))) { |
|
43 | + if ( ! (is_string($capability) || is_array($capability))) { |
|
44 | 44 | throw new InvalidDataTypeException('$capability', $capability, 'string or array'); |
45 | 45 | } |
46 | - if (! is_string($context)) { |
|
46 | + if ( ! is_string($context)) { |
|
47 | 47 | throw new InvalidDataTypeException('$context', $context, 'string'); |
48 | 48 | } |
49 | 49 | $this->capability = $capability; |
@@ -19,19 +19,19 @@ |
||
19 | 19 | class EmailAddressFactory implements FactoryInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @param string $email_address |
|
24 | - * @return EmailAddress |
|
25 | - * @throws EmailValidationException |
|
26 | - * @throws InvalidDataTypeException |
|
27 | - * @throws InvalidInterfaceException |
|
28 | - * @throws InvalidArgumentException |
|
29 | - */ |
|
30 | - public static function create($email_address) |
|
31 | - { |
|
32 | - return LoaderFactory::getLoader()->getNew( |
|
33 | - 'EventEspresso\core\domain\values\EmailAddress', |
|
34 | - array($email_address) |
|
35 | - ); |
|
36 | - } |
|
22 | + /** |
|
23 | + * @param string $email_address |
|
24 | + * @return EmailAddress |
|
25 | + * @throws EmailValidationException |
|
26 | + * @throws InvalidDataTypeException |
|
27 | + * @throws InvalidInterfaceException |
|
28 | + * @throws InvalidArgumentException |
|
29 | + */ |
|
30 | + public static function create($email_address) |
|
31 | + { |
|
32 | + return LoaderFactory::getLoader()->getNew( |
|
33 | + 'EventEspresso\core\domain\values\EmailAddress', |
|
34 | + array($email_address) |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | } |
@@ -16,41 +16,41 @@ |
||
16 | 16 | class CreateTicketLineItemService extends DomainService |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param \EE_Transaction $transaction |
|
21 | - * @param \EE_Ticket $ticket |
|
22 | - * @param int $quantity |
|
23 | - * @return \EE_Line_Item |
|
24 | - * @throws \EE_Error |
|
25 | - * @throws UnexpectedEntityException |
|
26 | - */ |
|
27 | - public function create( |
|
28 | - \EE_Transaction $transaction, |
|
29 | - \EE_Ticket $ticket, |
|
30 | - $quantity = 1 |
|
31 | - ) { |
|
32 | - $total_line_item = $transaction->total_line_item(); |
|
33 | - if (! $total_line_item instanceof \EE_Line_Item) { |
|
34 | - throw new UnexpectedEntityException($total_line_item, 'EE_Line_Item'); |
|
35 | - } |
|
36 | - // create new line item for ticket |
|
37 | - $ticket_line_item = \EEH_Line_Item::add_ticket_purchase( |
|
38 | - $total_line_item, |
|
39 | - $ticket, |
|
40 | - $quantity |
|
41 | - ); |
|
42 | - if (! $ticket_line_item instanceof \EE_Line_Item) { |
|
43 | - throw new UnexpectedEntityException($ticket_line_item, 'EE_Line_Item'); |
|
44 | - } |
|
45 | - $total_line_item->save_this_and_descendants_to_txn($transaction->ID()); |
|
46 | - // apply any applicable promotions that were initially used during registration to new line items |
|
47 | - do_action( |
|
48 | - 'AHEE__\EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler__handle__new_ticket_line_item_added', |
|
49 | - $total_line_item, |
|
50 | - $ticket, |
|
51 | - $transaction, |
|
52 | - $quantity |
|
53 | - ); |
|
54 | - return $ticket_line_item; |
|
55 | - } |
|
19 | + /** |
|
20 | + * @param \EE_Transaction $transaction |
|
21 | + * @param \EE_Ticket $ticket |
|
22 | + * @param int $quantity |
|
23 | + * @return \EE_Line_Item |
|
24 | + * @throws \EE_Error |
|
25 | + * @throws UnexpectedEntityException |
|
26 | + */ |
|
27 | + public function create( |
|
28 | + \EE_Transaction $transaction, |
|
29 | + \EE_Ticket $ticket, |
|
30 | + $quantity = 1 |
|
31 | + ) { |
|
32 | + $total_line_item = $transaction->total_line_item(); |
|
33 | + if (! $total_line_item instanceof \EE_Line_Item) { |
|
34 | + throw new UnexpectedEntityException($total_line_item, 'EE_Line_Item'); |
|
35 | + } |
|
36 | + // create new line item for ticket |
|
37 | + $ticket_line_item = \EEH_Line_Item::add_ticket_purchase( |
|
38 | + $total_line_item, |
|
39 | + $ticket, |
|
40 | + $quantity |
|
41 | + ); |
|
42 | + if (! $ticket_line_item instanceof \EE_Line_Item) { |
|
43 | + throw new UnexpectedEntityException($ticket_line_item, 'EE_Line_Item'); |
|
44 | + } |
|
45 | + $total_line_item->save_this_and_descendants_to_txn($transaction->ID()); |
|
46 | + // apply any applicable promotions that were initially used during registration to new line items |
|
47 | + do_action( |
|
48 | + 'AHEE__\EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler__handle__new_ticket_line_item_added', |
|
49 | + $total_line_item, |
|
50 | + $ticket, |
|
51 | + $transaction, |
|
52 | + $quantity |
|
53 | + ); |
|
54 | + return $ticket_line_item; |
|
55 | + } |
|
56 | 56 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $quantity = 1 |
31 | 31 | ) { |
32 | 32 | $total_line_item = $transaction->total_line_item(); |
33 | - if (! $total_line_item instanceof \EE_Line_Item) { |
|
33 | + if ( ! $total_line_item instanceof \EE_Line_Item) { |
|
34 | 34 | throw new UnexpectedEntityException($total_line_item, 'EE_Line_Item'); |
35 | 35 | } |
36 | 36 | // create new line item for ticket |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $ticket, |
40 | 40 | $quantity |
41 | 41 | ); |
42 | - if (! $ticket_line_item instanceof \EE_Line_Item) { |
|
42 | + if ( ! $ticket_line_item instanceof \EE_Line_Item) { |
|
43 | 43 | throw new UnexpectedEntityException($ticket_line_item, 'EE_Line_Item'); |
44 | 44 | } |
45 | 45 | $total_line_item->save_this_and_descendants_to_txn($transaction->ID()); |
@@ -17,47 +17,47 @@ discard block |
||
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, 3); |
|
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, 3); |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Callback for `after_plugin_row` to add upsell info |
|
50 | - * |
|
51 | - * @param string $plugin_file |
|
52 | - * @param array $plugin_data |
|
53 | - * @param string $status |
|
54 | - * @throws DomainException |
|
55 | - */ |
|
56 | - public function doPremiumUpsell($plugin_file, $plugin_data, $status) |
|
57 | - { |
|
58 | - if ($plugin_file === $this->domain->pluginBasename()) { |
|
59 | - list($button_text, $button_url, $upsell_text) = $this->getAfterPluginRowDetails(); |
|
60 | - echo '<tr class="plugin-update-tr ee-upsell-plugin-list-table active"> |
|
48 | + /** |
|
49 | + * Callback for `after_plugin_row` to add upsell info |
|
50 | + * |
|
51 | + * @param string $plugin_file |
|
52 | + * @param array $plugin_data |
|
53 | + * @param string $status |
|
54 | + * @throws DomainException |
|
55 | + */ |
|
56 | + public function doPremiumUpsell($plugin_file, $plugin_data, $status) |
|
57 | + { |
|
58 | + if ($plugin_file === $this->domain->pluginBasename()) { |
|
59 | + list($button_text, $button_url, $upsell_text) = $this->getAfterPluginRowDetails(); |
|
60 | + echo '<tr class="plugin-update-tr ee-upsell-plugin-list-table active"> |
|
61 | 61 | <td colspan="3" class="plugin-update colspanchange"> |
62 | 62 | <div class="notice inline notice-alt"> |
63 | 63 | <div class="ee-upsell-container"> |
@@ -74,27 +74,27 @@ discard block |
||
74 | 74 | </div> |
75 | 75 | </td> |
76 | 76 | </tr>'; |
77 | - } |
|
78 | - } |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Provide the details used for the upsell container. |
|
82 | - * |
|
83 | - * @return array |
|
84 | - */ |
|
85 | - protected function getAfterPluginRowDetails() |
|
86 | - { |
|
87 | - return array( |
|
88 | - esc_html__('Upgrade for Support', 'event_espresso'), |
|
89 | - 'https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link" class="button button-primary', |
|
90 | - sprintf( |
|
91 | - esc_html__( |
|
92 | - 'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s! Don\'t have an Event Espresso support license key? Support the project and buy one today!', |
|
93 | - 'event_espresso' |
|
94 | - ), |
|
95 | - '<strong>', |
|
96 | - '</strong>' |
|
97 | - ), |
|
98 | - ); |
|
99 | - } |
|
80 | + /** |
|
81 | + * Provide the details used for the upsell container. |
|
82 | + * |
|
83 | + * @return array |
|
84 | + */ |
|
85 | + protected function getAfterPluginRowDetails() |
|
86 | + { |
|
87 | + return array( |
|
88 | + esc_html__('Upgrade for Support', 'event_espresso'), |
|
89 | + 'https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link" class="button button-primary', |
|
90 | + sprintf( |
|
91 | + esc_html__( |
|
92 | + 'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s! Don\'t have an Event Espresso support license key? Support the project and buy one today!', |
|
93 | + 'event_espresso' |
|
94 | + ), |
|
95 | + '<strong>', |
|
96 | + '</strong>' |
|
97 | + ), |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | } |
@@ -62,12 +62,12 @@ |
||
62 | 62 | <div class="notice inline notice-alt"> |
63 | 63 | <div class="ee-upsell-container"> |
64 | 64 | <div class="ee-upsell-inner-container"> |
65 | - <a href="' . esc_url_raw($button_url) . '"> |
|
66 | - ' . $button_text /* already escaped */ . ' |
|
65 | + <a href="' . esc_url_raw($button_url).'"> |
|
66 | + ' . $button_text /* already escaped */.' |
|
67 | 67 | </a> |
68 | 68 | </div> |
69 | 69 | <div class="ee-upsell-inner-container"> |
70 | - <p>' . $upsell_text /* already escaped */ . '</p> |
|
70 | + <p>' . $upsell_text /* already escaped */.'</p> |
|
71 | 71 | </div> |
72 | 72 | <div style="clear:both"></div> |
73 | 73 | </div> |
@@ -4,31 +4,31 @@ |
||
4 | 4 | interface SetHooksInterface |
5 | 5 | { |
6 | 6 | |
7 | - /** |
|
8 | - * a place to add action and filter hooks for regular frontend requests |
|
9 | - * |
|
10 | - * @return void |
|
11 | - */ |
|
12 | - public function setHooks(); |
|
7 | + /** |
|
8 | + * a place to add action and filter hooks for regular frontend requests |
|
9 | + * |
|
10 | + * @return void |
|
11 | + */ |
|
12 | + public function setHooks(); |
|
13 | 13 | |
14 | - /** |
|
15 | - * a place to add action and filter hooks for regular WP admin requests |
|
16 | - * |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function setAdminHooks(); |
|
14 | + /** |
|
15 | + * a place to add action and filter hooks for regular WP admin requests |
|
16 | + * |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function setAdminHooks(); |
|
20 | 20 | |
21 | - /** |
|
22 | - * a place to add action and filter hooks for AJAX requests |
|
23 | - * |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function setAjaxHooks(); |
|
21 | + /** |
|
22 | + * a place to add action and filter hooks for AJAX requests |
|
23 | + * |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function setAjaxHooks(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * a place to add action and filter hooks for REST API requests |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function setApiHooks(); |
|
28 | + /** |
|
29 | + * a place to add action and filter hooks for REST API requests |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function setApiHooks(); |
|
34 | 34 | } |
@@ -16,13 +16,13 @@ |
||
16 | 16 | interface RequiresDependencyMapInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param EE_Dependency_Map $dependency_map |
|
21 | - */ |
|
22 | - public function setDependencyMap($dependency_map); |
|
19 | + /** |
|
20 | + * @param EE_Dependency_Map $dependency_map |
|
21 | + */ |
|
22 | + public function setDependencyMap($dependency_map); |
|
23 | 23 | |
24 | - /** |
|
25 | - * @return EE_Dependency_Map |
|
26 | - */ |
|
27 | - public function dependencyMap(); |
|
24 | + /** |
|
25 | + * @return EE_Dependency_Map |
|
26 | + */ |
|
27 | + public function dependencyMap(); |
|
28 | 28 | } |
@@ -13,14 +13,14 @@ |
||
13 | 13 | interface RequiresDomainInterface |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param DomainInterface $domain |
|
18 | - */ |
|
19 | - public function setDomain(DomainInterface $domain); |
|
16 | + /** |
|
17 | + * @param DomainInterface $domain |
|
18 | + */ |
|
19 | + public function setDomain(DomainInterface $domain); |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @return DomainInterface |
|
24 | - */ |
|
25 | - public function domain(); |
|
22 | + /** |
|
23 | + * @return DomainInterface |
|
24 | + */ |
|
25 | + public function domain(); |
|
26 | 26 | } |
@@ -14,34 +14,34 @@ |
||
14 | 14 | */ |
15 | 15 | interface CapabilitiesActionRestrictionInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * Return whether the item can be edited for the given context. |
|
19 | - * @param Context $context |
|
20 | - * @return bool |
|
21 | - */ |
|
22 | - public function canEdit(Context $context); |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * Return whether the item can be read for the given context. |
|
27 | - * @param Context $context |
|
28 | - * @return bool |
|
29 | - */ |
|
30 | - public function canRead(Context $context); |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Return whether the item can be deleted for the given context. |
|
35 | - * @param Context $context |
|
36 | - * @return bool |
|
37 | - */ |
|
38 | - public function canDelete(Context $context); |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Return whether the item can be created for the given context |
|
43 | - * @param Context $context |
|
44 | - * @return bool |
|
45 | - */ |
|
46 | - public function canCreate(Context $context); |
|
17 | + /** |
|
18 | + * Return whether the item can be edited for the given context. |
|
19 | + * @param Context $context |
|
20 | + * @return bool |
|
21 | + */ |
|
22 | + public function canEdit(Context $context); |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * Return whether the item can be read for the given context. |
|
27 | + * @param Context $context |
|
28 | + * @return bool |
|
29 | + */ |
|
30 | + public function canRead(Context $context); |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Return whether the item can be deleted for the given context. |
|
35 | + * @param Context $context |
|
36 | + * @return bool |
|
37 | + */ |
|
38 | + public function canDelete(Context $context); |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Return whether the item can be created for the given context |
|
43 | + * @param Context $context |
|
44 | + * @return bool |
|
45 | + */ |
|
46 | + public function canCreate(Context $context); |
|
47 | 47 | } |
@@ -20,98 +20,98 @@ |
||
20 | 20 | class SessionLifespan |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * how long an EE session lasts in seconds |
|
25 | - * default session lifespan of 1 hour (for not so instant IPNs) |
|
26 | - * |
|
27 | - * @var int $lifespan |
|
28 | - */ |
|
29 | - private $lifespan; |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * SessionLifespan constructor. |
|
34 | - * |
|
35 | - * @param int $lifespan |
|
36 | - * @throws DomainException |
|
37 | - */ |
|
38 | - public function __construct($lifespan = 0) |
|
39 | - { |
|
40 | - $lifespan = absint($lifespan); |
|
41 | - $lifespan = $lifespan > 0 ? $lifespan : (int) HOUR_IN_SECONDS; |
|
42 | - $this->setLifespan($lifespan); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @param int $lifespan |
|
48 | - * @throws DomainException |
|
49 | - */ |
|
50 | - protected function setLifespan($lifespan) |
|
51 | - { |
|
52 | - if ($lifespan < 60) { |
|
53 | - throw new DomainException( |
|
54 | - esc_html__( |
|
55 | - 'The session lifespan needs to be at least 60 seconds, and even that is extremely short', |
|
56 | - 'event_espresso' |
|
57 | - ) |
|
58 | - ); |
|
59 | - } |
|
60 | - $this->lifespan = apply_filters( |
|
61 | - 'FHEE__EventEspresso_core_domain_values_session_SessionLifespan__setLifespan___lifespan', |
|
62 | - // apply legacy filter for now but add doing it wrong notice in future |
|
63 | - apply_filters( |
|
64 | - 'FHEE__EE_Session__construct___lifespan', |
|
65 | - $lifespan |
|
66 | - ) |
|
67 | - ) + 1; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return int |
|
73 | - */ |
|
74 | - public function inSeconds() |
|
75 | - { |
|
76 | - return $this->lifespan; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @param string $separator |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function inHoursMinutesSeconds($separator = ':') |
|
85 | - { |
|
86 | - return sprintf( |
|
87 | - '%02d%s%02d%s%02d', |
|
88 | - floor($this->lifespan / 3600), |
|
89 | - $separator, |
|
90 | - ($this->lifespan / 60) % 60, |
|
91 | - $separator, |
|
92 | - $this->lifespan % 60 |
|
93 | - ); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * Returns a timestamp for when the session would expire based on this lifespan |
|
99 | - * |
|
100 | - * @param bool $utc If true, displays expiration in UTC |
|
101 | - * If false, displays expiration in local time |
|
102 | - * @return int |
|
103 | - */ |
|
104 | - public function expiration($utc = true) |
|
105 | - { |
|
106 | - return (int) current_time('timestamp', $utc) - $this->lifespan; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @return string |
|
112 | - */ |
|
113 | - public function __toString() |
|
114 | - { |
|
115 | - return (string) $this->inSeconds(); |
|
116 | - } |
|
23 | + /** |
|
24 | + * how long an EE session lasts in seconds |
|
25 | + * default session lifespan of 1 hour (for not so instant IPNs) |
|
26 | + * |
|
27 | + * @var int $lifespan |
|
28 | + */ |
|
29 | + private $lifespan; |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * SessionLifespan constructor. |
|
34 | + * |
|
35 | + * @param int $lifespan |
|
36 | + * @throws DomainException |
|
37 | + */ |
|
38 | + public function __construct($lifespan = 0) |
|
39 | + { |
|
40 | + $lifespan = absint($lifespan); |
|
41 | + $lifespan = $lifespan > 0 ? $lifespan : (int) HOUR_IN_SECONDS; |
|
42 | + $this->setLifespan($lifespan); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @param int $lifespan |
|
48 | + * @throws DomainException |
|
49 | + */ |
|
50 | + protected function setLifespan($lifespan) |
|
51 | + { |
|
52 | + if ($lifespan < 60) { |
|
53 | + throw new DomainException( |
|
54 | + esc_html__( |
|
55 | + 'The session lifespan needs to be at least 60 seconds, and even that is extremely short', |
|
56 | + 'event_espresso' |
|
57 | + ) |
|
58 | + ); |
|
59 | + } |
|
60 | + $this->lifespan = apply_filters( |
|
61 | + 'FHEE__EventEspresso_core_domain_values_session_SessionLifespan__setLifespan___lifespan', |
|
62 | + // apply legacy filter for now but add doing it wrong notice in future |
|
63 | + apply_filters( |
|
64 | + 'FHEE__EE_Session__construct___lifespan', |
|
65 | + $lifespan |
|
66 | + ) |
|
67 | + ) + 1; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return int |
|
73 | + */ |
|
74 | + public function inSeconds() |
|
75 | + { |
|
76 | + return $this->lifespan; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @param string $separator |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function inHoursMinutesSeconds($separator = ':') |
|
85 | + { |
|
86 | + return sprintf( |
|
87 | + '%02d%s%02d%s%02d', |
|
88 | + floor($this->lifespan / 3600), |
|
89 | + $separator, |
|
90 | + ($this->lifespan / 60) % 60, |
|
91 | + $separator, |
|
92 | + $this->lifespan % 60 |
|
93 | + ); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * Returns a timestamp for when the session would expire based on this lifespan |
|
99 | + * |
|
100 | + * @param bool $utc If true, displays expiration in UTC |
|
101 | + * If false, displays expiration in local time |
|
102 | + * @return int |
|
103 | + */ |
|
104 | + public function expiration($utc = true) |
|
105 | + { |
|
106 | + return (int) current_time('timestamp', $utc) - $this->lifespan; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @return string |
|
112 | + */ |
|
113 | + public function __toString() |
|
114 | + { |
|
115 | + return (string) $this->inSeconds(); |
|
116 | + } |
|
117 | 117 | } |