[Flow] One-To-One Bidirectional only one site available

Martin Keck keck at bloomproject.de
Sat Jan 25 11:40:18 CET 2014


Hi Alex,

afaik you have to set the bidirection manually, meaning you set object 1 on object 2 and vice versa. Example:

// create the objects --> for sure those objects could come from a form or something else
$scheduledPayment = new \Qbus\Bestdesq\Project\Domain\Model\ScheduledPayment();
$invoice = new \Qbus\Bestdesq\Project\Domain\Model\Invoice();

// connect the objects to each other
$invoice->setScheduledPayment($scheduledPayment);
$scheduledPayment->setInvoice($invoice);

// add one object to its repository
$this->invoiceRepository->add($invoice);

Another way could be to create an (empty) scheduledPayment of the invoice in the constructor of invoice and establish the connection already when the invoice is created:

public function __construct() {
        $scheduledPayment = new \Qbus\Bestdesq\Project\Domain\Model\ScheduledPayment();
	$scheduledPayment->setInvoice($this);
	$this->setScheduledPayment($scheduledPayment);
    }

The properties of scheduledPayment could then be changed later.

Hope that helps.

Greetings
Martin



Am 24.01.2014 um 21:59 schrieb Axel Wüstemann <awu at qbus.de>:

> Hello,
> 
> for a business planning solution I have scheduledPayments (planned payments) and invoices. I have established a bidirectional one to one relation
> 
> /**
> * @Flow\Entity
> */
> class Invoice {
> 
> ...
> 
> /**
> * @var Qbus\Bestdesq\Project\Domain\Model\ScheduledPayment
> * @ORM\OneToOne(mappedBy="invoice")
> */
> protected $scheduledPayment;
> 
> /**
> * @Flow\Entity
> */
> class ScheduledPayment
> 
> ...
> 
> /**
> * @var Qbus\Bestdesq\Project\Domain\Model\Invoice
> * @ORM\OneToOne(inversedBy="scheduledPayment")
> */
> protected $invoice;
> 
> 
> 
> When I enter e new invoice I select one of the available scheduledPayments. As a result invoice->scheduledPayment is correctly set but the opposit scheduledPayment->invoice remains empty.
> 
> In a dashboard list I want to show all scheduledPayments which have not yet an invoice.
> 
> How to implement such scenario correctly?
> 
> Thanks
> Axel
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow



Bloom ist Branchensieger im „Jahr der Werbung" 2013. In der Kategorie
„Alkoholische Getränke“ (B2C) landete Bloom auf dem ersten Platz. Alle Infos
auf http://www.bloomproject.de/arbeiten/show/lederer-markenpositionierung/



More information about the Flow mailing list