Skip to content

Commit

Permalink
Eagerly load plans and discounts from subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Feb 24, 2015
1 parent 3cfc9ec commit f57e9ad
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.2.0

* Update mapping so that when fetching a subscription, plan and (eventual) discount are loaded eagerly instead of
being lazy-loaded. The reason is that most of the time, the subscription is fetched in order to be shown with all
the information linked to it.

## 1.1.1

* Revert uppercase for country code
Expand Down
4 changes: 2 additions & 2 deletions config/doctrine/ZfrCash.Entity.Subscription.dcm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
</options>
</field>

<many-to-one field="plan" target-entity="ZfrCash\Entity\Plan" />
<many-to-one field="plan" target-entity="ZfrCash\Entity\Plan" fetch="EAGER" />

<many-to-one field="payer" target-entity="ZfrCash\Entity\CustomerInterface">
<join-column on-delete="CASCADE" />
</many-to-one>

<one-to-one field="discount" target-entity="ZfrCash\Entity\SubscriptionDiscount" inversed-by="subscription">
<one-to-one field="discount" target-entity="ZfrCash\Entity\SubscriptionDiscount" inversed-by="subscription" fetch="EAGER">
<cascade>
<cascade-persist />
</cascade>
Expand Down
16 changes: 16 additions & 0 deletions src/Entity/AbstractDiscount.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ public function getId()
return $this->id;
}

/**
* @param CustomerInterface $customer
*/
public function setCustomer($customer)
{
$this->customer = $customer;
}

/**
* @return CustomerInterface
*/
public function getCustomer()
{
return $this->customer;
}

/**
* @param Coupon $coupon
*/
Expand Down
10 changes: 1 addition & 9 deletions src/Entity/CustomerDiscount.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ class CustomerDiscount extends AbstractDiscount
public function setCustomer($customer)
{
$customer->setDiscount($this);
$this->customer = $customer;
}

/**
* @return CustomerInterface
*/
public function getCustomer()
{
return $this->customer;
parent::setCustomer($customer);
}
}
16 changes: 0 additions & 16 deletions src/Entity/SubscriptionDiscount.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@ class SubscriptionDiscount extends AbstractDiscount
*/
protected $subscription;

/**
* @param CustomerInterface $customer
*/
public function setCustomer($customer)
{
$this->customer = $customer;
}

/**
* @return CustomerInterface
*/
public function getCustomer()
{
return $this->customer;
}

/**
* @param Subscription $subscription
*/
Expand Down

0 comments on commit f57e9ad

Please sign in to comment.