@@ -12,26 +12,26 @@ |
||
| 12 | 12 | class ServiceNotFoundException extends \RuntimeException |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * ServiceNotFoundException constructor |
|
| 17 | - * |
|
| 18 | - * @param string $service_name the name of the requested service |
|
| 19 | - * @param string $message |
|
| 20 | - * @param int $code |
|
| 21 | - * @param \Exception $previous |
|
| 22 | - */ |
|
| 23 | - public function __construct( |
|
| 24 | - $service_name, |
|
| 25 | - $message = '', |
|
| 26 | - $code = 0, |
|
| 27 | - \Exception $previous = null |
|
| 28 | - ) { |
|
| 29 | - if (empty($message)) { |
|
| 30 | - $message = sprintf( |
|
| 31 | - __('The requested service "%1$s" could not found be found in the CoffeeShop.', 'event_espresso'), |
|
| 32 | - $service_name |
|
| 33 | - ); |
|
| 34 | - } |
|
| 35 | - parent::__construct($message, $code, $previous); |
|
| 36 | - } |
|
| 15 | + /** |
|
| 16 | + * ServiceNotFoundException constructor |
|
| 17 | + * |
|
| 18 | + * @param string $service_name the name of the requested service |
|
| 19 | + * @param string $message |
|
| 20 | + * @param int $code |
|
| 21 | + * @param \Exception $previous |
|
| 22 | + */ |
|
| 23 | + public function __construct( |
|
| 24 | + $service_name, |
|
| 25 | + $message = '', |
|
| 26 | + $code = 0, |
|
| 27 | + \Exception $previous = null |
|
| 28 | + ) { |
|
| 29 | + if (empty($message)) { |
|
| 30 | + $message = sprintf( |
|
| 31 | + __('The requested service "%1$s" could not found be found in the CoffeeShop.', 'event_espresso'), |
|
| 32 | + $service_name |
|
| 33 | + ); |
|
| 34 | + } |
|
| 35 | + parent::__construct($message, $code, $previous); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -13,27 +13,27 @@ |
||
| 13 | 13 | class InvalidServiceException extends \UnexpectedValueException |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * InvalidServiceException constructor. |
|
| 18 | - * |
|
| 19 | - * @param string $service_name the name of the requested service |
|
| 20 | - * @param string $actual classname of what we got |
|
| 21 | - * @param string $message |
|
| 22 | - * @param int $code |
|
| 23 | - * @param \Exception $previous |
|
| 24 | - */ |
|
| 25 | - public function __construct($service_name, $actual, $message = '', $code = 0, \Exception $previous = null) |
|
| 26 | - { |
|
| 27 | - if (empty($message)) { |
|
| 28 | - $message = sprintf( |
|
| 29 | - __( |
|
| 30 | - 'The "%1$s" service could not be retrieved from the CoffeeShop, but "%2$s" was received.', |
|
| 31 | - 'event_espresso' |
|
| 32 | - ), |
|
| 33 | - $service_name, |
|
| 34 | - print_r($actual, true) |
|
| 35 | - ); |
|
| 36 | - } |
|
| 37 | - parent::__construct($message, $code, $previous); |
|
| 38 | - } |
|
| 16 | + /** |
|
| 17 | + * InvalidServiceException constructor. |
|
| 18 | + * |
|
| 19 | + * @param string $service_name the name of the requested service |
|
| 20 | + * @param string $actual classname of what we got |
|
| 21 | + * @param string $message |
|
| 22 | + * @param int $code |
|
| 23 | + * @param \Exception $previous |
|
| 24 | + */ |
|
| 25 | + public function __construct($service_name, $actual, $message = '', $code = 0, \Exception $previous = null) |
|
| 26 | + { |
|
| 27 | + if (empty($message)) { |
|
| 28 | + $message = sprintf( |
|
| 29 | + __( |
|
| 30 | + 'The "%1$s" service could not be retrieved from the CoffeeShop, but "%2$s" was received.', |
|
| 31 | + 'event_espresso' |
|
| 32 | + ), |
|
| 33 | + $service_name, |
|
| 34 | + print_r($actual, true) |
|
| 35 | + ); |
|
| 36 | + } |
|
| 37 | + parent::__construct($message, $code, $previous); |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -20,51 +20,51 @@ |
||
| 20 | 20 | { |
| 21 | 21 | |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @return string |
|
| 25 | - */ |
|
| 26 | - public function type() |
|
| 27 | - { |
|
| 28 | - return CoffeeMaker::BREW_NEW; |
|
| 29 | - } |
|
| 23 | + /** |
|
| 24 | + * @return string |
|
| 25 | + */ |
|
| 26 | + public function type() |
|
| 27 | + { |
|
| 28 | + return CoffeeMaker::BREW_NEW; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param RecipeInterface $recipe |
|
| 34 | - * @param array $arguments |
|
| 35 | - * @return mixed |
|
| 36 | - */ |
|
| 37 | - public function brew(RecipeInterface $recipe, $arguments = array()) |
|
| 38 | - { |
|
| 39 | - $this->resolveClassAndFilepath($recipe); |
|
| 40 | - $reflector = $this->injector()->getReflectionClass($recipe->fqcn()); |
|
| 41 | - $method = $this->resolveInstantiationMethod($reflector); |
|
| 42 | - switch ($method) { |
|
| 43 | - case 'instance': |
|
| 44 | - case 'new_instance': |
|
| 45 | - case 'new_instance_from_db': |
|
| 46 | - $injector = $this->injector(); |
|
| 47 | - $closure = function ($arguments) use ($recipe, $reflector, $method, $injector) { |
|
| 48 | - return call_user_func_array( |
|
| 49 | - array($reflector->getName(), $method), |
|
| 50 | - $injector->resolveDependencies($recipe, $reflector, $arguments) |
|
| 51 | - ); |
|
| 52 | - }; |
|
| 53 | - break; |
|
| 54 | - case 'newInstance': |
|
| 55 | - $closure = function () use ($reflector) { |
|
| 56 | - return $reflector->newInstance(); |
|
| 57 | - }; |
|
| 58 | - break; |
|
| 59 | - case 'newInstanceArgs': |
|
| 60 | - default: |
|
| 61 | - $injector = $this->injector(); |
|
| 62 | - $closure = function ($arguments) use ($recipe, $reflector, $injector) { |
|
| 63 | - return $reflector->newInstanceArgs( |
|
| 64 | - $injector->resolveDependencies($recipe, $reflector, $arguments) |
|
| 65 | - ); |
|
| 66 | - }; |
|
| 67 | - } |
|
| 68 | - return $this->coffeePot()->addClosure($recipe->identifier(), $closure); |
|
| 69 | - } |
|
| 32 | + /** |
|
| 33 | + * @param RecipeInterface $recipe |
|
| 34 | + * @param array $arguments |
|
| 35 | + * @return mixed |
|
| 36 | + */ |
|
| 37 | + public function brew(RecipeInterface $recipe, $arguments = array()) |
|
| 38 | + { |
|
| 39 | + $this->resolveClassAndFilepath($recipe); |
|
| 40 | + $reflector = $this->injector()->getReflectionClass($recipe->fqcn()); |
|
| 41 | + $method = $this->resolveInstantiationMethod($reflector); |
|
| 42 | + switch ($method) { |
|
| 43 | + case 'instance': |
|
| 44 | + case 'new_instance': |
|
| 45 | + case 'new_instance_from_db': |
|
| 46 | + $injector = $this->injector(); |
|
| 47 | + $closure = function ($arguments) use ($recipe, $reflector, $method, $injector) { |
|
| 48 | + return call_user_func_array( |
|
| 49 | + array($reflector->getName(), $method), |
|
| 50 | + $injector->resolveDependencies($recipe, $reflector, $arguments) |
|
| 51 | + ); |
|
| 52 | + }; |
|
| 53 | + break; |
|
| 54 | + case 'newInstance': |
|
| 55 | + $closure = function () use ($reflector) { |
|
| 56 | + return $reflector->newInstance(); |
|
| 57 | + }; |
|
| 58 | + break; |
|
| 59 | + case 'newInstanceArgs': |
|
| 60 | + default: |
|
| 61 | + $injector = $this->injector(); |
|
| 62 | + $closure = function ($arguments) use ($recipe, $reflector, $injector) { |
|
| 63 | + return $reflector->newInstanceArgs( |
|
| 64 | + $injector->resolveDependencies($recipe, $reflector, $arguments) |
|
| 65 | + ); |
|
| 66 | + }; |
|
| 67 | + } |
|
| 68 | + return $this->coffeePot()->addClosure($recipe->identifier(), $closure); |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | case 'new_instance': |
| 45 | 45 | case 'new_instance_from_db': |
| 46 | 46 | $injector = $this->injector(); |
| 47 | - $closure = function ($arguments) use ($recipe, $reflector, $method, $injector) { |
|
| 47 | + $closure = function($arguments) use ($recipe, $reflector, $method, $injector) { |
|
| 48 | 48 | return call_user_func_array( |
| 49 | 49 | array($reflector->getName(), $method), |
| 50 | 50 | $injector->resolveDependencies($recipe, $reflector, $arguments) |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | }; |
| 53 | 53 | break; |
| 54 | 54 | case 'newInstance': |
| 55 | - $closure = function () use ($reflector) { |
|
| 55 | + $closure = function() use ($reflector) { |
|
| 56 | 56 | return $reflector->newInstance(); |
| 57 | 57 | }; |
| 58 | 58 | break; |
| 59 | 59 | case 'newInstanceArgs': |
| 60 | 60 | default: |
| 61 | 61 | $injector = $this->injector(); |
| 62 | - $closure = function ($arguments) use ($recipe, $reflector, $injector) { |
|
| 62 | + $closure = function($arguments) use ($recipe, $reflector, $injector) { |
|
| 63 | 63 | return $reflector->newInstanceArgs( |
| 64 | 64 | $injector->resolveDependencies($recipe, $reflector, $arguments) |
| 65 | 65 | ); |
@@ -18,43 +18,43 @@ |
||
| 18 | 18 | { |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @return string |
|
| 23 | - */ |
|
| 24 | - public function type() |
|
| 25 | - { |
|
| 26 | - return CoffeeMaker::BREW_SHARED; |
|
| 27 | - } |
|
| 21 | + /** |
|
| 22 | + * @return string |
|
| 23 | + */ |
|
| 24 | + public function type() |
|
| 25 | + { |
|
| 26 | + return CoffeeMaker::BREW_SHARED; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @param RecipeInterface $recipe |
|
| 32 | - * @param array $arguments |
|
| 33 | - * @return mixed |
|
| 34 | - */ |
|
| 35 | - public function brew(RecipeInterface $recipe, $arguments = array()) |
|
| 36 | - { |
|
| 37 | - $this->resolveClassAndFilepath($recipe); |
|
| 38 | - $reflector = $this->injector()->getReflectionClass($recipe->fqcn()); |
|
| 39 | - $method = $this->resolveInstantiationMethod($reflector); |
|
| 40 | - switch ($method) { |
|
| 41 | - case 'instance': |
|
| 42 | - case 'new_instance': |
|
| 43 | - case 'new_instance_from_db': |
|
| 44 | - $service = call_user_func_array( |
|
| 45 | - array($reflector->getName(), $method), |
|
| 46 | - $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
| 47 | - ); |
|
| 48 | - break; |
|
| 49 | - case 'newInstance': |
|
| 50 | - $service = $reflector->newInstance(); |
|
| 51 | - break; |
|
| 52 | - case 'newInstanceArgs': |
|
| 53 | - default: |
|
| 54 | - $service = $reflector->newInstanceArgs( |
|
| 55 | - $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
| 56 | - ); |
|
| 57 | - } |
|
| 58 | - return $this->coffeePot()->addService($recipe->identifier(), $service); |
|
| 59 | - } |
|
| 30 | + /** |
|
| 31 | + * @param RecipeInterface $recipe |
|
| 32 | + * @param array $arguments |
|
| 33 | + * @return mixed |
|
| 34 | + */ |
|
| 35 | + public function brew(RecipeInterface $recipe, $arguments = array()) |
|
| 36 | + { |
|
| 37 | + $this->resolveClassAndFilepath($recipe); |
|
| 38 | + $reflector = $this->injector()->getReflectionClass($recipe->fqcn()); |
|
| 39 | + $method = $this->resolveInstantiationMethod($reflector); |
|
| 40 | + switch ($method) { |
|
| 41 | + case 'instance': |
|
| 42 | + case 'new_instance': |
|
| 43 | + case 'new_instance_from_db': |
|
| 44 | + $service = call_user_func_array( |
|
| 45 | + array($reflector->getName(), $method), |
|
| 46 | + $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
| 47 | + ); |
|
| 48 | + break; |
|
| 49 | + case 'newInstance': |
|
| 50 | + $service = $reflector->newInstance(); |
|
| 51 | + break; |
|
| 52 | + case 'newInstanceArgs': |
|
| 53 | + default: |
|
| 54 | + $service = $reflector->newInstanceArgs( |
|
| 55 | + $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | + return $this->coffeePot()->addService($recipe->identifier(), $service); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -21,23 +21,23 @@ |
||
| 21 | 21 | class LoadOnlyCoffeeMaker extends CoffeeMaker |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function type() |
|
| 28 | - { |
|
| 29 | - return CoffeeMaker::BREW_LOAD_ONLY; |
|
| 30 | - } |
|
| 24 | + /** |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function type() |
|
| 28 | + { |
|
| 29 | + return CoffeeMaker::BREW_LOAD_ONLY; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param RecipeInterface $recipe |
|
| 35 | - * @param array $arguments |
|
| 36 | - * @return mixed |
|
| 37 | - * @throws InvalidClassException |
|
| 38 | - */ |
|
| 39 | - public function brew(RecipeInterface $recipe, $arguments = array()) |
|
| 40 | - { |
|
| 41 | - return $this->resolveClassAndFilepath($recipe); |
|
| 42 | - } |
|
| 33 | + /** |
|
| 34 | + * @param RecipeInterface $recipe |
|
| 35 | + * @param array $arguments |
|
| 36 | + * @return mixed |
|
| 37 | + * @throws InvalidClassException |
|
| 38 | + */ |
|
| 39 | + public function brew(RecipeInterface $recipe, $arguments = array()) |
|
| 40 | + { |
|
| 41 | + return $this->resolveClassAndFilepath($recipe); |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -14,115 +14,115 @@ |
||
| 14 | 14 | class GatewayDataFormatter implements GatewayDataFormatterInterface |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Gets the text to use for a gateway's line item name when this is a partial payment |
|
| 19 | - * |
|
| 20 | - * @param \EEI_Payment $payment |
|
| 21 | - * @return string |
|
| 22 | - */ |
|
| 23 | - public function formatPartialPaymentLineItemName(\EEI_Payment $payment) |
|
| 24 | - { |
|
| 25 | - return apply_filters( |
|
| 26 | - 'EEG_Paypal_Pro__do_direct_payment__partial_amount_line_item_name', |
|
| 27 | - $payment->get_first_event_name(), |
|
| 28 | - $this, |
|
| 29 | - $payment |
|
| 30 | - ); |
|
| 31 | - } |
|
| 17 | + /** |
|
| 18 | + * Gets the text to use for a gateway's line item name when this is a partial payment |
|
| 19 | + * |
|
| 20 | + * @param \EEI_Payment $payment |
|
| 21 | + * @return string |
|
| 22 | + */ |
|
| 23 | + public function formatPartialPaymentLineItemName(\EEI_Payment $payment) |
|
| 24 | + { |
|
| 25 | + return apply_filters( |
|
| 26 | + 'EEG_Paypal_Pro__do_direct_payment__partial_amount_line_item_name', |
|
| 27 | + $payment->get_first_event_name(), |
|
| 28 | + $this, |
|
| 29 | + $payment |
|
| 30 | + ); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Gets the text to use for a gateway's line item description when this is a partial payment |
|
| 36 | - * |
|
| 37 | - * @param \EEI_Payment $payment |
|
| 38 | - * @return string |
|
| 39 | - */ |
|
| 40 | - public function formatPartialPaymentLineItemDesc(\EEI_Payment $payment) |
|
| 41 | - { |
|
| 42 | - return apply_filters( |
|
| 43 | - 'FHEE__EE_Gateway___partial_payment_desc', |
|
| 44 | - sprintf( |
|
| 45 | - __('Payment of %1$s for %2$s', "event_espresso"), |
|
| 46 | - $payment->get_pretty('PAY_amount', 'no_currency_code'), |
|
| 47 | - $payment->get_first_event_name() |
|
| 48 | - ), |
|
| 49 | - $this, |
|
| 50 | - $payment |
|
| 51 | - ); |
|
| 52 | - } |
|
| 34 | + /** |
|
| 35 | + * Gets the text to use for a gateway's line item description when this is a partial payment |
|
| 36 | + * |
|
| 37 | + * @param \EEI_Payment $payment |
|
| 38 | + * @return string |
|
| 39 | + */ |
|
| 40 | + public function formatPartialPaymentLineItemDesc(\EEI_Payment $payment) |
|
| 41 | + { |
|
| 42 | + return apply_filters( |
|
| 43 | + 'FHEE__EE_Gateway___partial_payment_desc', |
|
| 44 | + sprintf( |
|
| 45 | + __('Payment of %1$s for %2$s', "event_espresso"), |
|
| 46 | + $payment->get_pretty('PAY_amount', 'no_currency_code'), |
|
| 47 | + $payment->get_first_event_name() |
|
| 48 | + ), |
|
| 49 | + $this, |
|
| 50 | + $payment |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Gets the name to use for a line item when sending line items to the gateway |
|
| 57 | - * |
|
| 58 | - * @param \EEI_Line_Item $line_item |
|
| 59 | - * @param \EEI_Payment $payment |
|
| 60 | - * @return string |
|
| 61 | - */ |
|
| 62 | - public function formatLineItemName(\EEI_Line_Item $line_item, \EEI_Payment $payment) |
|
| 63 | - { |
|
| 64 | - return apply_filters( |
|
| 65 | - 'FHEE__EE_gateway___line_item_name', |
|
| 66 | - sprintf( |
|
| 67 | - _x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), |
|
| 68 | - $line_item->name(), |
|
| 69 | - $line_item->ticket_event_name() |
|
| 70 | - ), |
|
| 71 | - $this, |
|
| 72 | - $line_item, |
|
| 73 | - $payment |
|
| 74 | - ); |
|
| 75 | - } |
|
| 55 | + /** |
|
| 56 | + * Gets the name to use for a line item when sending line items to the gateway |
|
| 57 | + * |
|
| 58 | + * @param \EEI_Line_Item $line_item |
|
| 59 | + * @param \EEI_Payment $payment |
|
| 60 | + * @return string |
|
| 61 | + */ |
|
| 62 | + public function formatLineItemName(\EEI_Line_Item $line_item, \EEI_Payment $payment) |
|
| 63 | + { |
|
| 64 | + return apply_filters( |
|
| 65 | + 'FHEE__EE_gateway___line_item_name', |
|
| 66 | + sprintf( |
|
| 67 | + _x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), |
|
| 68 | + $line_item->name(), |
|
| 69 | + $line_item->ticket_event_name() |
|
| 70 | + ), |
|
| 71 | + $this, |
|
| 72 | + $line_item, |
|
| 73 | + $payment |
|
| 74 | + ); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Gets the description to use for a line item when sending line items to the gateway |
|
| 80 | - * |
|
| 81 | - * @param \EEI_Line_Item $line_item |
|
| 82 | - * @param \EEI_Payment $payment |
|
| 83 | - * @return string |
|
| 84 | - */ |
|
| 85 | - public function formatLineItemDesc(\EEI_Line_Item $line_item, \EEI_Payment $payment) |
|
| 86 | - { |
|
| 87 | - return apply_filters( |
|
| 88 | - 'FHEE__EE_Gateway___line_item_desc', |
|
| 89 | - $line_item->desc(), |
|
| 90 | - $this, |
|
| 91 | - $line_item, |
|
| 92 | - $payment |
|
| 93 | - ); |
|
| 94 | - } |
|
| 78 | + /** |
|
| 79 | + * Gets the description to use for a line item when sending line items to the gateway |
|
| 80 | + * |
|
| 81 | + * @param \EEI_Line_Item $line_item |
|
| 82 | + * @param \EEI_Payment $payment |
|
| 83 | + * @return string |
|
| 84 | + */ |
|
| 85 | + public function formatLineItemDesc(\EEI_Line_Item $line_item, \EEI_Payment $payment) |
|
| 86 | + { |
|
| 87 | + return apply_filters( |
|
| 88 | + 'FHEE__EE_Gateway___line_item_desc', |
|
| 89 | + $line_item->desc(), |
|
| 90 | + $this, |
|
| 91 | + $line_item, |
|
| 92 | + $payment |
|
| 93 | + ); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Gets the order description that should generally be sent to gateways |
|
| 99 | - * |
|
| 100 | - * @param \EEI_Payment $payment |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - public function formatOrderDescription(\EEI_Payment $payment) |
|
| 104 | - { |
|
| 105 | - return apply_filters( |
|
| 106 | - 'FHEE__EE_Gateway___order_description', |
|
| 107 | - sprintf( |
|
| 108 | - __('Event Registrations from %1$s for %2$s', "event_espresso"), |
|
| 109 | - wp_specialchars_decode(get_bloginfo(), ENT_QUOTES), |
|
| 110 | - $payment->get_first_event_name() |
|
| 111 | - ), |
|
| 112 | - $this, |
|
| 113 | - $payment |
|
| 114 | - ); |
|
| 115 | - } |
|
| 97 | + /** |
|
| 98 | + * Gets the order description that should generally be sent to gateways |
|
| 99 | + * |
|
| 100 | + * @param \EEI_Payment $payment |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + public function formatOrderDescription(\EEI_Payment $payment) |
|
| 104 | + { |
|
| 105 | + return apply_filters( |
|
| 106 | + 'FHEE__EE_Gateway___order_description', |
|
| 107 | + sprintf( |
|
| 108 | + __('Event Registrations from %1$s for %2$s', "event_espresso"), |
|
| 109 | + wp_specialchars_decode(get_bloginfo(), ENT_QUOTES), |
|
| 110 | + $payment->get_first_event_name() |
|
| 111 | + ), |
|
| 112 | + $this, |
|
| 113 | + $payment |
|
| 114 | + ); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Formats the amount so it can generally be sent to gateways |
|
| 120 | - * |
|
| 121 | - * @param float $amount |
|
| 122 | - * @return string |
|
| 123 | - */ |
|
| 124 | - public function formatCurrency($amount) |
|
| 125 | - { |
|
| 126 | - return number_format($amount, 2, '.', ''); |
|
| 127 | - } |
|
| 118 | + /** |
|
| 119 | + * Formats the amount so it can generally be sent to gateways |
|
| 120 | + * |
|
| 121 | + * @param float $amount |
|
| 122 | + * @return string |
|
| 123 | + */ |
|
| 124 | + public function formatCurrency($amount) |
|
| 125 | + { |
|
| 126 | + return number_format($amount, 2, '.', ''); |
|
| 127 | + } |
|
| 128 | 128 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected function setId($id = '') |
| 123 | 123 | { |
| 124 | - if (! is_string($id)) { |
|
| 124 | + if ( ! is_string($id)) { |
|
| 125 | 125 | throw new InvalidDataTypeException('$id', $id, 'string'); |
| 126 | 126 | } |
| 127 | 127 | $this->id = $id; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | protected function setOrder($order = 0) |
| 146 | 146 | { |
| 147 | - if (! is_int($order)) { |
|
| 147 | + if ( ! is_int($order)) { |
|
| 148 | 148 | throw new InvalidDataTypeException('$order', $order, 'integer'); |
| 149 | 149 | } |
| 150 | 150 | $this->order = $order; |
@@ -173,11 +173,11 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | protected function setHtmlClass($html_class) |
| 175 | 175 | { |
| 176 | - if (! is_string($html_class)) { |
|
| 176 | + if ( ! is_string($html_class)) { |
|
| 177 | 177 | throw new InvalidDataTypeException('$html_class', $html_class, 'string'); |
| 178 | 178 | } |
| 179 | 179 | if (strpos($html_class, 'progress-step-') === false) { |
| 180 | - $html_class = 'progress-step-' . $html_class; |
|
| 180 | + $html_class = 'progress-step-'.$html_class; |
|
| 181 | 181 | } |
| 182 | 182 | $this->html_class = $html_class; |
| 183 | 183 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | protected function setText($text) |
| 201 | 201 | { |
| 202 | - if (! is_string($text)) { |
|
| 202 | + if ( ! is_string($text)) { |
|
| 203 | 203 | throw new InvalidDataTypeException('$text', $text, 'string'); |
| 204 | 204 | } |
| 205 | 205 | $this->text = $text; |
@@ -18,190 +18,190 @@ |
||
| 18 | 18 | { |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var boolean $current |
|
| 23 | - */ |
|
| 24 | - private $current = false; |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var boolean $completed |
|
| 29 | - */ |
|
| 30 | - private $completed = false; |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var string $html_class |
|
| 35 | - */ |
|
| 36 | - private $html_class; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var string $id |
|
| 40 | - */ |
|
| 41 | - private $id = ''; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var int $order |
|
| 45 | - */ |
|
| 46 | - private $order = 0; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var string $text |
|
| 50 | - */ |
|
| 51 | - private $text = ''; |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * ProgressStep constructor |
|
| 56 | - * |
|
| 57 | - * @param int $order |
|
| 58 | - * @param string $id |
|
| 59 | - * @param string $html_class |
|
| 60 | - * @param string $text |
|
| 61 | - * @throws InvalidDataTypeException |
|
| 62 | - */ |
|
| 63 | - public function __construct($order, $id, $html_class, $text) |
|
| 64 | - { |
|
| 65 | - $this->setOrder($order); |
|
| 66 | - $this->setId($id); |
|
| 67 | - $this->setHtmlClass($html_class); |
|
| 68 | - $this->setText($text); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @return boolean |
|
| 74 | - */ |
|
| 75 | - public function isCurrent() |
|
| 76 | - { |
|
| 77 | - return $this->current; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @param boolean $current |
|
| 83 | - */ |
|
| 84 | - public function setIsCurrent($current = true) |
|
| 85 | - { |
|
| 86 | - $this->current = filter_var($current, FILTER_VALIDATE_BOOLEAN); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @return boolean |
|
| 92 | - */ |
|
| 93 | - public function isCompleted() |
|
| 94 | - { |
|
| 95 | - return $this->completed; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @param boolean $completed |
|
| 101 | - */ |
|
| 102 | - public function setIsCompleted($completed = true) |
|
| 103 | - { |
|
| 104 | - $this->completed = filter_var($completed, FILTER_VALIDATE_BOOLEAN); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @return string |
|
| 110 | - */ |
|
| 111 | - public function id() |
|
| 112 | - { |
|
| 113 | - return $this->id; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @access protected |
|
| 119 | - * @param string $id |
|
| 120 | - * @throws InvalidDataTypeException |
|
| 121 | - */ |
|
| 122 | - protected function setId($id = '') |
|
| 123 | - { |
|
| 124 | - if (! is_string($id)) { |
|
| 125 | - throw new InvalidDataTypeException('$id', $id, 'string'); |
|
| 126 | - } |
|
| 127 | - $this->id = $id; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @return int |
|
| 133 | - */ |
|
| 134 | - public function order() |
|
| 135 | - { |
|
| 136 | - return $this->order; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @access protected |
|
| 142 | - * @param int $order |
|
| 143 | - * @throws InvalidDataTypeException |
|
| 144 | - */ |
|
| 145 | - protected function setOrder($order = 0) |
|
| 146 | - { |
|
| 147 | - if (! is_int($order)) { |
|
| 148 | - throw new InvalidDataTypeException('$order', $order, 'integer'); |
|
| 149 | - } |
|
| 150 | - $this->order = $order; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @return string |
|
| 156 | - */ |
|
| 157 | - public function htmlClass() |
|
| 158 | - { |
|
| 159 | - $html_class = $this->html_class; |
|
| 160 | - if ($this->isCurrent()) { |
|
| 161 | - $html_class .= ' progress-step-active'; |
|
| 162 | - } elseif ($this->isCompleted()) { |
|
| 163 | - $html_class .= ' progress-step-completed'; |
|
| 164 | - } |
|
| 165 | - return $html_class; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * @access protected |
|
| 171 | - * @param string $html_class |
|
| 172 | - * @throws InvalidDataTypeException |
|
| 173 | - */ |
|
| 174 | - protected function setHtmlClass($html_class) |
|
| 175 | - { |
|
| 176 | - if (! is_string($html_class)) { |
|
| 177 | - throw new InvalidDataTypeException('$html_class', $html_class, 'string'); |
|
| 178 | - } |
|
| 179 | - if (strpos($html_class, 'progress-step-') === false) { |
|
| 180 | - $html_class = 'progress-step-' . $html_class; |
|
| 181 | - } |
|
| 182 | - $this->html_class = $html_class; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * @return string |
|
| 188 | - */ |
|
| 189 | - public function text() |
|
| 190 | - { |
|
| 191 | - return $this->text; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * @access protected |
|
| 197 | - * @param string $text |
|
| 198 | - * @throws InvalidDataTypeException |
|
| 199 | - */ |
|
| 200 | - protected function setText($text) |
|
| 201 | - { |
|
| 202 | - if (! is_string($text)) { |
|
| 203 | - throw new InvalidDataTypeException('$text', $text, 'string'); |
|
| 204 | - } |
|
| 205 | - $this->text = $text; |
|
| 206 | - } |
|
| 21 | + /** |
|
| 22 | + * @var boolean $current |
|
| 23 | + */ |
|
| 24 | + private $current = false; |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var boolean $completed |
|
| 29 | + */ |
|
| 30 | + private $completed = false; |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var string $html_class |
|
| 35 | + */ |
|
| 36 | + private $html_class; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var string $id |
|
| 40 | + */ |
|
| 41 | + private $id = ''; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var int $order |
|
| 45 | + */ |
|
| 46 | + private $order = 0; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var string $text |
|
| 50 | + */ |
|
| 51 | + private $text = ''; |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * ProgressStep constructor |
|
| 56 | + * |
|
| 57 | + * @param int $order |
|
| 58 | + * @param string $id |
|
| 59 | + * @param string $html_class |
|
| 60 | + * @param string $text |
|
| 61 | + * @throws InvalidDataTypeException |
|
| 62 | + */ |
|
| 63 | + public function __construct($order, $id, $html_class, $text) |
|
| 64 | + { |
|
| 65 | + $this->setOrder($order); |
|
| 66 | + $this->setId($id); |
|
| 67 | + $this->setHtmlClass($html_class); |
|
| 68 | + $this->setText($text); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @return boolean |
|
| 74 | + */ |
|
| 75 | + public function isCurrent() |
|
| 76 | + { |
|
| 77 | + return $this->current; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @param boolean $current |
|
| 83 | + */ |
|
| 84 | + public function setIsCurrent($current = true) |
|
| 85 | + { |
|
| 86 | + $this->current = filter_var($current, FILTER_VALIDATE_BOOLEAN); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @return boolean |
|
| 92 | + */ |
|
| 93 | + public function isCompleted() |
|
| 94 | + { |
|
| 95 | + return $this->completed; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @param boolean $completed |
|
| 101 | + */ |
|
| 102 | + public function setIsCompleted($completed = true) |
|
| 103 | + { |
|
| 104 | + $this->completed = filter_var($completed, FILTER_VALIDATE_BOOLEAN); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @return string |
|
| 110 | + */ |
|
| 111 | + public function id() |
|
| 112 | + { |
|
| 113 | + return $this->id; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @access protected |
|
| 119 | + * @param string $id |
|
| 120 | + * @throws InvalidDataTypeException |
|
| 121 | + */ |
|
| 122 | + protected function setId($id = '') |
|
| 123 | + { |
|
| 124 | + if (! is_string($id)) { |
|
| 125 | + throw new InvalidDataTypeException('$id', $id, 'string'); |
|
| 126 | + } |
|
| 127 | + $this->id = $id; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @return int |
|
| 133 | + */ |
|
| 134 | + public function order() |
|
| 135 | + { |
|
| 136 | + return $this->order; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @access protected |
|
| 142 | + * @param int $order |
|
| 143 | + * @throws InvalidDataTypeException |
|
| 144 | + */ |
|
| 145 | + protected function setOrder($order = 0) |
|
| 146 | + { |
|
| 147 | + if (! is_int($order)) { |
|
| 148 | + throw new InvalidDataTypeException('$order', $order, 'integer'); |
|
| 149 | + } |
|
| 150 | + $this->order = $order; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * @return string |
|
| 156 | + */ |
|
| 157 | + public function htmlClass() |
|
| 158 | + { |
|
| 159 | + $html_class = $this->html_class; |
|
| 160 | + if ($this->isCurrent()) { |
|
| 161 | + $html_class .= ' progress-step-active'; |
|
| 162 | + } elseif ($this->isCompleted()) { |
|
| 163 | + $html_class .= ' progress-step-completed'; |
|
| 164 | + } |
|
| 165 | + return $html_class; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * @access protected |
|
| 171 | + * @param string $html_class |
|
| 172 | + * @throws InvalidDataTypeException |
|
| 173 | + */ |
|
| 174 | + protected function setHtmlClass($html_class) |
|
| 175 | + { |
|
| 176 | + if (! is_string($html_class)) { |
|
| 177 | + throw new InvalidDataTypeException('$html_class', $html_class, 'string'); |
|
| 178 | + } |
|
| 179 | + if (strpos($html_class, 'progress-step-') === false) { |
|
| 180 | + $html_class = 'progress-step-' . $html_class; |
|
| 181 | + } |
|
| 182 | + $this->html_class = $html_class; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * @return string |
|
| 188 | + */ |
|
| 189 | + public function text() |
|
| 190 | + { |
|
| 191 | + return $this->text; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * @access protected |
|
| 197 | + * @param string $text |
|
| 198 | + * @throws InvalidDataTypeException |
|
| 199 | + */ |
|
| 200 | + protected function setText($text) |
|
| 201 | + { |
|
| 202 | + if (! is_string($text)) { |
|
| 203 | + throw new InvalidDataTypeException('$text', $text, 'string'); |
|
| 204 | + } |
|
| 205 | + $this->text = $text; |
|
| 206 | + } |
|
| 207 | 207 | } |
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | class ProgressStepCollection extends Collection |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * ProgressStepCollection constructor. |
|
| 22 | - * |
|
| 23 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 24 | - */ |
|
| 25 | - public function __construct() |
|
| 26 | - { |
|
| 27 | - parent::__construct('\EventEspresso\core\services\progress_steps\ProgressStepInterface'); |
|
| 28 | - } |
|
| 20 | + /** |
|
| 21 | + * ProgressStepCollection constructor. |
|
| 22 | + * |
|
| 23 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 24 | + */ |
|
| 25 | + public function __construct() |
|
| 26 | + { |
|
| 27 | + parent::__construct('\EventEspresso\core\services\progress_steps\ProgressStepInterface'); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -26,227 +26,227 @@ |
||
| 26 | 26 | class ProgressStepManager |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var ProgressStepInterface[] $collection |
|
| 31 | - */ |
|
| 32 | - private $collection; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var string $default_step |
|
| 36 | - */ |
|
| 37 | - private $default_step; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * the key used for the URL param that denotes the current form step |
|
| 41 | - * defaults to 'ee-form-step' |
|
| 42 | - * |
|
| 43 | - * @var string $form_step_url_key |
|
| 44 | - */ |
|
| 45 | - private $form_step_url_key = ''; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var ProgressStepsDisplayInterface $display_strategy |
|
| 49 | - */ |
|
| 50 | - private $display_strategy; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @var EE_Request $request |
|
| 54 | - */ |
|
| 55 | - private $request; |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * ProgressStepManager constructor |
|
| 60 | - * |
|
| 61 | - * @param string $display_strategy_name |
|
| 62 | - * @param string $default_step |
|
| 63 | - * @param string $form_step_url_key |
|
| 64 | - * @param CollectionInterface $collection |
|
| 65 | - * @param \EE_Request $request |
|
| 66 | - * @throws InvalidClassException |
|
| 67 | - * @throws InvalidDataTypeException |
|
| 68 | - * @throws InvalidInterfaceException |
|
| 69 | - */ |
|
| 70 | - public function __construct( |
|
| 71 | - $display_strategy_name = 'number_bubbles', |
|
| 72 | - $default_step = '', |
|
| 73 | - $form_step_url_key = '', |
|
| 74 | - CollectionInterface $collection = null, |
|
| 75 | - EE_Request $request = null |
|
| 76 | - ) { |
|
| 77 | - $this->setDisplayStrategy($display_strategy_name); |
|
| 78 | - $this->setDefaultStep($default_step); |
|
| 79 | - $this->setFormStepUrlKey($form_step_url_key); |
|
| 80 | - if (! $collection instanceof CollectionInterface) { |
|
| 81 | - $collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface'); |
|
| 82 | - } |
|
| 83 | - $this->collection = $collection; |
|
| 84 | - if (! $request instanceof EE_Request) { |
|
| 85 | - $request = \EE_Registry::instance()->load_core('Request'); |
|
| 86 | - } |
|
| 87 | - $this->request = $request; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @param string $display_strategy_name |
|
| 93 | - * @throws InvalidDataTypeException |
|
| 94 | - * @throws InvalidClassException |
|
| 95 | - */ |
|
| 96 | - protected function setDisplayStrategy($display_strategy_name = 'number_bubbles') |
|
| 97 | - { |
|
| 98 | - if (! is_string($display_strategy_name)) { |
|
| 99 | - throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string'); |
|
| 100 | - } |
|
| 101 | - // build up FQCN from incoming display strategy folder name |
|
| 102 | - $display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\'; |
|
| 103 | - $display_strategy_class .= $display_strategy_name . '\\'; |
|
| 104 | - $display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name))); |
|
| 105 | - $display_strategy_class .= 'ProgressStepsDisplay'; |
|
| 106 | - $display_strategy_class = apply_filters( |
|
| 107 | - 'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class', |
|
| 108 | - $display_strategy_class |
|
| 109 | - ); |
|
| 110 | - if (! class_exists($display_strategy_class)) { |
|
| 111 | - throw new InvalidClassException($display_strategy_class); |
|
| 112 | - } |
|
| 113 | - $display_strategy = new $display_strategy_class(); |
|
| 114 | - if (! $display_strategy instanceof ProgressStepsDisplayInterface) { |
|
| 115 | - throw new InvalidClassException( |
|
| 116 | - $display_strategy_class, |
|
| 117 | - sprintf( |
|
| 118 | - __('The "%1$s" Class needs to be an implementation of the "%1$s" Interface.', 'event_espresso'), |
|
| 119 | - $display_strategy_class, |
|
| 120 | - '\EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface' |
|
| 121 | - ) |
|
| 122 | - ); |
|
| 123 | - } |
|
| 124 | - $this->display_strategy = $display_strategy; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @param string $default_step |
|
| 130 | - * @throws InvalidDataTypeException |
|
| 131 | - */ |
|
| 132 | - public function setDefaultStep($default_step) |
|
| 133 | - { |
|
| 134 | - if (! is_string($default_step)) { |
|
| 135 | - throw new InvalidDataTypeException('$default_step', $default_step, 'string'); |
|
| 136 | - } |
|
| 137 | - $this->default_step = $default_step; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @param string $form_step_url_key |
|
| 143 | - * @throws InvalidDataTypeException |
|
| 144 | - */ |
|
| 145 | - public function setFormStepUrlKey($form_step_url_key = 'ee-form-step') |
|
| 146 | - { |
|
| 147 | - if (! is_string($form_step_url_key)) { |
|
| 148 | - throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string'); |
|
| 149 | - } |
|
| 150 | - $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step'; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @param string $step |
|
| 156 | - * @throws InvalidIdentifierException |
|
| 157 | - */ |
|
| 158 | - public function setCurrentStep($step = '') |
|
| 159 | - { |
|
| 160 | - // use incoming value if it's set, otherwise use request param if it's set, otherwise use default |
|
| 161 | - $step = ! empty($step) |
|
| 162 | - ? $step |
|
| 163 | - : $this->request->get($this->form_step_url_key, $this->default_step); |
|
| 164 | - // grab the step previously known as current, in case we need to revert |
|
| 165 | - $current_current_step = $this->collection->current(); |
|
| 166 | - // verify that requested step exists |
|
| 167 | - if (! $this->collection->has($step)) { |
|
| 168 | - throw new InvalidIdentifierException($step, $this->default_step); |
|
| 169 | - } |
|
| 170 | - if ($this->collection->setCurrent($step)) { |
|
| 171 | - // if the old boss is the same as the new boss, then nothing changes |
|
| 172 | - if ($this->collection->current() !== $current_current_step) { |
|
| 173 | - $current_current_step->setIsCurrent(false); |
|
| 174 | - } |
|
| 175 | - $this->collection->current()->setIsCurrent(); |
|
| 176 | - } else { |
|
| 177 | - $this->collection->setCurrent($current_current_step->id()); |
|
| 178 | - $current_current_step->setIsCurrent(true); |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * setPreviousStepsCompleted |
|
| 185 | - */ |
|
| 186 | - public function setPreviousStepsCompleted() |
|
| 187 | - { |
|
| 188 | - $current_current_step = $this->collection->current(); |
|
| 189 | - $this->collection->rewind(); |
|
| 190 | - while ($this->collection->valid()) { |
|
| 191 | - if ($this->collection->current() === $current_current_step) { |
|
| 192 | - break; |
|
| 193 | - } |
|
| 194 | - $this->setCurrentStepCompleted(); |
|
| 195 | - $this->collection->next(); |
|
| 196 | - } |
|
| 197 | - $this->collection->setCurrentUsingObject($current_current_step); |
|
| 198 | - return false; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * @return ProgressStepInterface |
|
| 204 | - */ |
|
| 205 | - public function currentStep() |
|
| 206 | - { |
|
| 207 | - return $this->collection->current(); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * @return ProgressStepInterface |
|
| 213 | - */ |
|
| 214 | - public function nextStep() |
|
| 215 | - { |
|
| 216 | - return $this->collection->next(); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * @return void |
|
| 222 | - */ |
|
| 223 | - public function enqueueStylesAndScripts() |
|
| 224 | - { |
|
| 225 | - $this->display_strategy->enqueueStylesAndScripts(); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * echos out HTML |
|
| 231 | - * |
|
| 232 | - * @return string |
|
| 233 | - */ |
|
| 234 | - public function displaySteps() |
|
| 235 | - { |
|
| 236 | - return \EEH_Template::display_template( |
|
| 237 | - $this->display_strategy->getTemplate(), |
|
| 238 | - array('progress_steps' => $this->collection), |
|
| 239 | - true |
|
| 240 | - ); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * @param bool $completed |
|
| 246 | - * @return \EventEspresso\core\services\progress_steps\ProgressStepInterface |
|
| 247 | - */ |
|
| 248 | - public function setCurrentStepCompleted($completed = true) |
|
| 249 | - { |
|
| 250 | - return $this->collection->current()->setIsCompleted($completed); |
|
| 251 | - } |
|
| 29 | + /** |
|
| 30 | + * @var ProgressStepInterface[] $collection |
|
| 31 | + */ |
|
| 32 | + private $collection; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var string $default_step |
|
| 36 | + */ |
|
| 37 | + private $default_step; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * the key used for the URL param that denotes the current form step |
|
| 41 | + * defaults to 'ee-form-step' |
|
| 42 | + * |
|
| 43 | + * @var string $form_step_url_key |
|
| 44 | + */ |
|
| 45 | + private $form_step_url_key = ''; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var ProgressStepsDisplayInterface $display_strategy |
|
| 49 | + */ |
|
| 50 | + private $display_strategy; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @var EE_Request $request |
|
| 54 | + */ |
|
| 55 | + private $request; |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * ProgressStepManager constructor |
|
| 60 | + * |
|
| 61 | + * @param string $display_strategy_name |
|
| 62 | + * @param string $default_step |
|
| 63 | + * @param string $form_step_url_key |
|
| 64 | + * @param CollectionInterface $collection |
|
| 65 | + * @param \EE_Request $request |
|
| 66 | + * @throws InvalidClassException |
|
| 67 | + * @throws InvalidDataTypeException |
|
| 68 | + * @throws InvalidInterfaceException |
|
| 69 | + */ |
|
| 70 | + public function __construct( |
|
| 71 | + $display_strategy_name = 'number_bubbles', |
|
| 72 | + $default_step = '', |
|
| 73 | + $form_step_url_key = '', |
|
| 74 | + CollectionInterface $collection = null, |
|
| 75 | + EE_Request $request = null |
|
| 76 | + ) { |
|
| 77 | + $this->setDisplayStrategy($display_strategy_name); |
|
| 78 | + $this->setDefaultStep($default_step); |
|
| 79 | + $this->setFormStepUrlKey($form_step_url_key); |
|
| 80 | + if (! $collection instanceof CollectionInterface) { |
|
| 81 | + $collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface'); |
|
| 82 | + } |
|
| 83 | + $this->collection = $collection; |
|
| 84 | + if (! $request instanceof EE_Request) { |
|
| 85 | + $request = \EE_Registry::instance()->load_core('Request'); |
|
| 86 | + } |
|
| 87 | + $this->request = $request; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @param string $display_strategy_name |
|
| 93 | + * @throws InvalidDataTypeException |
|
| 94 | + * @throws InvalidClassException |
|
| 95 | + */ |
|
| 96 | + protected function setDisplayStrategy($display_strategy_name = 'number_bubbles') |
|
| 97 | + { |
|
| 98 | + if (! is_string($display_strategy_name)) { |
|
| 99 | + throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string'); |
|
| 100 | + } |
|
| 101 | + // build up FQCN from incoming display strategy folder name |
|
| 102 | + $display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\'; |
|
| 103 | + $display_strategy_class .= $display_strategy_name . '\\'; |
|
| 104 | + $display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name))); |
|
| 105 | + $display_strategy_class .= 'ProgressStepsDisplay'; |
|
| 106 | + $display_strategy_class = apply_filters( |
|
| 107 | + 'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class', |
|
| 108 | + $display_strategy_class |
|
| 109 | + ); |
|
| 110 | + if (! class_exists($display_strategy_class)) { |
|
| 111 | + throw new InvalidClassException($display_strategy_class); |
|
| 112 | + } |
|
| 113 | + $display_strategy = new $display_strategy_class(); |
|
| 114 | + if (! $display_strategy instanceof ProgressStepsDisplayInterface) { |
|
| 115 | + throw new InvalidClassException( |
|
| 116 | + $display_strategy_class, |
|
| 117 | + sprintf( |
|
| 118 | + __('The "%1$s" Class needs to be an implementation of the "%1$s" Interface.', 'event_espresso'), |
|
| 119 | + $display_strategy_class, |
|
| 120 | + '\EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface' |
|
| 121 | + ) |
|
| 122 | + ); |
|
| 123 | + } |
|
| 124 | + $this->display_strategy = $display_strategy; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @param string $default_step |
|
| 130 | + * @throws InvalidDataTypeException |
|
| 131 | + */ |
|
| 132 | + public function setDefaultStep($default_step) |
|
| 133 | + { |
|
| 134 | + if (! is_string($default_step)) { |
|
| 135 | + throw new InvalidDataTypeException('$default_step', $default_step, 'string'); |
|
| 136 | + } |
|
| 137 | + $this->default_step = $default_step; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * @param string $form_step_url_key |
|
| 143 | + * @throws InvalidDataTypeException |
|
| 144 | + */ |
|
| 145 | + public function setFormStepUrlKey($form_step_url_key = 'ee-form-step') |
|
| 146 | + { |
|
| 147 | + if (! is_string($form_step_url_key)) { |
|
| 148 | + throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string'); |
|
| 149 | + } |
|
| 150 | + $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step'; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * @param string $step |
|
| 156 | + * @throws InvalidIdentifierException |
|
| 157 | + */ |
|
| 158 | + public function setCurrentStep($step = '') |
|
| 159 | + { |
|
| 160 | + // use incoming value if it's set, otherwise use request param if it's set, otherwise use default |
|
| 161 | + $step = ! empty($step) |
|
| 162 | + ? $step |
|
| 163 | + : $this->request->get($this->form_step_url_key, $this->default_step); |
|
| 164 | + // grab the step previously known as current, in case we need to revert |
|
| 165 | + $current_current_step = $this->collection->current(); |
|
| 166 | + // verify that requested step exists |
|
| 167 | + if (! $this->collection->has($step)) { |
|
| 168 | + throw new InvalidIdentifierException($step, $this->default_step); |
|
| 169 | + } |
|
| 170 | + if ($this->collection->setCurrent($step)) { |
|
| 171 | + // if the old boss is the same as the new boss, then nothing changes |
|
| 172 | + if ($this->collection->current() !== $current_current_step) { |
|
| 173 | + $current_current_step->setIsCurrent(false); |
|
| 174 | + } |
|
| 175 | + $this->collection->current()->setIsCurrent(); |
|
| 176 | + } else { |
|
| 177 | + $this->collection->setCurrent($current_current_step->id()); |
|
| 178 | + $current_current_step->setIsCurrent(true); |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * setPreviousStepsCompleted |
|
| 185 | + */ |
|
| 186 | + public function setPreviousStepsCompleted() |
|
| 187 | + { |
|
| 188 | + $current_current_step = $this->collection->current(); |
|
| 189 | + $this->collection->rewind(); |
|
| 190 | + while ($this->collection->valid()) { |
|
| 191 | + if ($this->collection->current() === $current_current_step) { |
|
| 192 | + break; |
|
| 193 | + } |
|
| 194 | + $this->setCurrentStepCompleted(); |
|
| 195 | + $this->collection->next(); |
|
| 196 | + } |
|
| 197 | + $this->collection->setCurrentUsingObject($current_current_step); |
|
| 198 | + return false; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * @return ProgressStepInterface |
|
| 204 | + */ |
|
| 205 | + public function currentStep() |
|
| 206 | + { |
|
| 207 | + return $this->collection->current(); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * @return ProgressStepInterface |
|
| 213 | + */ |
|
| 214 | + public function nextStep() |
|
| 215 | + { |
|
| 216 | + return $this->collection->next(); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * @return void |
|
| 222 | + */ |
|
| 223 | + public function enqueueStylesAndScripts() |
|
| 224 | + { |
|
| 225 | + $this->display_strategy->enqueueStylesAndScripts(); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * echos out HTML |
|
| 231 | + * |
|
| 232 | + * @return string |
|
| 233 | + */ |
|
| 234 | + public function displaySteps() |
|
| 235 | + { |
|
| 236 | + return \EEH_Template::display_template( |
|
| 237 | + $this->display_strategy->getTemplate(), |
|
| 238 | + array('progress_steps' => $this->collection), |
|
| 239 | + true |
|
| 240 | + ); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * @param bool $completed |
|
| 246 | + * @return \EventEspresso\core\services\progress_steps\ProgressStepInterface |
|
| 247 | + */ |
|
| 248 | + public function setCurrentStepCompleted($completed = true) |
|
| 249 | + { |
|
| 250 | + return $this->collection->current()->setIsCompleted($completed); |
|
| 251 | + } |
|
| 252 | 252 | } |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | $this->setDisplayStrategy($display_strategy_name); |
| 78 | 78 | $this->setDefaultStep($default_step); |
| 79 | 79 | $this->setFormStepUrlKey($form_step_url_key); |
| 80 | - if (! $collection instanceof CollectionInterface) { |
|
| 80 | + if ( ! $collection instanceof CollectionInterface) { |
|
| 81 | 81 | $collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface'); |
| 82 | 82 | } |
| 83 | 83 | $this->collection = $collection; |
| 84 | - if (! $request instanceof EE_Request) { |
|
| 84 | + if ( ! $request instanceof EE_Request) { |
|
| 85 | 85 | $request = \EE_Registry::instance()->load_core('Request'); |
| 86 | 86 | } |
| 87 | 87 | $this->request = $request; |
@@ -95,23 +95,23 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | protected function setDisplayStrategy($display_strategy_name = 'number_bubbles') |
| 97 | 97 | { |
| 98 | - if (! is_string($display_strategy_name)) { |
|
| 98 | + if ( ! is_string($display_strategy_name)) { |
|
| 99 | 99 | throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string'); |
| 100 | 100 | } |
| 101 | 101 | // build up FQCN from incoming display strategy folder name |
| 102 | 102 | $display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\'; |
| 103 | - $display_strategy_class .= $display_strategy_name . '\\'; |
|
| 103 | + $display_strategy_class .= $display_strategy_name.'\\'; |
|
| 104 | 104 | $display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name))); |
| 105 | 105 | $display_strategy_class .= 'ProgressStepsDisplay'; |
| 106 | 106 | $display_strategy_class = apply_filters( |
| 107 | 107 | 'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class', |
| 108 | 108 | $display_strategy_class |
| 109 | 109 | ); |
| 110 | - if (! class_exists($display_strategy_class)) { |
|
| 110 | + if ( ! class_exists($display_strategy_class)) { |
|
| 111 | 111 | throw new InvalidClassException($display_strategy_class); |
| 112 | 112 | } |
| 113 | 113 | $display_strategy = new $display_strategy_class(); |
| 114 | - if (! $display_strategy instanceof ProgressStepsDisplayInterface) { |
|
| 114 | + if ( ! $display_strategy instanceof ProgressStepsDisplayInterface) { |
|
| 115 | 115 | throw new InvalidClassException( |
| 116 | 116 | $display_strategy_class, |
| 117 | 117 | sprintf( |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function setDefaultStep($default_step) |
| 133 | 133 | { |
| 134 | - if (! is_string($default_step)) { |
|
| 134 | + if ( ! is_string($default_step)) { |
|
| 135 | 135 | throw new InvalidDataTypeException('$default_step', $default_step, 'string'); |
| 136 | 136 | } |
| 137 | 137 | $this->default_step = $default_step; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function setFormStepUrlKey($form_step_url_key = 'ee-form-step') |
| 146 | 146 | { |
| 147 | - if (! is_string($form_step_url_key)) { |
|
| 147 | + if ( ! is_string($form_step_url_key)) { |
|
| 148 | 148 | throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string'); |
| 149 | 149 | } |
| 150 | 150 | $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step'; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | // grab the step previously known as current, in case we need to revert |
| 165 | 165 | $current_current_step = $this->collection->current(); |
| 166 | 166 | // verify that requested step exists |
| 167 | - if (! $this->collection->has($step)) { |
|
| 167 | + if ( ! $this->collection->has($step)) { |
|
| 168 | 168 | throw new InvalidIdentifierException($step, $this->default_step); |
| 169 | 169 | } |
| 170 | 170 | if ($this->collection->setCurrent($step)) { |