Add events and logging for payments#797
Add events and logging for payments#797heddn wants to merge 4 commits intodrupalcommerce:8.x-2.xfrom
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.
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.
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.
Ah, that's true. I ignored that important item. I was still in d7 array mode.
| fail: 'not found' | ||
| validate_options: { } | ||
| break_phrase: false | ||
| break_phrase: true |
There was a problem hiding this comment.
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.
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.
I figured that insert, update, delete and refund are the only things of interest.
There was a problem hiding this comment.
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 |
| * | ||
| * @see \Drupal\commerce_payment\Event\PaymentEvent | ||
| */ | ||
| const PAYMENT_INSERT = 'commerce_payment.commerce_payment.insert'; |
There was a problem hiding this comment.
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.