2013-10-08 3 views
9

Ich mache dies, um nicht Annotation Mapping meines Dokuments zuordnen. Aber es holt es nicht auf. Ich weiß, dass es alter Code ist, aber weiß jemand, wie man es richtig abbildet. Vielen Dank!richtige Möglichkeit zum Laden von mongodb Hash zugeordneten Array-Mapping, wenn keine Anmerkungen mit seltsamen Zugriffsmethoden

assoziiert PR = https://github.com/Payum/PaypalExpressCheckoutNvp/pull/12/files#diff-fcfa75e424ccb89d62449aba21f9db31R49

Und auch im Zusammenhang mit diesem: https://groups.google.com/forum/#!topic/doctrine-user/MdIoOMWA7F4 https://github.com/doctrine/mongodb-odm/issues/421 https://github.com/doctrine/mongodb-odm/issues/453

<?php 

abstract class MongoTest extends BaseMongoTest 
{ 
/** 
* {@inheritDoc} 
*/ 
protected function getMetadataDriverImpl() 
{ 
    $rootDir = realpath(__DIR__.'/../../../../../../../../../'); 
    if (false === $rootDir || false === is_dir($rootDir.'/src/Payum')) { 
     throw new \RuntimeException('Cannot guess Payum root dir.'); 
    } 

$driver = new MappingDriverChain; 
    $xmlDriver = new XmlDriver(
     new SymfonyFileLocator(
      array(
       $rootDir.'/src/Payum/Paypal/ExpressCheckout/Nvp/Bridge/Doctrine/Resources/mapping' 
       => 'Payum\Paypal\ExpressCheckout\Nvp\Bridge\Doctrine\Document', 
       $rootDir.'/examples/Payum/Paypal/ExpressCheckout/Nvp/Examples/Resources/mapping' 
       => 'Payum\Paypal\ExpressCheckout\Nvp\Examples\Document' 
      ), 
      '.mongodb.xml' 
     ), 
     '.mongodb.xml' 
    ); 
    $driver->addDriver($xmlDriver, 'Payum\Paypal\ExpressCheckout\Nvp\Examples\Document'); 
    $driver->addDriver($xmlDriver, 'Payum\Paypal\ExpressCheckout\Nvp\Bridge\Doctrine\Document'); 


    return $driver; 
} 

ich Fehler von 2 Tests bekommen scheitern, weil es keine Persistenz der Wert Eigenschaften von PaymentDetail Dokument ist unter Beispielordner. Hier

ist die Abbildung der PaymentDetails

https://github.com/cordoval/PaypalExpressCheckoutNvp/blob/mongo-tests/src/Payum/Paypal/ExpressCheckout/Nvp/Bridge/Doctrine/Resources/mapping/PaymentDetails.mongodb.xml?pr=%2FPayum%2FPaypalExpressCheckoutNvp%2Fpull%2F12

und die Zuordnung für den Super

https://github.com/cordoval/PaypalExpressCheckoutNvp/blob/mongo-tests/examples/Payum/Paypal/ExpressCheckout/Nvp/Examples/Resources/mapping/PaymentDetails.mongodb.xml?pr=%2FPayum%2FPaypalExpressCheckoutNvp%2Fpull%2F12

Es scheint, das Problem wegen der seltsamen Setter/Getter von Basemodel ist, das ist erweitert um PaymentDetails.

protected $paymentrequest_nnn_amt = array(); 

    public function getPaymentrequestAmt($n = null) 
    { 
     return $this->get('paymentrequest_nnn_amt', $n); 
    } 

    public function setPaymentrequestAmt($n, $value) 
    { 
     $this->set('paymentrequest_nnn_amt', $value, $n); 
    } 

, die oben von einer Zwischenbasisklasse ist, und hier ist unten von der Basisklasse

/** 
* @param string $property 
* @param bool $n 
* @param bool $m 
* 
* @return mixed 
*/ 
protected function get($property, $n = false, $m = false) 
{ 
    $currentValue = $this->$property; 
    if (false !== $n && false !== $m) { 
     if (null === $n && null === $m) { 
      return $currentValue; 
     } 
     if (array_key_exists($n, $currentValue) && array_key_exists($m,$currentValue[$n]){ 
      return $currentValue[$n][$m]; 
     } 
    } 
    if (null === $n) { 
     return $currentValue; 
    } 
    if (array_key_exists($n, $currentValue)) { 
     return $currentValue[$n]; 
    } 
} 
+0

Schauen Sie sich dies an [Payum \ Payum # 50] (https://github.com/Payum/Payum/pull/50/files). Ich habe die Problemumgehung, die ich für das Token-Dokument gemacht habe, wieder rückgängig gemacht und jetzt scheitert es auch. Es sollte einfacher zu debuggen, denn es gibt einfache Setter \ Getter –

Antwort

1

Ich fand heraus, und das Problem behoben. Es gab mehr Problem, das ich in laufen habe:

  • Zuerst Nach ORM für lange Zeit mit Mir war verwirrt, dass name ein Feld in Mongo ist und fieldName ist ein Eigenschaftsname (issue).
  • Zweitens, wenn die fieldName keine Eigenschaft entspricht, ist es nur silently skipped (wo ORM löst Ausnahme). So war es schwer herauszufinden, warum die Immobilie nicht gespeichert wurde. (issue).

Nach fixing the mapping funktioniert alles gut.

+0

@cordoval seltsame Accessoren ist nicht das Problem (: –

Verwandte Themen