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

Active record storage #4

Open
wants to merge 13 commits into
base: active-record-storage
Choose a base branch
from

Conversation

martynling
Copy link

This is a pretty rough but effective means of implementing ActiveRecord storage. I needed ActiveRecord storage working for Payum in a hurry, so found what seemed the simplest solution to me. I suspect that you may want to implement it in a more elegant way, but I did the following:

  • For token storage, I extended Payum\Core\Model\Token and gave it an activeRecord property. In the __construct method, when a new object is being created, the activeRecord property is set to a new TokenActiveRecord (an extension of ActiveRecord). Given that Payum is usually expecting a token, I give it a token with the active record more or less hidden within it.
  • For payment detail storage, I took a similar approach by extending ArrayObject and giving it an activeRecord property. On __construct it creates a new PaymentActiveRecord (you guessed it, an extension of ActiveRecord).

It needs some tidying up if it were to be merged in... but I'll hold off on doing that since you may not want to merge it in anyway. If you go ahead with a more elegant solution, I'll probably switch to that further down the line.

Anyway, here it is, just in case it's helpful to you or someone else.

@makasim
Copy link
Member

makasim commented Jan 3, 2014

@martynling thanks for sharing! is this working version?

I am not yii expert so it would be hard for me to review, in any case I would do it.

@makasim
Copy link
Member

makasim commented Jan 3, 2014

@martynling could you write a chapter how to use it so I can install it on my yii sandbox and play a bit.

@makasim
Copy link
Member

makasim commented Jan 3, 2014

here's sandbox repo: https://github.com/makasim/PayumYiiSandbox

@martynling
Copy link
Author

@makasim Yes, it's a working version. I'll write the "how to use it" section next week sometime. Glad to share. :-)

@makasim
Copy link
Member

makasim commented Jan 4, 2014

For token storage, I extended Payum\Core\Model\Token and gave it an activeRecord property. In the __construct method, when a new object is being created, the activeRecord property is set to a new TokenActiveRecord (an extension of ActiveRecord). Given that Payum is usually expecting a token, I give it a token with the active record more or less hidden within it.

Could it be possible to create TokenActiveRecord that implements TokenInterface? payum expects it.

@makasim
Copy link
Member

makasim commented Jan 4, 2014

For payment detail storage, I took a similar approach by extending ArrayObject and giving it an activeRecord property. On __construct it creates a new PaymentActiveRecord (you guessed it, an extension of ActiveRecord).

same here, why should we hide active record inside the other model. Why not create active record model that implements array access interface?

@makasim
Copy link
Member

makasim commented Jan 4, 2014

It needs some tidying up if it were to be merged in... but I'll hold off on doing that since you may not want to merge it in anyway.

I am looking forward to merge it (:. indeed we have to clean things up a bit

@martynling
Copy link
Author

@makasim Sorry for the delay on this - I moved house last weekend and there's a problem getting connected to the Internet. I should be fully back in action next week and will get to work on this then.

@makasim
Copy link
Member

makasim commented Jan 9, 2014

@martynling congrats on moving to new house!

@makasim
Copy link
Member

makasim commented Jan 14, 2014

@martynling any news on this?

@martynling
Copy link
Author

@makasim Still got connection problems... and there have been 2 days of public holiday so no progress. Once I get connected again, I'll get to it. Next week, hopefully.

@martynling
Copy link
Author

@makasim I've added the How to use... chapter this morning. Let me know what you think.

@makasim
Copy link
Member

makasim commented Feb 11, 2014

great! I will try it in my sandbox asap.

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