Skip to content
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

Open
wants to merge 4 commits into
base: 8.x-2.x
Choose a base branch
from

Conversation

heddn
Copy link

@heddn heddn commented Sep 14, 2017

This takes pieces from #610 and #791 and combines them.


function commerce_log_entity_type_alter(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['commerce_payment']->setListBuilderClass(PaymentListBuilder::class);
Copy link
Author

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.

Copy link
Contributor

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?

Copy link
Author

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
Copy link
Author

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'] = [
Copy link
Author

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:
Copy link
Author

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.

Copy link
Author

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.

@mglaman mglaman mentioned this pull request Sep 16, 2017

commerce_payment:
label: Payment
entity_type: commerce_payment
Copy link
Author

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';
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants