@@ -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( |
@@ -25,124 +25,124 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class Checkin extends Base |
| 27 | 27 | { |
| 28 | - /** |
|
| 29 | - * @param WP_REST_Request $request |
|
| 30 | - * @param string $version |
|
| 31 | - * @return WP_Error|WP_REST_Response |
|
| 32 | - */ |
|
| 33 | - public static function handleRequestToggleCheckin(WP_REST_Request $request, $version) |
|
| 34 | - { |
|
| 35 | - $controller = new Checkin(); |
|
| 36 | - return $controller->createCheckinCheckoutObject($request, $version); |
|
| 37 | - } |
|
| 28 | + /** |
|
| 29 | + * @param WP_REST_Request $request |
|
| 30 | + * @param string $version |
|
| 31 | + * @return WP_Error|WP_REST_Response |
|
| 32 | + */ |
|
| 33 | + public static function handleRequestToggleCheckin(WP_REST_Request $request, $version) |
|
| 34 | + { |
|
| 35 | + $controller = new Checkin(); |
|
| 36 | + return $controller->createCheckinCheckoutObject($request, $version); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Toggles whether the user is checked in or not. |
|
| 42 | - * |
|
| 43 | - * @param WP_REST_Request $request |
|
| 44 | - * @param string $version |
|
| 45 | - * @return WP_Error|WP_REST_Response |
|
| 46 | - */ |
|
| 47 | - protected function createCheckinCheckoutObject(WP_REST_Request $request, $version) |
|
| 48 | - { |
|
| 49 | - $reg_id = $request->get_param('REG_ID'); |
|
| 50 | - $dtt_id = $request->get_param('DTT_ID'); |
|
| 51 | - $force = $request->get_param('force'); |
|
| 52 | - if ($force == 'true') { |
|
| 53 | - $force = true; |
|
| 54 | - } else { |
|
| 55 | - $force = false; |
|
| 56 | - } |
|
| 57 | - $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 58 | - if (! $reg instanceof EE_Registration) { |
|
| 59 | - return $this->sendResponse( |
|
| 60 | - new WP_Error( |
|
| 61 | - 'rest_registration_toggle_checkin_invalid_id', |
|
| 62 | - sprintf( |
|
| 63 | - esc_html__( |
|
| 64 | - 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', |
|
| 65 | - 'event_espresso' |
|
| 66 | - ), |
|
| 67 | - $reg_id |
|
| 68 | - ), |
|
| 69 | - array('status' => 422) |
|
| 70 | - ) |
|
| 71 | - ); |
|
| 72 | - } |
|
| 73 | - if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
| 74 | - return $this->sendResponse( |
|
| 75 | - new WP_Error( |
|
| 76 | - 'rest_user_cannot_toggle_checkin', |
|
| 77 | - sprintf( |
|
| 78 | - esc_html__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), |
|
| 79 | - $reg_id |
|
| 80 | - ), |
|
| 81 | - array('status' => 403) |
|
| 82 | - ) |
|
| 83 | - ); |
|
| 84 | - } |
|
| 85 | - $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
|
| 86 | - if ($success === false) { |
|
| 87 | - // check if we know they can't check in because they're not approved and we aren't forcing |
|
| 88 | - if (! $reg->is_approved() && ! $force) { |
|
| 89 | - // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
|
| 90 | - return $this->sendResponse( |
|
| 91 | - new WP_Error( |
|
| 92 | - 'rest_toggle_checkin_failed', |
|
| 93 | - esc_html__( |
|
| 94 | - // @codingStandardsIgnoreStart |
|
| 95 | - 'Registration check-in failed because the registration is not approved. You may attempt to force checking in though.', |
|
| 96 | - // @codingStandardsIgnoreEnd |
|
| 97 | - 'event_espresso' |
|
| 98 | - ) |
|
| 99 | - ) |
|
| 100 | - ); |
|
| 101 | - } |
|
| 102 | - return $this->sendResponse( |
|
| 103 | - new WP_Error( |
|
| 104 | - 'rest_toggle_checkin_failed_not_forceable', |
|
| 105 | - esc_html__('Registration checkin failed. Please see additional error data.', 'event_espresso') |
|
| 106 | - ) |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - $checkin = EEM_Checkin::instance()->get_one( |
|
| 110 | - array( |
|
| 111 | - array( |
|
| 112 | - 'REG_ID' => $reg_id, |
|
| 113 | - 'DTT_ID' => $dtt_id, |
|
| 114 | - ), |
|
| 115 | - 'order_by' => array( |
|
| 116 | - 'CHK_timestamp' => 'DESC', |
|
| 117 | - ), |
|
| 118 | - ) |
|
| 119 | - ); |
|
| 120 | - if (! $checkin instanceof EE_Checkin) { |
|
| 121 | - return $this->sendResponse( |
|
| 122 | - new WP_Error( |
|
| 123 | - 'rest_toggle_checkin_error', |
|
| 124 | - sprintf( |
|
| 125 | - esc_html__( |
|
| 126 | - // @codingStandardsIgnoreStart |
|
| 127 | - 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', |
|
| 128 | - // @codingStandardsIgnoreEnd |
|
| 129 | - 'event_espresso' |
|
| 130 | - ), |
|
| 131 | - $reg_id, |
|
| 132 | - $dtt_id |
|
| 133 | - ) |
|
| 134 | - ) |
|
| 135 | - ); |
|
| 136 | - } |
|
| 137 | - $get_request = new WP_REST_Request( |
|
| 138 | - 'GET', |
|
| 139 | - '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
| 140 | - ); |
|
| 141 | - $get_request->set_url_params( |
|
| 142 | - array( |
|
| 143 | - 'id' => $checkin->ID(), |
|
| 144 | - ) |
|
| 145 | - ); |
|
| 146 | - return Read::handleRequestGetOne($get_request, $version, 'Checkin'); |
|
| 147 | - } |
|
| 40 | + /** |
|
| 41 | + * Toggles whether the user is checked in or not. |
|
| 42 | + * |
|
| 43 | + * @param WP_REST_Request $request |
|
| 44 | + * @param string $version |
|
| 45 | + * @return WP_Error|WP_REST_Response |
|
| 46 | + */ |
|
| 47 | + protected function createCheckinCheckoutObject(WP_REST_Request $request, $version) |
|
| 48 | + { |
|
| 49 | + $reg_id = $request->get_param('REG_ID'); |
|
| 50 | + $dtt_id = $request->get_param('DTT_ID'); |
|
| 51 | + $force = $request->get_param('force'); |
|
| 52 | + if ($force == 'true') { |
|
| 53 | + $force = true; |
|
| 54 | + } else { |
|
| 55 | + $force = false; |
|
| 56 | + } |
|
| 57 | + $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 58 | + if (! $reg instanceof EE_Registration) { |
|
| 59 | + return $this->sendResponse( |
|
| 60 | + new WP_Error( |
|
| 61 | + 'rest_registration_toggle_checkin_invalid_id', |
|
| 62 | + sprintf( |
|
| 63 | + esc_html__( |
|
| 64 | + 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', |
|
| 65 | + 'event_espresso' |
|
| 66 | + ), |
|
| 67 | + $reg_id |
|
| 68 | + ), |
|
| 69 | + array('status' => 422) |
|
| 70 | + ) |
|
| 71 | + ); |
|
| 72 | + } |
|
| 73 | + if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
| 74 | + return $this->sendResponse( |
|
| 75 | + new WP_Error( |
|
| 76 | + 'rest_user_cannot_toggle_checkin', |
|
| 77 | + sprintf( |
|
| 78 | + esc_html__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), |
|
| 79 | + $reg_id |
|
| 80 | + ), |
|
| 81 | + array('status' => 403) |
|
| 82 | + ) |
|
| 83 | + ); |
|
| 84 | + } |
|
| 85 | + $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
|
| 86 | + if ($success === false) { |
|
| 87 | + // check if we know they can't check in because they're not approved and we aren't forcing |
|
| 88 | + if (! $reg->is_approved() && ! $force) { |
|
| 89 | + // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
|
| 90 | + return $this->sendResponse( |
|
| 91 | + new WP_Error( |
|
| 92 | + 'rest_toggle_checkin_failed', |
|
| 93 | + esc_html__( |
|
| 94 | + // @codingStandardsIgnoreStart |
|
| 95 | + 'Registration check-in failed because the registration is not approved. You may attempt to force checking in though.', |
|
| 96 | + // @codingStandardsIgnoreEnd |
|
| 97 | + 'event_espresso' |
|
| 98 | + ) |
|
| 99 | + ) |
|
| 100 | + ); |
|
| 101 | + } |
|
| 102 | + return $this->sendResponse( |
|
| 103 | + new WP_Error( |
|
| 104 | + 'rest_toggle_checkin_failed_not_forceable', |
|
| 105 | + esc_html__('Registration checkin failed. Please see additional error data.', 'event_espresso') |
|
| 106 | + ) |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + $checkin = EEM_Checkin::instance()->get_one( |
|
| 110 | + array( |
|
| 111 | + array( |
|
| 112 | + 'REG_ID' => $reg_id, |
|
| 113 | + 'DTT_ID' => $dtt_id, |
|
| 114 | + ), |
|
| 115 | + 'order_by' => array( |
|
| 116 | + 'CHK_timestamp' => 'DESC', |
|
| 117 | + ), |
|
| 118 | + ) |
|
| 119 | + ); |
|
| 120 | + if (! $checkin instanceof EE_Checkin) { |
|
| 121 | + return $this->sendResponse( |
|
| 122 | + new WP_Error( |
|
| 123 | + 'rest_toggle_checkin_error', |
|
| 124 | + sprintf( |
|
| 125 | + esc_html__( |
|
| 126 | + // @codingStandardsIgnoreStart |
|
| 127 | + 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', |
|
| 128 | + // @codingStandardsIgnoreEnd |
|
| 129 | + 'event_espresso' |
|
| 130 | + ), |
|
| 131 | + $reg_id, |
|
| 132 | + $dtt_id |
|
| 133 | + ) |
|
| 134 | + ) |
|
| 135 | + ); |
|
| 136 | + } |
|
| 137 | + $get_request = new WP_REST_Request( |
|
| 138 | + 'GET', |
|
| 139 | + '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
| 140 | + ); |
|
| 141 | + $get_request->set_url_params( |
|
| 142 | + array( |
|
| 143 | + 'id' => $checkin->ID(), |
|
| 144 | + ) |
|
| 145 | + ); |
|
| 146 | + return Read::handleRequestGetOne($get_request, $version, 'Checkin'); |
|
| 147 | + } |
|
| 148 | 148 | } |
@@ -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 | } |
@@ -4,63 +4,63 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface HasSchemaInterface |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Returns whatever is set as the nicename for the object. |
|
| 9 | - * |
|
| 10 | - * @return string |
|
| 11 | - */ |
|
| 12 | - public function getSchemaDescription(); |
|
| 7 | + /** |
|
| 8 | + * Returns whatever is set as the nicename for the object. |
|
| 9 | + * |
|
| 10 | + * @return string |
|
| 11 | + */ |
|
| 12 | + public function getSchemaDescription(); |
|
| 13 | 13 | |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Returns whatever is set as the $_schema_type property for the object. |
|
| 17 | - * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
| 18 | - * |
|
| 19 | - * @return string|array |
|
| 20 | - */ |
|
| 21 | - public function getSchemaType(); |
|
| 15 | + /** |
|
| 16 | + * Returns whatever is set as the $_schema_type property for the object. |
|
| 17 | + * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
| 18 | + * |
|
| 19 | + * @return string|array |
|
| 20 | + */ |
|
| 21 | + public function getSchemaType(); |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
| 26 | - * this method and return the properties for the schema. |
|
| 27 | - * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
| 28 | - * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
| 29 | - * |
|
| 30 | - * @return array |
|
| 31 | - */ |
|
| 32 | - public function getSchemaProperties(); |
|
| 24 | + /** |
|
| 25 | + * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
| 26 | + * this method and return the properties for the schema. |
|
| 27 | + * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
| 28 | + * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
| 29 | + * |
|
| 30 | + * @return array |
|
| 31 | + */ |
|
| 32 | + public function getSchemaProperties(); |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * If a child class has enum values, they should override this method and provide a simple array |
|
| 36 | - * of the enum values. |
|
| 37 | - * The reason this is not a property on the class is because there may be filterable enum values that |
|
| 38 | - * are set on the instantiated object that could be filtered after construct. |
|
| 39 | - * |
|
| 40 | - * @return array |
|
| 41 | - */ |
|
| 42 | - public function getSchemaEnum(); |
|
| 34 | + /** |
|
| 35 | + * If a child class has enum values, they should override this method and provide a simple array |
|
| 36 | + * of the enum values. |
|
| 37 | + * The reason this is not a property on the class is because there may be filterable enum values that |
|
| 38 | + * are set on the instantiated object that could be filtered after construct. |
|
| 39 | + * |
|
| 40 | + * @return array |
|
| 41 | + */ |
|
| 42 | + public function getSchemaEnum(); |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * This returns the value of the $_schema_format property on the object. |
|
| 46 | - * |
|
| 47 | - * @return string |
|
| 48 | - */ |
|
| 49 | - public function getSchemaFormat(); |
|
| 44 | + /** |
|
| 45 | + * This returns the value of the $_schema_format property on the object. |
|
| 46 | + * |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 49 | + public function getSchemaFormat(); |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * This returns the value of the $_schema_readonly property on the object. |
|
| 53 | - * |
|
| 54 | - * @return bool |
|
| 55 | - */ |
|
| 56 | - public function getSchemaReadonly(); |
|
| 51 | + /** |
|
| 52 | + * This returns the value of the $_schema_readonly property on the object. |
|
| 53 | + * |
|
| 54 | + * @return bool |
|
| 55 | + */ |
|
| 56 | + public function getSchemaReadonly(); |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * This returns elements used to represent this field in the json schema. |
|
| 61 | - * |
|
| 62 | - * @link http://json-schema.org/ |
|
| 63 | - * @return array |
|
| 64 | - */ |
|
| 65 | - public function getSchema(); |
|
| 59 | + /** |
|
| 60 | + * This returns elements used to represent this field in the json schema. |
|
| 61 | + * |
|
| 62 | + * @link http://json-schema.org/ |
|
| 63 | + * @return array |
|
| 64 | + */ |
|
| 65 | + public function getSchema(); |
|
| 66 | 66 | } |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | interface CaffeinatedInterface |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Used to indicate when functionality is caffeinated or not. |
|
| 17 | - * @return bool |
|
| 18 | - */ |
|
| 19 | - public function isCaffeinated(); |
|
| 15 | + /** |
|
| 16 | + * Used to indicate when functionality is caffeinated or not. |
|
| 17 | + * @return bool |
|
| 18 | + */ |
|
| 19 | + public function isCaffeinated(); |
|
| 20 | 20 | } |
@@ -5,8 +5,8 @@ |
||
| 5 | 5 | interface SessionIdentifierInterface |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * @return string |
|
| 10 | - */ |
|
| 11 | - public function id(); |
|
| 8 | + /** |
|
| 9 | + * @return string |
|
| 10 | + */ |
|
| 11 | + public function id(); |
|
| 12 | 12 | } |
@@ -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 | ); |
@@ -14,19 +14,19 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class WordPress extends Basic |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @param string $email_address |
|
| 19 | - * @return boolean |
|
| 20 | - * @throws EmailValidationException |
|
| 21 | - */ |
|
| 22 | - public function validate($email_address) |
|
| 23 | - { |
|
| 24 | - parent::validate($email_address); |
|
| 25 | - if (! is_email($email_address)) { |
|
| 26 | - throw new EmailValidationException( |
|
| 27 | - esc_html__('The email address provided is not valid.', 'event_espresso') |
|
| 28 | - ); |
|
| 29 | - } |
|
| 30 | - return true; |
|
| 31 | - } |
|
| 17 | + /** |
|
| 18 | + * @param string $email_address |
|
| 19 | + * @return boolean |
|
| 20 | + * @throws EmailValidationException |
|
| 21 | + */ |
|
| 22 | + public function validate($email_address) |
|
| 23 | + { |
|
| 24 | + parent::validate($email_address); |
|
| 25 | + if (! is_email($email_address)) { |
|
| 26 | + throw new EmailValidationException( |
|
| 27 | + esc_html__('The email address provided is not valid.', 'event_espresso') |
|
| 28 | + ); |
|
| 29 | + } |
|
| 30 | + return true; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -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()); |
@@ -15,41 +15,41 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class CreateTicketLineItemService extends DomainService |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @param \EE_Transaction $transaction |
|
| 20 | - * @param \EE_Ticket $ticket |
|
| 21 | - * @param int $quantity |
|
| 22 | - * @return \EE_Line_Item |
|
| 23 | - * @throws \EE_Error |
|
| 24 | - * @throws UnexpectedEntityException |
|
| 25 | - */ |
|
| 26 | - public function create( |
|
| 27 | - \EE_Transaction $transaction, |
|
| 28 | - \EE_Ticket $ticket, |
|
| 29 | - $quantity = 1 |
|
| 30 | - ) { |
|
| 31 | - $total_line_item = $transaction->total_line_item(); |
|
| 32 | - if (! $total_line_item instanceof \EE_Line_Item) { |
|
| 33 | - throw new UnexpectedEntityException($total_line_item, 'EE_Line_Item'); |
|
| 34 | - } |
|
| 35 | - // create new line item for ticket |
|
| 36 | - $ticket_line_item = \EEH_Line_Item::add_ticket_purchase( |
|
| 37 | - $total_line_item, |
|
| 38 | - $ticket, |
|
| 39 | - $quantity |
|
| 40 | - ); |
|
| 41 | - if (! $ticket_line_item instanceof \EE_Line_Item) { |
|
| 42 | - throw new UnexpectedEntityException($ticket_line_item, 'EE_Line_Item'); |
|
| 43 | - } |
|
| 44 | - $total_line_item->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 45 | - // apply any applicable promotions that were initially used during registration to new line items |
|
| 46 | - do_action( |
|
| 47 | - 'AHEE__\EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler__handle__new_ticket_line_item_added', |
|
| 48 | - $total_line_item, |
|
| 49 | - $ticket, |
|
| 50 | - $transaction, |
|
| 51 | - $quantity |
|
| 52 | - ); |
|
| 53 | - return $ticket_line_item; |
|
| 54 | - } |
|
| 18 | + /** |
|
| 19 | + * @param \EE_Transaction $transaction |
|
| 20 | + * @param \EE_Ticket $ticket |
|
| 21 | + * @param int $quantity |
|
| 22 | + * @return \EE_Line_Item |
|
| 23 | + * @throws \EE_Error |
|
| 24 | + * @throws UnexpectedEntityException |
|
| 25 | + */ |
|
| 26 | + public function create( |
|
| 27 | + \EE_Transaction $transaction, |
|
| 28 | + \EE_Ticket $ticket, |
|
| 29 | + $quantity = 1 |
|
| 30 | + ) { |
|
| 31 | + $total_line_item = $transaction->total_line_item(); |
|
| 32 | + if (! $total_line_item instanceof \EE_Line_Item) { |
|
| 33 | + throw new UnexpectedEntityException($total_line_item, 'EE_Line_Item'); |
|
| 34 | + } |
|
| 35 | + // create new line item for ticket |
|
| 36 | + $ticket_line_item = \EEH_Line_Item::add_ticket_purchase( |
|
| 37 | + $total_line_item, |
|
| 38 | + $ticket, |
|
| 39 | + $quantity |
|
| 40 | + ); |
|
| 41 | + if (! $ticket_line_item instanceof \EE_Line_Item) { |
|
| 42 | + throw new UnexpectedEntityException($ticket_line_item, 'EE_Line_Item'); |
|
| 43 | + } |
|
| 44 | + $total_line_item->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 45 | + // apply any applicable promotions that were initially used during registration to new line items |
|
| 46 | + do_action( |
|
| 47 | + 'AHEE__\EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler__handle__new_ticket_line_item_added', |
|
| 48 | + $total_line_item, |
|
| 49 | + $ticket, |
|
| 50 | + $transaction, |
|
| 51 | + $quantity |
|
| 52 | + ); |
|
| 53 | + return $ticket_line_item; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -4,31 +4,31 @@ |
||
| 4 | 4 | interface SetHooksInterface |
| 5 | 5 | { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * a place to add action and filter hooks for regular frontend requests |
|
| 9 | - * |
|
| 10 | - * @return void |
|
| 11 | - */ |
|
| 12 | - public function setHooks(); |
|
| 7 | + /** |
|
| 8 | + * a place to add action and filter hooks for regular frontend requests |
|
| 9 | + * |
|
| 10 | + * @return void |
|
| 11 | + */ |
|
| 12 | + public function setHooks(); |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * a place to add action and filter hooks for regular WP admin requests |
|
| 16 | - * |
|
| 17 | - * @return void |
|
| 18 | - */ |
|
| 19 | - public function setAdminHooks(); |
|
| 14 | + /** |
|
| 15 | + * a place to add action and filter hooks for regular WP admin requests |
|
| 16 | + * |
|
| 17 | + * @return void |
|
| 18 | + */ |
|
| 19 | + public function setAdminHooks(); |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * a place to add action and filter hooks for AJAX requests |
|
| 23 | - * |
|
| 24 | - * @return void |
|
| 25 | - */ |
|
| 26 | - public function setAjaxHooks(); |
|
| 21 | + /** |
|
| 22 | + * a place to add action and filter hooks for AJAX requests |
|
| 23 | + * |
|
| 24 | + * @return void |
|
| 25 | + */ |
|
| 26 | + public function setAjaxHooks(); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * a place to add action and filter hooks for REST API requests |
|
| 30 | - * |
|
| 31 | - * @return void |
|
| 32 | - */ |
|
| 33 | - public function setApiHooks(); |
|
| 28 | + /** |
|
| 29 | + * a place to add action and filter hooks for REST API requests |
|
| 30 | + * |
|
| 31 | + * @return void |
|
| 32 | + */ |
|
| 33 | + public function setApiHooks(); |
|
| 34 | 34 | } |
@@ -14,34 +14,34 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | interface CapabilitiesActionRestrictionInterface |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Return whether the item can be edited for the given context. |
|
| 19 | - * @param Context $context |
|
| 20 | - * @return bool |
|
| 21 | - */ |
|
| 22 | - public function canEdit(Context $context); |
|
| 23 | - |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Return whether the item can be read for the given context. |
|
| 27 | - * @param Context $context |
|
| 28 | - * @return bool |
|
| 29 | - */ |
|
| 30 | - public function canRead(Context $context); |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Return whether the item can be deleted for the given context. |
|
| 35 | - * @param Context $context |
|
| 36 | - * @return bool |
|
| 37 | - */ |
|
| 38 | - public function canDelete(Context $context); |
|
| 39 | - |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Return whether the item can be created for the given context |
|
| 43 | - * @param Context $context |
|
| 44 | - * @return bool |
|
| 45 | - */ |
|
| 46 | - public function canCreate(Context $context); |
|
| 17 | + /** |
|
| 18 | + * Return whether the item can be edited for the given context. |
|
| 19 | + * @param Context $context |
|
| 20 | + * @return bool |
|
| 21 | + */ |
|
| 22 | + public function canEdit(Context $context); |
|
| 23 | + |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Return whether the item can be read for the given context. |
|
| 27 | + * @param Context $context |
|
| 28 | + * @return bool |
|
| 29 | + */ |
|
| 30 | + public function canRead(Context $context); |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Return whether the item can be deleted for the given context. |
|
| 35 | + * @param Context $context |
|
| 36 | + * @return bool |
|
| 37 | + */ |
|
| 38 | + public function canDelete(Context $context); |
|
| 39 | + |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Return whether the item can be created for the given context |
|
| 43 | + * @param Context $context |
|
| 44 | + * @return bool |
|
| 45 | + */ |
|
| 46 | + public function canCreate(Context $context); |
|
| 47 | 47 | } |