@@ -24,37 +24,37 @@ |
||
| 24 | 24 | class CapChecker implements CommandBusMiddlewareInterface |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @type CapabilitiesCheckerInterface $capabilities_checker |
|
| 29 | - */ |
|
| 30 | - private $capabilities_checker; |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * CapChecker constructor |
|
| 35 | - * |
|
| 36 | - * @param CapabilitiesCheckerInterface $capabilities_checker |
|
| 37 | - */ |
|
| 38 | - public function __construct(CapabilitiesCheckerInterface $capabilities_checker) |
|
| 39 | - { |
|
| 40 | - $this->capabilities_checker = $capabilities_checker; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @param CommandInterface $command |
|
| 46 | - * @param Closure $next |
|
| 47 | - * @return mixed |
|
| 48 | - * @throws InvalidClassException |
|
| 49 | - * @throws InsufficientPermissionsException |
|
| 50 | - */ |
|
| 51 | - public function handle(CommandInterface $command, Closure $next) |
|
| 52 | - { |
|
| 53 | - if ($command instanceof CommandRequiresCapCheckInterface) { |
|
| 54 | - $this->capabilities_checker->processCapCheck( |
|
| 55 | - $command->getCapCheck() |
|
| 56 | - ); |
|
| 57 | - } |
|
| 58 | - return $next($command); |
|
| 59 | - } |
|
| 27 | + /** |
|
| 28 | + * @type CapabilitiesCheckerInterface $capabilities_checker |
|
| 29 | + */ |
|
| 30 | + private $capabilities_checker; |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * CapChecker constructor |
|
| 35 | + * |
|
| 36 | + * @param CapabilitiesCheckerInterface $capabilities_checker |
|
| 37 | + */ |
|
| 38 | + public function __construct(CapabilitiesCheckerInterface $capabilities_checker) |
|
| 39 | + { |
|
| 40 | + $this->capabilities_checker = $capabilities_checker; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @param CommandInterface $command |
|
| 46 | + * @param Closure $next |
|
| 47 | + * @return mixed |
|
| 48 | + * @throws InvalidClassException |
|
| 49 | + * @throws InsufficientPermissionsException |
|
| 50 | + */ |
|
| 51 | + public function handle(CommandInterface $command, Closure $next) |
|
| 52 | + { |
|
| 53 | + if ($command instanceof CommandRequiresCapCheckInterface) { |
|
| 54 | + $this->capabilities_checker->processCapCheck( |
|
| 55 | + $command->getCapCheck() |
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | + return $next($command); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -16,112 +16,112 @@ |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var \EE_Transaction $transaction |
|
| 21 | - */ |
|
| 22 | - private $transaction; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var \EE_Ticket $ticket |
|
| 26 | - */ |
|
| 27 | - private $ticket; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var \EE_Line_Item $ticket_line_item |
|
| 31 | - */ |
|
| 32 | - protected $ticket_line_item; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var int $quantity |
|
| 36 | - */ |
|
| 37 | - protected $quantity; |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @param \EE_Registration $registration |
|
| 42 | - * @param int $quantity |
|
| 43 | - */ |
|
| 44 | - public static function fromRegistration(\EE_Registration $registration, $quantity = 1) |
|
| 45 | - { |
|
| 46 | - new self( |
|
| 47 | - $registration->transaction(), |
|
| 48 | - $registration->ticket(), |
|
| 49 | - 1, |
|
| 50 | - $registration->ticket_line_item() |
|
| 51 | - ); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @param \EE_Line_Item $ticket_line_item |
|
| 57 | - * @param int $quantity |
|
| 58 | - */ |
|
| 59 | - public static function fromTicketLineItem( |
|
| 60 | - \EE_Line_Item $ticket_line_item, |
|
| 61 | - $quantity = 1 |
|
| 62 | - ) { |
|
| 63 | - new self( |
|
| 64 | - $ticket_line_item->transaction(), |
|
| 65 | - $ticket_line_item->ticket(), |
|
| 66 | - $quantity, |
|
| 67 | - $ticket_line_item |
|
| 68 | - ); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * CancelTicketLineItemCommand constructor. |
|
| 74 | - * |
|
| 75 | - * @param \EE_Transaction $transaction |
|
| 76 | - * @param \EE_Ticket $ticket |
|
| 77 | - * @param int $quantity |
|
| 78 | - * @param \EE_Line_Item $ticket_line_item |
|
| 79 | - */ |
|
| 80 | - public function __construct( |
|
| 81 | - \EE_Transaction $transaction, |
|
| 82 | - \EE_Ticket $ticket, |
|
| 83 | - $quantity = 1, |
|
| 84 | - \EE_Line_Item $ticket_line_item = null |
|
| 85 | - ) { |
|
| 86 | - $this->transaction = $transaction; |
|
| 87 | - $this->ticket = $ticket; |
|
| 88 | - $this->quantity = min(1, absint($quantity)); |
|
| 89 | - $this->ticket_line_item = $ticket_line_item; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @return \EE_Transaction |
|
| 95 | - */ |
|
| 96 | - public function transaction() |
|
| 97 | - { |
|
| 98 | - return $this->transaction; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @return \EE_Ticket |
|
| 104 | - */ |
|
| 105 | - public function ticket() |
|
| 106 | - { |
|
| 107 | - return $this->ticket; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * @return \EE_Line_Item |
|
| 113 | - */ |
|
| 114 | - public function ticketLineItem() |
|
| 115 | - { |
|
| 116 | - return $this->ticket_line_item; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @return int |
|
| 122 | - */ |
|
| 123 | - public function quantity() |
|
| 124 | - { |
|
| 125 | - return $this->quantity; |
|
| 126 | - } |
|
| 19 | + /** |
|
| 20 | + * @var \EE_Transaction $transaction |
|
| 21 | + */ |
|
| 22 | + private $transaction; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var \EE_Ticket $ticket |
|
| 26 | + */ |
|
| 27 | + private $ticket; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var \EE_Line_Item $ticket_line_item |
|
| 31 | + */ |
|
| 32 | + protected $ticket_line_item; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var int $quantity |
|
| 36 | + */ |
|
| 37 | + protected $quantity; |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @param \EE_Registration $registration |
|
| 42 | + * @param int $quantity |
|
| 43 | + */ |
|
| 44 | + public static function fromRegistration(\EE_Registration $registration, $quantity = 1) |
|
| 45 | + { |
|
| 46 | + new self( |
|
| 47 | + $registration->transaction(), |
|
| 48 | + $registration->ticket(), |
|
| 49 | + 1, |
|
| 50 | + $registration->ticket_line_item() |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @param \EE_Line_Item $ticket_line_item |
|
| 57 | + * @param int $quantity |
|
| 58 | + */ |
|
| 59 | + public static function fromTicketLineItem( |
|
| 60 | + \EE_Line_Item $ticket_line_item, |
|
| 61 | + $quantity = 1 |
|
| 62 | + ) { |
|
| 63 | + new self( |
|
| 64 | + $ticket_line_item->transaction(), |
|
| 65 | + $ticket_line_item->ticket(), |
|
| 66 | + $quantity, |
|
| 67 | + $ticket_line_item |
|
| 68 | + ); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * CancelTicketLineItemCommand constructor. |
|
| 74 | + * |
|
| 75 | + * @param \EE_Transaction $transaction |
|
| 76 | + * @param \EE_Ticket $ticket |
|
| 77 | + * @param int $quantity |
|
| 78 | + * @param \EE_Line_Item $ticket_line_item |
|
| 79 | + */ |
|
| 80 | + public function __construct( |
|
| 81 | + \EE_Transaction $transaction, |
|
| 82 | + \EE_Ticket $ticket, |
|
| 83 | + $quantity = 1, |
|
| 84 | + \EE_Line_Item $ticket_line_item = null |
|
| 85 | + ) { |
|
| 86 | + $this->transaction = $transaction; |
|
| 87 | + $this->ticket = $ticket; |
|
| 88 | + $this->quantity = min(1, absint($quantity)); |
|
| 89 | + $this->ticket_line_item = $ticket_line_item; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @return \EE_Transaction |
|
| 95 | + */ |
|
| 96 | + public function transaction() |
|
| 97 | + { |
|
| 98 | + return $this->transaction; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @return \EE_Ticket |
|
| 104 | + */ |
|
| 105 | + public function ticket() |
|
| 106 | + { |
|
| 107 | + return $this->ticket; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * @return \EE_Line_Item |
|
| 113 | + */ |
|
| 114 | + public function ticketLineItem() |
|
| 115 | + { |
|
| 116 | + return $this->ticket_line_item; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @return int |
|
| 122 | + */ |
|
| 123 | + public function quantity() |
|
| 124 | + { |
|
| 125 | + return $this->quantity; |
|
| 126 | + } |
|
| 127 | 127 | } |
@@ -16,77 +16,77 @@ |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var \EE_Transaction $transaction |
|
| 21 | - */ |
|
| 22 | - private $transaction; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var \EE_Ticket $ticket |
|
| 26 | - */ |
|
| 27 | - private $ticket; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var int $quantity |
|
| 31 | - */ |
|
| 32 | - private $quantity = 1; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var \EE_Line_Item $ticket_line_item |
|
| 36 | - */ |
|
| 37 | - protected $ticket_line_item; |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * CreateTicketLineItemCommand constructor. |
|
| 42 | - * |
|
| 43 | - * @param \EE_Transaction $transaction |
|
| 44 | - * @param \EE_Ticket $ticket |
|
| 45 | - * @param int $quantity |
|
| 46 | - */ |
|
| 47 | - public function __construct( |
|
| 48 | - \EE_Transaction $transaction, |
|
| 49 | - \EE_Ticket $ticket, |
|
| 50 | - $quantity = 1 |
|
| 51 | - ) { |
|
| 52 | - $this->transaction = $transaction; |
|
| 53 | - $this->ticket = $ticket; |
|
| 54 | - $this->quantity = $quantity; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @return \EE_Transaction |
|
| 60 | - */ |
|
| 61 | - public function transaction() |
|
| 62 | - { |
|
| 63 | - return $this->transaction; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @return \EE_Ticket |
|
| 69 | - */ |
|
| 70 | - public function ticket() |
|
| 71 | - { |
|
| 72 | - return $this->ticket; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @return int |
|
| 78 | - */ |
|
| 79 | - public function quantity() |
|
| 80 | - { |
|
| 81 | - return $this->quantity; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @return \EE_Line_Item |
|
| 87 | - */ |
|
| 88 | - public function ticketLineItem() |
|
| 89 | - { |
|
| 90 | - return $this->ticket_line_item; |
|
| 91 | - } |
|
| 19 | + /** |
|
| 20 | + * @var \EE_Transaction $transaction |
|
| 21 | + */ |
|
| 22 | + private $transaction; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var \EE_Ticket $ticket |
|
| 26 | + */ |
|
| 27 | + private $ticket; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var int $quantity |
|
| 31 | + */ |
|
| 32 | + private $quantity = 1; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var \EE_Line_Item $ticket_line_item |
|
| 36 | + */ |
|
| 37 | + protected $ticket_line_item; |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * CreateTicketLineItemCommand constructor. |
|
| 42 | + * |
|
| 43 | + * @param \EE_Transaction $transaction |
|
| 44 | + * @param \EE_Ticket $ticket |
|
| 45 | + * @param int $quantity |
|
| 46 | + */ |
|
| 47 | + public function __construct( |
|
| 48 | + \EE_Transaction $transaction, |
|
| 49 | + \EE_Ticket $ticket, |
|
| 50 | + $quantity = 1 |
|
| 51 | + ) { |
|
| 52 | + $this->transaction = $transaction; |
|
| 53 | + $this->ticket = $ticket; |
|
| 54 | + $this->quantity = $quantity; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @return \EE_Transaction |
|
| 60 | + */ |
|
| 61 | + public function transaction() |
|
| 62 | + { |
|
| 63 | + return $this->transaction; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @return \EE_Ticket |
|
| 69 | + */ |
|
| 70 | + public function ticket() |
|
| 71 | + { |
|
| 72 | + return $this->ticket; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @return int |
|
| 78 | + */ |
|
| 79 | + public function quantity() |
|
| 80 | + { |
|
| 81 | + return $this->quantity; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @return \EE_Line_Item |
|
| 87 | + */ |
|
| 88 | + public function ticketLineItem() |
|
| 89 | + { |
|
| 90 | + return $this->ticket_line_item; |
|
| 91 | + } |
|
| 92 | 92 | } |
@@ -14,10 +14,10 @@ |
||
| 14 | 14 | abstract class FormHtmlFilter |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @param $html |
|
| 19 | - * @param EE_Form_Section_Validatable $form_section |
|
| 20 | - * @return string |
|
| 21 | - */ |
|
| 22 | - abstract public function filterHtml($html, EE_Form_Section_Validatable $form_section); |
|
| 17 | + /** |
|
| 18 | + * @param $html |
|
| 19 | + * @param EE_Form_Section_Validatable $form_section |
|
| 20 | + * @return string |
|
| 21 | + */ |
|
| 22 | + abstract public function filterHtml($html, EE_Form_Section_Validatable $form_section); |
|
| 23 | 23 | } |
@@ -12,49 +12,49 @@ |
||
| 12 | 12 | class EventListIframeEmbedButton extends IframeEmbedButton |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * EventListIframeEmbedButton constructor. |
|
| 17 | - */ |
|
| 18 | - public function __construct() |
|
| 19 | - { |
|
| 20 | - parent::__construct( |
|
| 21 | - esc_html__('Upcoming Event List', 'event_espresso'), |
|
| 22 | - 'event_list' |
|
| 23 | - ); |
|
| 24 | - } |
|
| 15 | + /** |
|
| 16 | + * EventListIframeEmbedButton constructor. |
|
| 17 | + */ |
|
| 18 | + public function __construct() |
|
| 19 | + { |
|
| 20 | + parent::__construct( |
|
| 21 | + esc_html__('Upcoming Event List', 'event_espresso'), |
|
| 22 | + 'event_list' |
|
| 23 | + ); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | - public function addEmbedButton() |
|
| 28 | - { |
|
| 29 | - add_filter( |
|
| 30 | - 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
|
| 31 | - array($this, 'addEventListIframeEmbedButtonSection') |
|
| 32 | - ); |
|
| 33 | - add_action( |
|
| 34 | - 'admin_enqueue_scripts', |
|
| 35 | - array($this, 'embedButtonAssets'), |
|
| 36 | - 10 |
|
| 37 | - ); |
|
| 38 | - } |
|
| 27 | + public function addEmbedButton() |
|
| 28 | + { |
|
| 29 | + add_filter( |
|
| 30 | + 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
|
| 31 | + array($this, 'addEventListIframeEmbedButtonSection') |
|
| 32 | + ); |
|
| 33 | + add_action( |
|
| 34 | + 'admin_enqueue_scripts', |
|
| 35 | + array($this, 'embedButtonAssets'), |
|
| 36 | + 10 |
|
| 37 | + ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Adds an iframe embed code button to the Event editor. |
|
| 43 | - * return string |
|
| 44 | - * |
|
| 45 | - * @param array $after_list_table |
|
| 46 | - * @return array |
|
| 47 | - */ |
|
| 48 | - public function addEventListIframeEmbedButtonSection(array $after_list_table) |
|
| 49 | - { |
|
| 50 | - return \EEH_Array::insert_into_array( |
|
| 51 | - $after_list_table, |
|
| 52 | - array( |
|
| 53 | - 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
| 54 | - array('event_list' => $this->embedButtonHtml()) |
|
| 55 | - ), |
|
| 56 | - ), |
|
| 57 | - 'legend' |
|
| 58 | - ); |
|
| 59 | - } |
|
| 41 | + /** |
|
| 42 | + * Adds an iframe embed code button to the Event editor. |
|
| 43 | + * return string |
|
| 44 | + * |
|
| 45 | + * @param array $after_list_table |
|
| 46 | + * @return array |
|
| 47 | + */ |
|
| 48 | + public function addEventListIframeEmbedButtonSection(array $after_list_table) |
|
| 49 | + { |
|
| 50 | + return \EEH_Array::insert_into_array( |
|
| 51 | + $after_list_table, |
|
| 52 | + array( |
|
| 53 | + 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
| 54 | + array('event_list' => $this->embedButtonHtml()) |
|
| 55 | + ), |
|
| 56 | + ), |
|
| 57 | + 'legend' |
|
| 58 | + ); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -7,57 +7,57 @@ |
||
| 7 | 7 | class ChangesIn40833 extends ChangesInBase |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * Adds hooks so requests to 4.8.29 don't have the checkin endpoints |
|
| 12 | - */ |
|
| 13 | - public function setHooks() |
|
| 14 | - { |
|
| 15 | - // set a hook to remove the checkout/checkout endpoints if the request |
|
| 16 | - // is for lower than 4.8.33 |
|
| 17 | - add_filter( |
|
| 18 | - 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
|
| 19 | - array($this, 'removeCheckinRoutesEarlierThan4833'), |
|
| 20 | - 10, |
|
| 21 | - 2 |
|
| 22 | - ); |
|
| 23 | - add_filter( |
|
| 24 | - 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return', |
|
| 25 | - array($this, 'dontAddHeadersFromEeNotices'), |
|
| 26 | - 10, |
|
| 27 | - 2 |
|
| 28 | - ); |
|
| 29 | - } |
|
| 10 | + /** |
|
| 11 | + * Adds hooks so requests to 4.8.29 don't have the checkin endpoints |
|
| 12 | + */ |
|
| 13 | + public function setHooks() |
|
| 14 | + { |
|
| 15 | + // set a hook to remove the checkout/checkout endpoints if the request |
|
| 16 | + // is for lower than 4.8.33 |
|
| 17 | + add_filter( |
|
| 18 | + 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
|
| 19 | + array($this, 'removeCheckinRoutesEarlierThan4833'), |
|
| 20 | + 10, |
|
| 21 | + 2 |
|
| 22 | + ); |
|
| 23 | + add_filter( |
|
| 24 | + 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return', |
|
| 25 | + array($this, 'dontAddHeadersFromEeNotices'), |
|
| 26 | + 10, |
|
| 27 | + 2 |
|
| 28 | + ); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Removes the checkin and checkout endpoints from the index for requests |
|
| 34 | - * to api versions lowers than 4.8.33 |
|
| 35 | - * |
|
| 36 | - * @param array $routes_on_this_version |
|
| 37 | - * @param string $version |
|
| 38 | - * @return array like $routes_on_this_version |
|
| 39 | - */ |
|
| 40 | - public function removeCheckinRoutesEarlierThan4833($routes_on_this_version, $version) |
|
| 41 | - { |
|
| 42 | - if ($this->appliesToVersion($version)) { |
|
| 43 | - unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']); |
|
| 44 | - } |
|
| 45 | - return $routes_on_this_version; |
|
| 46 | - } |
|
| 32 | + /** |
|
| 33 | + * Removes the checkin and checkout endpoints from the index for requests |
|
| 34 | + * to api versions lowers than 4.8.33 |
|
| 35 | + * |
|
| 36 | + * @param array $routes_on_this_version |
|
| 37 | + * @param string $version |
|
| 38 | + * @return array like $routes_on_this_version |
|
| 39 | + */ |
|
| 40 | + public function removeCheckinRoutesEarlierThan4833($routes_on_this_version, $version) |
|
| 41 | + { |
|
| 42 | + if ($this->appliesToVersion($version)) { |
|
| 43 | + unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']); |
|
| 44 | + } |
|
| 45 | + return $routes_on_this_version; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * We just added headers for notices in this version |
|
| 51 | - * |
|
| 52 | - * @param array $headers_from_ee_notices |
|
| 53 | - * @param string $requested_version |
|
| 54 | - * @return array |
|
| 55 | - */ |
|
| 56 | - public function dontAddHeadersFromEeNotices($headers_from_ee_notices, $requested_version) |
|
| 57 | - { |
|
| 58 | - if ($this->appliesToVersion($requested_version)) { |
|
| 59 | - return array(); |
|
| 60 | - } |
|
| 61 | - return $headers_from_ee_notices; |
|
| 62 | - } |
|
| 49 | + /** |
|
| 50 | + * We just added headers for notices in this version |
|
| 51 | + * |
|
| 52 | + * @param array $headers_from_ee_notices |
|
| 53 | + * @param string $requested_version |
|
| 54 | + * @return array |
|
| 55 | + */ |
|
| 56 | + public function dontAddHeadersFromEeNotices($headers_from_ee_notices, $requested_version) |
|
| 57 | + { |
|
| 58 | + if ($this->appliesToVersion($requested_version)) { |
|
| 59 | + return array(); |
|
| 60 | + } |
|
| 61 | + return $headers_from_ee_notices; |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $force = false; |
| 57 | 57 | } |
| 58 | 58 | $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
| 59 | - if (! $reg instanceof EE_Registration) { |
|
| 59 | + if ( ! $reg instanceof EE_Registration) { |
|
| 60 | 60 | return $this->sendResponse( |
| 61 | 61 | new WP_Error( |
| 62 | 62 | 'rest_registration_toggle_checkin_invalid_id', |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | ) |
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | - if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
| 74 | + if ( ! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
| 75 | 75 | return $this->sendResponse( |
| 76 | 76 | new WP_Error( |
| 77 | 77 | 'rest_user_cannot_toggle_checkin', |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
| 87 | 87 | if ($success === false) { |
| 88 | 88 | // check if we know they can't check in because they're not approved and we aren't forcing |
| 89 | - if (! $reg->is_approved() && ! $force) { |
|
| 89 | + if ( ! $reg->is_approved() && ! $force) { |
|
| 90 | 90 | // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
| 91 | 91 | return $this->sendResponse( |
| 92 | 92 | new WP_Error( |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | ), |
| 119 | 119 | ) |
| 120 | 120 | ); |
| 121 | - if (! $checkin instanceof EE_Checkin) { |
|
| 121 | + if ( ! $checkin instanceof EE_Checkin) { |
|
| 122 | 122 | return $this->sendResponse( |
| 123 | 123 | new WP_Error( |
| 124 | 124 | 'rest_toggle_checkin_error', |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | $get_request = new WP_REST_Request( |
| 139 | 139 | 'GET', |
| 140 | - '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
| 140 | + '/'.EED_Core_Rest_Api::ee_api_namespace.'v'.$version.'/checkins/'.$checkin->ID() |
|
| 141 | 141 | ); |
| 142 | 142 | $get_request->set_url_params( |
| 143 | 143 | array( |
@@ -26,124 +26,124 @@ |
||
| 26 | 26 | class Checkin extends Base |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @param WP_REST_Request $request |
|
| 31 | - * @param string $version |
|
| 32 | - * @return WP_Error|WP_REST_Response |
|
| 33 | - */ |
|
| 34 | - public static function handleRequestToggleCheckin(WP_REST_Request $request, $version) |
|
| 35 | - { |
|
| 36 | - $controller = new Checkin(); |
|
| 37 | - return $controller->createCheckinCheckoutObject($request, $version); |
|
| 38 | - } |
|
| 29 | + /** |
|
| 30 | + * @param WP_REST_Request $request |
|
| 31 | + * @param string $version |
|
| 32 | + * @return WP_Error|WP_REST_Response |
|
| 33 | + */ |
|
| 34 | + public static function handleRequestToggleCheckin(WP_REST_Request $request, $version) |
|
| 35 | + { |
|
| 36 | + $controller = new Checkin(); |
|
| 37 | + return $controller->createCheckinCheckoutObject($request, $version); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Toggles whether the user is checked in or not. |
|
| 43 | - * |
|
| 44 | - * @param WP_REST_Request $request |
|
| 45 | - * @param string $version |
|
| 46 | - * @return WP_Error|WP_REST_Response |
|
| 47 | - */ |
|
| 48 | - protected function createCheckinCheckoutObject(WP_REST_Request $request, $version) |
|
| 49 | - { |
|
| 50 | - $reg_id = $request->get_param('REG_ID'); |
|
| 51 | - $dtt_id = $request->get_param('DTT_ID'); |
|
| 52 | - $force = $request->get_param('force'); |
|
| 53 | - if ($force == 'true') { |
|
| 54 | - $force = true; |
|
| 55 | - } else { |
|
| 56 | - $force = false; |
|
| 57 | - } |
|
| 58 | - $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 59 | - if (! $reg instanceof EE_Registration) { |
|
| 60 | - return $this->sendResponse( |
|
| 61 | - new WP_Error( |
|
| 62 | - 'rest_registration_toggle_checkin_invalid_id', |
|
| 63 | - sprintf( |
|
| 64 | - esc_html__( |
|
| 65 | - 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', |
|
| 66 | - 'event_espresso' |
|
| 67 | - ), |
|
| 68 | - $reg_id |
|
| 69 | - ), |
|
| 70 | - array('status' => 422) |
|
| 71 | - ) |
|
| 72 | - ); |
|
| 73 | - } |
|
| 74 | - if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
| 75 | - return $this->sendResponse( |
|
| 76 | - new WP_Error( |
|
| 77 | - 'rest_user_cannot_toggle_checkin', |
|
| 78 | - sprintf( |
|
| 79 | - esc_html__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), |
|
| 80 | - $reg_id |
|
| 81 | - ), |
|
| 82 | - array('status' => 403) |
|
| 83 | - ) |
|
| 84 | - ); |
|
| 85 | - } |
|
| 86 | - $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
|
| 87 | - if ($success === false) { |
|
| 88 | - // check if we know they can't check in because they're not approved and we aren't forcing |
|
| 89 | - if (! $reg->is_approved() && ! $force) { |
|
| 90 | - // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
|
| 91 | - return $this->sendResponse( |
|
| 92 | - new WP_Error( |
|
| 93 | - 'rest_toggle_checkin_failed', |
|
| 94 | - esc_html__( |
|
| 95 | - // @codingStandardsIgnoreStart |
|
| 96 | - 'Registration check-in failed because the registration is not approved. You may attempt to force checking in though.', |
|
| 97 | - // @codingStandardsIgnoreEnd |
|
| 98 | - 'event_espresso' |
|
| 99 | - ) |
|
| 100 | - ) |
|
| 101 | - ); |
|
| 102 | - } |
|
| 103 | - return $this->sendResponse( |
|
| 104 | - new WP_Error( |
|
| 105 | - 'rest_toggle_checkin_failed_not_forceable', |
|
| 106 | - esc_html__('Registration checkin failed. Please see additional error data.', 'event_espresso') |
|
| 107 | - ) |
|
| 108 | - ); |
|
| 109 | - } |
|
| 110 | - $checkin = EEM_Checkin::instance()->get_one( |
|
| 111 | - array( |
|
| 112 | - array( |
|
| 113 | - 'REG_ID' => $reg_id, |
|
| 114 | - 'DTT_ID' => $dtt_id, |
|
| 115 | - ), |
|
| 116 | - 'order_by' => array( |
|
| 117 | - 'CHK_timestamp' => 'DESC', |
|
| 118 | - ), |
|
| 119 | - ) |
|
| 120 | - ); |
|
| 121 | - if (! $checkin instanceof EE_Checkin) { |
|
| 122 | - return $this->sendResponse( |
|
| 123 | - new WP_Error( |
|
| 124 | - 'rest_toggle_checkin_error', |
|
| 125 | - sprintf( |
|
| 126 | - esc_html__( |
|
| 127 | - // @codingStandardsIgnoreStart |
|
| 128 | - 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', |
|
| 129 | - // @codingStandardsIgnoreEnd |
|
| 130 | - 'event_espresso' |
|
| 131 | - ), |
|
| 132 | - $reg_id, |
|
| 133 | - $dtt_id |
|
| 134 | - ) |
|
| 135 | - ) |
|
| 136 | - ); |
|
| 137 | - } |
|
| 138 | - $get_request = new WP_REST_Request( |
|
| 139 | - 'GET', |
|
| 140 | - '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
| 141 | - ); |
|
| 142 | - $get_request->set_url_params( |
|
| 143 | - array( |
|
| 144 | - 'id' => $checkin->ID(), |
|
| 145 | - ) |
|
| 146 | - ); |
|
| 147 | - return Read::handleRequestGetOne($get_request, $version, 'Checkin'); |
|
| 148 | - } |
|
| 41 | + /** |
|
| 42 | + * Toggles whether the user is checked in or not. |
|
| 43 | + * |
|
| 44 | + * @param WP_REST_Request $request |
|
| 45 | + * @param string $version |
|
| 46 | + * @return WP_Error|WP_REST_Response |
|
| 47 | + */ |
|
| 48 | + protected function createCheckinCheckoutObject(WP_REST_Request $request, $version) |
|
| 49 | + { |
|
| 50 | + $reg_id = $request->get_param('REG_ID'); |
|
| 51 | + $dtt_id = $request->get_param('DTT_ID'); |
|
| 52 | + $force = $request->get_param('force'); |
|
| 53 | + if ($force == 'true') { |
|
| 54 | + $force = true; |
|
| 55 | + } else { |
|
| 56 | + $force = false; |
|
| 57 | + } |
|
| 58 | + $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 59 | + if (! $reg instanceof EE_Registration) { |
|
| 60 | + return $this->sendResponse( |
|
| 61 | + new WP_Error( |
|
| 62 | + 'rest_registration_toggle_checkin_invalid_id', |
|
| 63 | + sprintf( |
|
| 64 | + esc_html__( |
|
| 65 | + 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', |
|
| 66 | + 'event_espresso' |
|
| 67 | + ), |
|
| 68 | + $reg_id |
|
| 69 | + ), |
|
| 70 | + array('status' => 422) |
|
| 71 | + ) |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | + if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
| 75 | + return $this->sendResponse( |
|
| 76 | + new WP_Error( |
|
| 77 | + 'rest_user_cannot_toggle_checkin', |
|
| 78 | + sprintf( |
|
| 79 | + esc_html__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), |
|
| 80 | + $reg_id |
|
| 81 | + ), |
|
| 82 | + array('status' => 403) |
|
| 83 | + ) |
|
| 84 | + ); |
|
| 85 | + } |
|
| 86 | + $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
|
| 87 | + if ($success === false) { |
|
| 88 | + // check if we know they can't check in because they're not approved and we aren't forcing |
|
| 89 | + if (! $reg->is_approved() && ! $force) { |
|
| 90 | + // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
|
| 91 | + return $this->sendResponse( |
|
| 92 | + new WP_Error( |
|
| 93 | + 'rest_toggle_checkin_failed', |
|
| 94 | + esc_html__( |
|
| 95 | + // @codingStandardsIgnoreStart |
|
| 96 | + 'Registration check-in failed because the registration is not approved. You may attempt to force checking in though.', |
|
| 97 | + // @codingStandardsIgnoreEnd |
|
| 98 | + 'event_espresso' |
|
| 99 | + ) |
|
| 100 | + ) |
|
| 101 | + ); |
|
| 102 | + } |
|
| 103 | + return $this->sendResponse( |
|
| 104 | + new WP_Error( |
|
| 105 | + 'rest_toggle_checkin_failed_not_forceable', |
|
| 106 | + esc_html__('Registration checkin failed. Please see additional error data.', 'event_espresso') |
|
| 107 | + ) |
|
| 108 | + ); |
|
| 109 | + } |
|
| 110 | + $checkin = EEM_Checkin::instance()->get_one( |
|
| 111 | + array( |
|
| 112 | + array( |
|
| 113 | + 'REG_ID' => $reg_id, |
|
| 114 | + 'DTT_ID' => $dtt_id, |
|
| 115 | + ), |
|
| 116 | + 'order_by' => array( |
|
| 117 | + 'CHK_timestamp' => 'DESC', |
|
| 118 | + ), |
|
| 119 | + ) |
|
| 120 | + ); |
|
| 121 | + if (! $checkin instanceof EE_Checkin) { |
|
| 122 | + return $this->sendResponse( |
|
| 123 | + new WP_Error( |
|
| 124 | + 'rest_toggle_checkin_error', |
|
| 125 | + sprintf( |
|
| 126 | + esc_html__( |
|
| 127 | + // @codingStandardsIgnoreStart |
|
| 128 | + 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', |
|
| 129 | + // @codingStandardsIgnoreEnd |
|
| 130 | + 'event_espresso' |
|
| 131 | + ), |
|
| 132 | + $reg_id, |
|
| 133 | + $dtt_id |
|
| 134 | + ) |
|
| 135 | + ) |
|
| 136 | + ); |
|
| 137 | + } |
|
| 138 | + $get_request = new WP_REST_Request( |
|
| 139 | + 'GET', |
|
| 140 | + '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
| 141 | + ); |
|
| 142 | + $get_request->set_url_params( |
|
| 143 | + array( |
|
| 144 | + 'id' => $checkin->ID(), |
|
| 145 | + ) |
|
| 146 | + ); |
|
| 147 | + return Read::handleRequestGetOne($get_request, $version, 'Checkin'); |
|
| 148 | + } |
|
| 149 | 149 | } |
@@ -13,5 +13,5 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | abstract class JobHandler implements JobHandlerInterface |
| 15 | 15 | { |
| 16 | - // so far no common methods or properties |
|
| 16 | + // so far no common methods or properties |
|
| 17 | 17 | } |
@@ -14,5 +14,5 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class BatchRequestException extends \Exception |
| 16 | 16 | { |
| 17 | - // so far the same as exception |
|
| 17 | + // so far the same as exception |
|
| 18 | 18 | } |