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
Propel storage bridge #306
Conversation
protected function getModelId($model) | ||
{ | ||
$id = array(); | ||
$modelPeer = get_class($model).'Peer'; |
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'd prefer to move it to constructor, even better if you allow a developer to pass it as a second argument. query could be passed same,
They could optional and user do not provide them then you can build it in constructor.
Looking forward to merge it, Tests and docs are left.... |
by the way is it Propel 1 or 2? |
@makasim I'm working with 1.7 propel branch, hopefully it will get tested by 2.0 branch as well. |
Does 2.0 propel backward compatible? TODO: Add a storage factory to symfony bundle,just a note for me anybody else who want to do it. |
@makasim I'm not sure, I've never had chance to use 2.0 in any project. As soon as it will be stable, I'l probably switch it in projects. |
Hi, nice job. Unfortunately this PR will not work with Propel 2. Peer classes have been removed for exemple and with this PR more BC break will be introduced |
I've created a few tests based on @liamsorsby file and have a few questions.
|
yes, sure, I am just thinking about the names. Maybe it is better to call this storage as |
I do not think you need a bundle, the propel lib would be enough. |
This approach looks good to me. |
- rename bridge storage and test class - add mock objects for testing - fix unit testing
@makasim we have to talk about storage usage in payum bundle. As I said here #144 (comment) I'm having trouble to configure it in working environment. Both models (token + order) writes to DB correctly, but request ends up with an error "Request Capture{model: Order} is not supported." I'm sure there is a problem in configuration as shown in gists, but I have no clue how to test. |
Ok, I just found I'm missing interface for Order model (BaseOrder is generated by propel1).
Now I'm getting "Request GetHumanStatus{model: NULL} is not supported." exception. Seems like I'm still missing one piece. Stack trace:
|
Seems like order->getDetails() returns NULL but it must be an array |
Yes, that is right. Order details are not saved. Token details are saved successfully. |
What is being used in the app/config file for storage as I keep getting Unrecognized option "propel" under "payum.security.token_storage.Acme\DemoBundle\Model\Token" or have I jumped a few steps? |
@liamsorsby I believe you mess things up. The storage we are discussing here is not related to one in the bundle config. The config one has to be address separately after we are done with this storage One we have this storage we can create a storage factory in bundle to simplify its creation. Somethin like doctrine: https://github.com/Payum/PayumBundle/blob/master/DependencyInjection/Factory/Storage/DoctrineStorageFactory.php |
@makasim So I'm right in thinking I've skipped the step that you are working on and Instead of working on the Payum bundle for symfony, I should be working on the Payum bundle and getting that to work without any framework? Is that correct? |
This PR is about a storage that could be reused in plain php or with any other frameworks. In PayumBundle you can use with custom storage factory. like this: payum:
security:
token_storage:
AppBundle\Model\Token:
custom: appbundle.payum.storage.propel.token
storages:
AppBundle\Model\Order:
custom: appbundle.payum.storage.propel.order
payments:
offline:
offline: ~
services:
appbundle.payum.storage.propel.order:
class: Payum\Core\Bridge\Propel\Storage\Propel1Storage
arguments: ["AppBundle\\Model\\Order"]
appbundle.payum.storage.propel.token:
class: Payum\Core\Bridge\Propel\Storage\Propel1Storage
arguments: ["AppBundle\\Model\\Token"] Later we may add a specific factory, like doctrine one. |
*/ | ||
public function findBy(array $criteria) | ||
{ | ||
throw new LogicException('Method is not supported by the storage.'); |
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.
is it really not supported? It is hard to implement such method for filesystem storage but should be possible for propel.
(we can do it as separate PR)
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.
@jkabat I wil check it out tomorrow, the bug he has pointed out may have been the issue that I was encountering when testing a payment. However, with the current it was the token I was struggling to set. Also, is the storage going to be different for propel 2? As the current storage uses peer |
There will be separate Storage for Propel2. This one is named Propel1Storage. |
It's part of the propel1 library. |
@jkabat thanks. |
@jkabat Could you please add a short usage guide here (like one for Doctrine) https://github.com/Payum/Payum/blob/master/src/Payum/Core/Resources/docs/storages.md#doctrine-orm |
I'me just discovering this bundle and glad to see that a Propel version has just been merged! @jkabat @liamsorsby could you confirm that the propel version is ok - because you seem to talk about a bug? |
@makasim Ill do that as soon as Ill get some spare time. |
The storages (for Propel1\2 were already added). You just have to add a bundle specific factory to make it work in the bundle. |
@makasim Should I make a pull request and add the propel specific storage onto the bundle? |
Would be great If you have time. |
@makasim I'll get onto doing it probably tomorrow now but I'll get it done by the end of the week (hopefully) |
@makasim Sorry for the delay! Just working on this now, does it need two storage implementations for propel1 and propel2? Or can it use a similar method to doctrine with the dynamic driver in the addConfigurations? |
Yes, it is. It should be two separate factories.
sorry dont get this question, Are you asking about ability to extend abstract storage, if it helps you can do it. |
@makasim Sorry, my question wasn't overly clear. Thats all I needed with regards to clarification on being two seperate factories. I've got to a point now where I've implemented the model and the extension but I seem to be getting this error: Unrecognized options "storage_dir", id_property" under "payum.security.token_storage.Acme\DemoBundle\Model\Token.propel1" any thoughts on what this could be just to push me in the right direction. |
Hm |
So to clarify these should not be needed at all as the 1st parameter should be the modelClass. Would that be correct? |
yeap, and maybe some options which propel may require |
@makasim Last question, I've pretty much got everything together, however I can't seem to work this last bit out, if you wouldn't mind pointing me in the right direction. I've added two seperate configs one for propel1 and one for propel2. The config would look like this:
I've used a similar configuration builder to Doctrine but it doesn't seem to pass through the correct file name.
As with Doctrine it should pass through orm or Mongodb, but it seems to be passing through the class rather than the actual parameter. Have you got any thoughts on how to tweek this as this should be the last section to finish this off. |
Hm, I this it should be done the other way. The config must be like this: Payum:
Security:
Path\To\Your\Token\Model: { propel1: ~ }
Storages:
Path\To\Your\Payment\Model: { propel2: ~ }
gateways:
offline:
offline: ~ So you dont need any magic with parameters. |
@makasim @jkabat Just looking at the implementatpion and was thinking. Shouldn't Propel also have the GatewayConfig and ArrayObject mappings as Doctrine does? Not sure if it would be possible but it looks like it may be needed as the following will not work without it. Example: $gateway = "paypal_express_gateway_name";
$storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails');
$details = $storage->create();
$details['PAYMENTREQUEST_0_CURRENCYCODE'] = "USD";
$storage->update($details);
$captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
$gatewayName,
$details,
'acme_payment_done'
);
return $this->redirect($captureToken->getTargetUrl()); Throws the following error:
|
It would be good to provide basic mappings for the models, but as far as I know it is a bit hard to do for Propel. You can always implement ArrayAccess interface to your model, the example will works in this case. |
I'll give it a go and if it works then I'll add this to the current PR. |
Doesn't seem to like it:
|
Please Open separate issue for it with some more info like, the payum version, what gateway are you using and some other that you think may help to debug it. |
No description provided.