@@ -15,19 +15,19 @@ |
||
| 15 | 15 | class WordPress extends Basic |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @param string $email_address |
|
| 20 | - * @return boolean |
|
| 21 | - * @throws EmailValidationException |
|
| 22 | - */ |
|
| 23 | - public function validate($email_address) |
|
| 24 | - { |
|
| 25 | - parent::validate($email_address); |
|
| 26 | - if (! is_email($email_address)) { |
|
| 27 | - throw new EmailValidationException( |
|
| 28 | - esc_html__('The email address provided is not valid.', 'event_espresso') |
|
| 29 | - ); |
|
| 30 | - } |
|
| 31 | - return true; |
|
| 32 | - } |
|
| 18 | + /** |
|
| 19 | + * @param string $email_address |
|
| 20 | + * @return boolean |
|
| 21 | + * @throws EmailValidationException |
|
| 22 | + */ |
|
| 23 | + public function validate($email_address) |
|
| 24 | + { |
|
| 25 | + parent::validate($email_address); |
|
| 26 | + if (! is_email($email_address)) { |
|
| 27 | + throw new EmailValidationException( |
|
| 28 | + esc_html__('The email address provided is not valid.', 'event_espresso') |
|
| 29 | + ); |
|
| 30 | + } |
|
| 31 | + return true; |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | public function validate($email_address) |
| 24 | 24 | { |
| 25 | 25 | parent::validate($email_address); |
| 26 | - if (! is_email($email_address)) { |
|
| 26 | + if ( ! is_email($email_address)) { |
|
| 27 | 27 | throw new EmailValidationException( |
| 28 | 28 | esc_html__('The email address provided is not valid.', 'event_espresso') |
| 29 | 29 | ); |
@@ -16,65 +16,65 @@ |
||
| 16 | 16 | class EmailValidationService implements EmailValidatorInterface |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var EE_Registration_Config $registration_config |
|
| 21 | - */ |
|
| 22 | - protected $registration_config; |
|
| 19 | + /** |
|
| 20 | + * @var EE_Registration_Config $registration_config |
|
| 21 | + */ |
|
| 22 | + protected $registration_config; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var Loader $loader |
|
| 26 | - */ |
|
| 27 | - protected $loader; |
|
| 24 | + /** |
|
| 25 | + * @var Loader $loader |
|
| 26 | + */ |
|
| 27 | + protected $loader; |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * EmailValidationService constructor. |
|
| 32 | - * Accepts an \EE_Config as an argument. |
|
| 33 | - * |
|
| 34 | - * @param EE_Registration_Config $config |
|
| 35 | - * @param Loader $loader |
|
| 36 | - */ |
|
| 37 | - public function __construct(EE_Registration_Config $config, Loader $loader) |
|
| 38 | - { |
|
| 39 | - $this->registration_config = $config; |
|
| 40 | - $this->loader = $loader; |
|
| 41 | - } |
|
| 30 | + /** |
|
| 31 | + * EmailValidationService constructor. |
|
| 32 | + * Accepts an \EE_Config as an argument. |
|
| 33 | + * |
|
| 34 | + * @param EE_Registration_Config $config |
|
| 35 | + * @param Loader $loader |
|
| 36 | + */ |
|
| 37 | + public function __construct(EE_Registration_Config $config, Loader $loader) |
|
| 38 | + { |
|
| 39 | + $this->registration_config = $config; |
|
| 40 | + $this->loader = $loader; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Validates the email address. If it's invalid, an EmailValidationException |
|
| 46 | - * is thrown that describes why its invalid. |
|
| 47 | - * |
|
| 48 | - * @param string $email_address |
|
| 49 | - * @return boolean |
|
| 50 | - * @throws EmailValidationException |
|
| 51 | - */ |
|
| 52 | - public function validate($email_address) |
|
| 53 | - { |
|
| 54 | - // pick the correct validator according to the config |
|
| 55 | - switch ($this->registration_config->email_validation_level) { |
|
| 56 | - case 'basic': |
|
| 57 | - $validator = $this->loader->getShared( |
|
| 58 | - 'EventEspresso\core\domain\services\validation\email\strategies\Basic' |
|
| 59 | - ); |
|
| 60 | - break; |
|
| 61 | - case 'i18n': |
|
| 62 | - $validator = $this->loader->getShared( |
|
| 63 | - 'EventEspresso\core\domain\services\validation\email\strategies\International' |
|
| 64 | - ); |
|
| 65 | - break; |
|
| 66 | - case 'i18n_dns': |
|
| 67 | - $validator = $this->loader->getShared( |
|
| 68 | - 'EventEspresso\core\domain\services\validation\email\strategies\InternationalDNS' |
|
| 69 | - ); |
|
| 70 | - break; |
|
| 71 | - case 'wp_default': |
|
| 72 | - default: |
|
| 73 | - $validator = $this->loader->getShared( |
|
| 74 | - 'EventEspresso\core\domain\services\validation\email\strategies\WordPress' |
|
| 75 | - ); |
|
| 76 | - break; |
|
| 77 | - } |
|
| 78 | - return $validator->validate($email_address); |
|
| 79 | - } |
|
| 44 | + /** |
|
| 45 | + * Validates the email address. If it's invalid, an EmailValidationException |
|
| 46 | + * is thrown that describes why its invalid. |
|
| 47 | + * |
|
| 48 | + * @param string $email_address |
|
| 49 | + * @return boolean |
|
| 50 | + * @throws EmailValidationException |
|
| 51 | + */ |
|
| 52 | + public function validate($email_address) |
|
| 53 | + { |
|
| 54 | + // pick the correct validator according to the config |
|
| 55 | + switch ($this->registration_config->email_validation_level) { |
|
| 56 | + case 'basic': |
|
| 57 | + $validator = $this->loader->getShared( |
|
| 58 | + 'EventEspresso\core\domain\services\validation\email\strategies\Basic' |
|
| 59 | + ); |
|
| 60 | + break; |
|
| 61 | + case 'i18n': |
|
| 62 | + $validator = $this->loader->getShared( |
|
| 63 | + 'EventEspresso\core\domain\services\validation\email\strategies\International' |
|
| 64 | + ); |
|
| 65 | + break; |
|
| 66 | + case 'i18n_dns': |
|
| 67 | + $validator = $this->loader->getShared( |
|
| 68 | + 'EventEspresso\core\domain\services\validation\email\strategies\InternationalDNS' |
|
| 69 | + ); |
|
| 70 | + break; |
|
| 71 | + case 'wp_default': |
|
| 72 | + default: |
|
| 73 | + $validator = $this->loader->getShared( |
|
| 74 | + 'EventEspresso\core\domain\services\validation\email\strategies\WordPress' |
|
| 75 | + ); |
|
| 76 | + break; |
|
| 77 | + } |
|
| 78 | + return $validator->validate($email_address); |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -20,10 +20,10 @@ |
||
| 20 | 20 | abstract class DomainService implements DomainServiceInterface |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * DomainService constructor. |
|
| 25 | - */ |
|
| 26 | - public function __construct() |
|
| 27 | - { |
|
| 28 | - } |
|
| 23 | + /** |
|
| 24 | + * DomainService constructor. |
|
| 25 | + */ |
|
| 26 | + public function __construct() |
|
| 27 | + { |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -16,25 +16,25 @@ |
||
| 16 | 16 | interface CapabilitiesCheckerInterface |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
| 21 | - * If any of the individual capability checks fails, then the command will NOT be executed. |
|
| 22 | - * |
|
| 23 | - * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
| 24 | - * @return bool |
|
| 25 | - * @throws InvalidClassException |
|
| 26 | - * @throws InsufficientPermissionsException |
|
| 27 | - */ |
|
| 28 | - public function processCapCheck($cap_check); |
|
| 19 | + /** |
|
| 20 | + * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
| 21 | + * If any of the individual capability checks fails, then the command will NOT be executed. |
|
| 22 | + * |
|
| 23 | + * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
| 24 | + * @return bool |
|
| 25 | + * @throws InvalidClassException |
|
| 26 | + * @throws InsufficientPermissionsException |
|
| 27 | + */ |
|
| 28 | + public function processCapCheck($cap_check); |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
| 33 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
| 34 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
| 35 | - * @return bool |
|
| 36 | - * @throws InsufficientPermissionsException |
|
| 37 | - * @throws InvalidClassException |
|
| 38 | - */ |
|
| 39 | - public function process($capability, $context, $ID = 0); |
|
| 31 | + /** |
|
| 32 | + * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
| 33 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
| 34 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
| 35 | + * @return bool |
|
| 36 | + * @throws InsufficientPermissionsException |
|
| 37 | + * @throws InvalidClassException |
|
| 38 | + */ |
|
| 39 | + public function process($capability, $context, $ID = 0); |
|
| 40 | 40 | } |
@@ -11,8 +11,8 @@ |
||
| 11 | 11 | interface RequiresCapCheckInterface |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @return CapCheckInterface |
|
| 16 | - */ |
|
| 17 | - public function getCapCheck(); |
|
| 14 | + /** |
|
| 15 | + * @return CapCheckInterface |
|
| 16 | + */ |
|
| 17 | + public function getCapCheck(); |
|
| 18 | 18 | } |
@@ -12,18 +12,18 @@ |
||
| 12 | 12 | interface CapCheckInterface |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @return string |
|
| 17 | - */ |
|
| 18 | - public function capability(); |
|
| 15 | + /** |
|
| 16 | + * @return string |
|
| 17 | + */ |
|
| 18 | + public function capability(); |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @return string |
|
| 22 | - */ |
|
| 23 | - public function context(); |
|
| 20 | + /** |
|
| 21 | + * @return string |
|
| 22 | + */ |
|
| 23 | + public function context(); |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @return int|string |
|
| 27 | - */ |
|
| 28 | - public function ID(); |
|
| 25 | + /** |
|
| 26 | + * @return int|string |
|
| 27 | + */ |
|
| 28 | + public function ID(); |
|
| 29 | 29 | } |
@@ -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()); |