-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add events and logging for payments #797
base: 8.x-2.x
Are you sure you want to change the base?
Conversation
modules/log/commerce_log.module
Outdated
|
||
function commerce_log_entity_type_alter(array &$entity_types) { | ||
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ | ||
$entity_types['commerce_payment']->setListBuilderClass(PaymentListBuilder::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't care if the module is enabled, if it isn't this will just get ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the module is disabled there won't be an $entity_types['commerce_payment'] object, causing a crash, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's true. I ignored that important item. I was still in d7 array mode.
@@ -337,7 +337,7 @@ display: | |||
type: none | |||
fail: 'not found' | |||
validate_options: { } | |||
break_phrase: false | |||
break_phrase: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This let's us pass in multiple entity id arguments to the source id contextual argument.
foreach ($this->load() as $entity) { | ||
$entityIds[] = $entity->id(); | ||
} | ||
$build['log']['title'] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe some views expert will figure out how to print the title. It didn't want to. So I punted and did this hack.
category: commerce_payment | ||
label: 'Payment deleted' | ||
template: '<p>Payment of {{ amount|commerce_price_format }} was deleted.</p>' | ||
payment_refunded: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured that insert, update, delete and refund are the only things of interest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like we want more details in the messages. Let's add the current state as part of the log too.
|
||
commerce_payment: | ||
label: Payment | ||
entity_type: commerce_payment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this read commerce_order?
* | ||
* @see \Drupal\commerce_payment\Event\PaymentEvent | ||
*/ | ||
const PAYMENT_INSERT = 'commerce_payment.commerce_payment.insert'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see an INSERT and a CREATE in product variation events. Do we need to duplicate the same here? The docs between the two aren't very clear about what the difference is.
This takes pieces from #610 and #791 and combines them.