Merge branch 'master' of https://github.com/thelia/thelia
This commit is contained in:
@@ -29,6 +29,8 @@ use Thelia\Model\Coupon as ChildCoupon;
|
||||
use Thelia\Model\CouponCountry as ChildCouponCountry;
|
||||
use Thelia\Model\CouponCountryQuery as ChildCouponCountryQuery;
|
||||
use Thelia\Model\CouponQuery as ChildCouponQuery;
|
||||
use Thelia\Model\OrderAddress as ChildOrderAddress;
|
||||
use Thelia\Model\OrderAddressQuery as ChildOrderAddressQuery;
|
||||
use Thelia\Model\OrderCoupon as ChildOrderCoupon;
|
||||
use Thelia\Model\OrderCouponCountry as ChildOrderCouponCountry;
|
||||
use Thelia\Model\OrderCouponCountryQuery as ChildOrderCouponCountryQuery;
|
||||
@@ -144,6 +146,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
protected $collAddresses;
|
||||
protected $collAddressesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildOrderAddress[] Collection to store aggregation of ChildOrderAddress objects.
|
||||
*/
|
||||
protected $collOrderAddresses;
|
||||
protected $collOrderAddressesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCouponCountry[] Collection to store aggregation of ChildCouponCountry objects.
|
||||
*/
|
||||
@@ -218,6 +226,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
*/
|
||||
protected $addressesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $orderAddressesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -980,6 +994,8 @@ abstract class Country implements ActiveRecordInterface
|
||||
|
||||
$this->collAddresses = null;
|
||||
|
||||
$this->collOrderAddresses = null;
|
||||
|
||||
$this->collCouponCountries = null;
|
||||
|
||||
$this->collOrderCouponCountries = null;
|
||||
@@ -1221,6 +1237,23 @@ abstract class Country implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->orderAddressesScheduledForDeletion !== null) {
|
||||
if (!$this->orderAddressesScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\OrderAddressQuery::create()
|
||||
->filterByPrimaryKeys($this->orderAddressesScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->orderAddressesScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collOrderAddresses !== null) {
|
||||
foreach ($this->collOrderAddresses as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->couponCountriesScheduledForDeletion !== null) {
|
||||
if (!$this->couponCountriesScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\CouponCountryQuery::create()
|
||||
@@ -1506,6 +1539,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if (null !== $this->collAddresses) {
|
||||
$result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collOrderAddresses) {
|
||||
$result['OrderAddresses'] = $this->collOrderAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCouponCountries) {
|
||||
$result['CouponCountries'] = $this->collCouponCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
@@ -1718,6 +1754,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getOrderAddresses() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addOrderAddress($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCouponCountries() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCouponCountry($relObj->copy($deepCopy));
|
||||
@@ -1834,6 +1876,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if ('Address' == $relationName) {
|
||||
return $this->initAddresses();
|
||||
}
|
||||
if ('OrderAddress' == $relationName) {
|
||||
return $this->initOrderAddresses();
|
||||
}
|
||||
if ('CouponCountry' == $relationName) {
|
||||
return $this->initCouponCountries();
|
||||
}
|
||||
@@ -2384,6 +2429,249 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this->getAddresses($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collOrderAddresses collection
|
||||
*
|
||||
* This does not modify the database; however, it will remove any associated objects, causing
|
||||
* them to be refetched by subsequent calls to accessor method.
|
||||
*
|
||||
* @return void
|
||||
* @see addOrderAddresses()
|
||||
*/
|
||||
public function clearOrderAddresses()
|
||||
{
|
||||
$this->collOrderAddresses = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collOrderAddresses collection loaded partially.
|
||||
*/
|
||||
public function resetPartialOrderAddresses($v = true)
|
||||
{
|
||||
$this->collOrderAddressesPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collOrderAddresses collection.
|
||||
*
|
||||
* By default this just sets the collOrderAddresses collection to an empty array (like clearcollOrderAddresses());
|
||||
* however, you may wish to override this method in your stub class to provide setting appropriate
|
||||
* to your application -- for example, setting the initial array to the values stored in database.
|
||||
*
|
||||
* @param boolean $overrideExisting If set to true, the method call initializes
|
||||
* the collection even if it is not empty
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initOrderAddresses($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collOrderAddresses && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collOrderAddresses = new ObjectCollection();
|
||||
$this->collOrderAddresses->setModel('\Thelia\Model\OrderAddress');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildOrderAddress objects which contain a foreign key that references this object.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this ChildCountry is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @return Collection|ChildOrderAddress[] List of ChildOrderAddress objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getOrderAddresses($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collOrderAddressesPartial && !$this->isNew();
|
||||
if (null === $this->collOrderAddresses || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collOrderAddresses) {
|
||||
// return empty collection
|
||||
$this->initOrderAddresses();
|
||||
} else {
|
||||
$collOrderAddresses = ChildOrderAddressQuery::create(null, $criteria)
|
||||
->filterByCountry($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collOrderAddressesPartial && count($collOrderAddresses)) {
|
||||
$this->initOrderAddresses(false);
|
||||
|
||||
foreach ($collOrderAddresses as $obj) {
|
||||
if (false == $this->collOrderAddresses->contains($obj)) {
|
||||
$this->collOrderAddresses->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collOrderAddressesPartial = true;
|
||||
}
|
||||
|
||||
reset($collOrderAddresses);
|
||||
|
||||
return $collOrderAddresses;
|
||||
}
|
||||
|
||||
if ($partial && $this->collOrderAddresses) {
|
||||
foreach ($this->collOrderAddresses as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collOrderAddresses[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collOrderAddresses = $collOrderAddresses;
|
||||
$this->collOrderAddressesPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collOrderAddresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of OrderAddress objects related by a one-to-many relationship
|
||||
* to the current object.
|
||||
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
|
||||
* and new objects from the given Propel collection.
|
||||
*
|
||||
* @param Collection $orderAddresses A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function setOrderAddresses(Collection $orderAddresses, ConnectionInterface $con = null)
|
||||
{
|
||||
$orderAddressesToDelete = $this->getOrderAddresses(new Criteria(), $con)->diff($orderAddresses);
|
||||
|
||||
|
||||
$this->orderAddressesScheduledForDeletion = $orderAddressesToDelete;
|
||||
|
||||
foreach ($orderAddressesToDelete as $orderAddressRemoved) {
|
||||
$orderAddressRemoved->setCountry(null);
|
||||
}
|
||||
|
||||
$this->collOrderAddresses = null;
|
||||
foreach ($orderAddresses as $orderAddress) {
|
||||
$this->addOrderAddress($orderAddress);
|
||||
}
|
||||
|
||||
$this->collOrderAddresses = $orderAddresses;
|
||||
$this->collOrderAddressesPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related OrderAddress objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related OrderAddress objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countOrderAddresses(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collOrderAddressesPartial && !$this->isNew();
|
||||
if (null === $this->collOrderAddresses || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collOrderAddresses) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getOrderAddresses());
|
||||
}
|
||||
|
||||
$query = ChildOrderAddressQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCountry($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collOrderAddresses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildOrderAddress object to this object
|
||||
* through the ChildOrderAddress foreign key attribute.
|
||||
*
|
||||
* @param ChildOrderAddress $l ChildOrderAddress
|
||||
* @return \Thelia\Model\Country The current object (for fluent API support)
|
||||
*/
|
||||
public function addOrderAddress(ChildOrderAddress $l)
|
||||
{
|
||||
if ($this->collOrderAddresses === null) {
|
||||
$this->initOrderAddresses();
|
||||
$this->collOrderAddressesPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collOrderAddresses->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddOrderAddress($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderAddress $orderAddress The orderAddress object to add.
|
||||
*/
|
||||
protected function doAddOrderAddress($orderAddress)
|
||||
{
|
||||
$this->collOrderAddresses[]= $orderAddress;
|
||||
$orderAddress->setCountry($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderAddress $orderAddress The orderAddress object to remove.
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function removeOrderAddress($orderAddress)
|
||||
{
|
||||
if ($this->getOrderAddresses()->contains($orderAddress)) {
|
||||
$this->collOrderAddresses->remove($this->collOrderAddresses->search($orderAddress));
|
||||
if (null === $this->orderAddressesScheduledForDeletion) {
|
||||
$this->orderAddressesScheduledForDeletion = clone $this->collOrderAddresses;
|
||||
$this->orderAddressesScheduledForDeletion->clear();
|
||||
}
|
||||
$this->orderAddressesScheduledForDeletion[]= clone $orderAddress;
|
||||
$orderAddress->setCountry(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Country is new, it will return
|
||||
* an empty collection; or if this Country has previously
|
||||
* been saved, it will retrieve related OrderAddresses from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Country.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildOrderAddress[] List of ChildOrderAddress objects
|
||||
*/
|
||||
public function getOrderAddressesJoinCustomerTitle($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildOrderAddressQuery::create(null, $criteria);
|
||||
$query->joinWith('CustomerTitle', $joinBehavior);
|
||||
|
||||
return $this->getOrderAddresses($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCouponCountries collection
|
||||
*
|
||||
@@ -3511,6 +3799,11 @@ abstract class Country implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collOrderAddresses) {
|
||||
foreach ($this->collOrderAddresses as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCouponCountries) {
|
||||
foreach ($this->collCouponCountries as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
@@ -3544,6 +3837,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
|
||||
$this->collTaxRuleCountries = null;
|
||||
$this->collAddresses = null;
|
||||
$this->collOrderAddresses = null;
|
||||
$this->collCouponCountries = null;
|
||||
$this->collOrderCouponCountries = null;
|
||||
$this->collCountryI18ns = null;
|
||||
|
||||
@@ -58,6 +58,10 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountryQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation
|
||||
* @method ChildCountryQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation
|
||||
*
|
||||
* @method ChildCountryQuery leftJoinOrderAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddress relation
|
||||
* @method ChildCountryQuery rightJoinOrderAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddress relation
|
||||
* @method ChildCountryQuery innerJoinOrderAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddress relation
|
||||
*
|
||||
* @method ChildCountryQuery leftJoinCouponCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCountryQuery rightJoinCouponCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCountryQuery innerJoinCouponCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponCountry relation
|
||||
@@ -815,6 +819,79 @@ abstract class CountryQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\OrderAddress object
|
||||
*
|
||||
* @param \Thelia\Model\OrderAddress|ObjectCollection $orderAddress the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderAddress($orderAddress, $comparison = null)
|
||||
{
|
||||
if ($orderAddress instanceof \Thelia\Model\OrderAddress) {
|
||||
return $this
|
||||
->addUsingAlias(CountryTableMap::ID, $orderAddress->getCountryId(), $comparison);
|
||||
} elseif ($orderAddress instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useOrderAddressQuery()
|
||||
->filterByPrimaryKeys($orderAddress->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByOrderAddress() only accepts arguments of type \Thelia\Model\OrderAddress or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the OrderAddress relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrderAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('OrderAddress');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'OrderAddress');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the OrderAddress relation OrderAddress object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrderAddress($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderAddress', '\Thelia\Model\OrderAddressQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponCountry object
|
||||
*
|
||||
|
||||
@@ -25,6 +25,8 @@ use Thelia\Model\CustomerTitle as ChildCustomerTitle;
|
||||
use Thelia\Model\CustomerTitleI18n as ChildCustomerTitleI18n;
|
||||
use Thelia\Model\CustomerTitleI18nQuery as ChildCustomerTitleI18nQuery;
|
||||
use Thelia\Model\CustomerTitleQuery as ChildCustomerTitleQuery;
|
||||
use Thelia\Model\OrderAddress as ChildOrderAddress;
|
||||
use Thelia\Model\OrderAddressQuery as ChildOrderAddressQuery;
|
||||
use Thelia\Model\Map\CustomerTitleTableMap;
|
||||
|
||||
abstract class CustomerTitle implements ActiveRecordInterface
|
||||
@@ -104,6 +106,12 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
protected $collAddresses;
|
||||
protected $collAddressesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildOrderAddress[] Collection to store aggregation of ChildOrderAddress objects.
|
||||
*/
|
||||
protected $collOrderAddresses;
|
||||
protected $collOrderAddressesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCustomerTitleI18n[] Collection to store aggregation of ChildCustomerTitleI18n objects.
|
||||
*/
|
||||
@@ -144,6 +152,12 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
*/
|
||||
protected $addressesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $orderAddressesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -733,6 +747,8 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
|
||||
$this->collAddresses = null;
|
||||
|
||||
$this->collOrderAddresses = null;
|
||||
|
||||
$this->collCustomerTitleI18ns = null;
|
||||
|
||||
} // if (deep)
|
||||
@@ -902,6 +918,24 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->orderAddressesScheduledForDeletion !== null) {
|
||||
if (!$this->orderAddressesScheduledForDeletion->isEmpty()) {
|
||||
foreach ($this->orderAddressesScheduledForDeletion as $orderAddress) {
|
||||
// need to save related object because we set the relation to null
|
||||
$orderAddress->save($con);
|
||||
}
|
||||
$this->orderAddressesScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collOrderAddresses !== null) {
|
||||
foreach ($this->collOrderAddresses as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->customerTitleI18nsScheduledForDeletion !== null) {
|
||||
if (!$this->customerTitleI18nsScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\CustomerTitleI18nQuery::create()
|
||||
@@ -1110,6 +1144,9 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
if (null !== $this->collAddresses) {
|
||||
$result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collOrderAddresses) {
|
||||
$result['OrderAddresses'] = $this->collOrderAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCustomerTitleI18ns) {
|
||||
$result['CustomerTitleI18ns'] = $this->collCustomerTitleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
@@ -1292,6 +1329,12 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getOrderAddresses() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addOrderAddress($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCustomerTitleI18ns() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCustomerTitleI18n($relObj->copy($deepCopy));
|
||||
@@ -1345,6 +1388,9 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
if ('Address' == $relationName) {
|
||||
return $this->initAddresses();
|
||||
}
|
||||
if ('OrderAddress' == $relationName) {
|
||||
return $this->initOrderAddresses();
|
||||
}
|
||||
if ('CustomerTitleI18n' == $relationName) {
|
||||
return $this->initCustomerTitleI18ns();
|
||||
}
|
||||
@@ -1836,6 +1882,249 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
return $this->getAddresses($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collOrderAddresses collection
|
||||
*
|
||||
* This does not modify the database; however, it will remove any associated objects, causing
|
||||
* them to be refetched by subsequent calls to accessor method.
|
||||
*
|
||||
* @return void
|
||||
* @see addOrderAddresses()
|
||||
*/
|
||||
public function clearOrderAddresses()
|
||||
{
|
||||
$this->collOrderAddresses = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collOrderAddresses collection loaded partially.
|
||||
*/
|
||||
public function resetPartialOrderAddresses($v = true)
|
||||
{
|
||||
$this->collOrderAddressesPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collOrderAddresses collection.
|
||||
*
|
||||
* By default this just sets the collOrderAddresses collection to an empty array (like clearcollOrderAddresses());
|
||||
* however, you may wish to override this method in your stub class to provide setting appropriate
|
||||
* to your application -- for example, setting the initial array to the values stored in database.
|
||||
*
|
||||
* @param boolean $overrideExisting If set to true, the method call initializes
|
||||
* the collection even if it is not empty
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initOrderAddresses($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collOrderAddresses && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collOrderAddresses = new ObjectCollection();
|
||||
$this->collOrderAddresses->setModel('\Thelia\Model\OrderAddress');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildOrderAddress objects which contain a foreign key that references this object.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this ChildCustomerTitle is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @return Collection|ChildOrderAddress[] List of ChildOrderAddress objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getOrderAddresses($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collOrderAddressesPartial && !$this->isNew();
|
||||
if (null === $this->collOrderAddresses || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collOrderAddresses) {
|
||||
// return empty collection
|
||||
$this->initOrderAddresses();
|
||||
} else {
|
||||
$collOrderAddresses = ChildOrderAddressQuery::create(null, $criteria)
|
||||
->filterByCustomerTitle($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collOrderAddressesPartial && count($collOrderAddresses)) {
|
||||
$this->initOrderAddresses(false);
|
||||
|
||||
foreach ($collOrderAddresses as $obj) {
|
||||
if (false == $this->collOrderAddresses->contains($obj)) {
|
||||
$this->collOrderAddresses->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collOrderAddressesPartial = true;
|
||||
}
|
||||
|
||||
reset($collOrderAddresses);
|
||||
|
||||
return $collOrderAddresses;
|
||||
}
|
||||
|
||||
if ($partial && $this->collOrderAddresses) {
|
||||
foreach ($this->collOrderAddresses as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collOrderAddresses[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collOrderAddresses = $collOrderAddresses;
|
||||
$this->collOrderAddressesPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collOrderAddresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of OrderAddress objects related by a one-to-many relationship
|
||||
* to the current object.
|
||||
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
|
||||
* and new objects from the given Propel collection.
|
||||
*
|
||||
* @param Collection $orderAddresses A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCustomerTitle The current object (for fluent API support)
|
||||
*/
|
||||
public function setOrderAddresses(Collection $orderAddresses, ConnectionInterface $con = null)
|
||||
{
|
||||
$orderAddressesToDelete = $this->getOrderAddresses(new Criteria(), $con)->diff($orderAddresses);
|
||||
|
||||
|
||||
$this->orderAddressesScheduledForDeletion = $orderAddressesToDelete;
|
||||
|
||||
foreach ($orderAddressesToDelete as $orderAddressRemoved) {
|
||||
$orderAddressRemoved->setCustomerTitle(null);
|
||||
}
|
||||
|
||||
$this->collOrderAddresses = null;
|
||||
foreach ($orderAddresses as $orderAddress) {
|
||||
$this->addOrderAddress($orderAddress);
|
||||
}
|
||||
|
||||
$this->collOrderAddresses = $orderAddresses;
|
||||
$this->collOrderAddressesPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related OrderAddress objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related OrderAddress objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countOrderAddresses(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collOrderAddressesPartial && !$this->isNew();
|
||||
if (null === $this->collOrderAddresses || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collOrderAddresses) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getOrderAddresses());
|
||||
}
|
||||
|
||||
$query = ChildOrderAddressQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCustomerTitle($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collOrderAddresses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildOrderAddress object to this object
|
||||
* through the ChildOrderAddress foreign key attribute.
|
||||
*
|
||||
* @param ChildOrderAddress $l ChildOrderAddress
|
||||
* @return \Thelia\Model\CustomerTitle The current object (for fluent API support)
|
||||
*/
|
||||
public function addOrderAddress(ChildOrderAddress $l)
|
||||
{
|
||||
if ($this->collOrderAddresses === null) {
|
||||
$this->initOrderAddresses();
|
||||
$this->collOrderAddressesPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collOrderAddresses->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddOrderAddress($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderAddress $orderAddress The orderAddress object to add.
|
||||
*/
|
||||
protected function doAddOrderAddress($orderAddress)
|
||||
{
|
||||
$this->collOrderAddresses[]= $orderAddress;
|
||||
$orderAddress->setCustomerTitle($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderAddress $orderAddress The orderAddress object to remove.
|
||||
* @return ChildCustomerTitle The current object (for fluent API support)
|
||||
*/
|
||||
public function removeOrderAddress($orderAddress)
|
||||
{
|
||||
if ($this->getOrderAddresses()->contains($orderAddress)) {
|
||||
$this->collOrderAddresses->remove($this->collOrderAddresses->search($orderAddress));
|
||||
if (null === $this->orderAddressesScheduledForDeletion) {
|
||||
$this->orderAddressesScheduledForDeletion = clone $this->collOrderAddresses;
|
||||
$this->orderAddressesScheduledForDeletion->clear();
|
||||
}
|
||||
$this->orderAddressesScheduledForDeletion[]= $orderAddress;
|
||||
$orderAddress->setCustomerTitle(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this CustomerTitle is new, it will return
|
||||
* an empty collection; or if this CustomerTitle has previously
|
||||
* been saved, it will retrieve related OrderAddresses from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in CustomerTitle.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildOrderAddress[] List of ChildOrderAddress objects
|
||||
*/
|
||||
public function getOrderAddressesJoinCountry($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildOrderAddressQuery::create(null, $criteria);
|
||||
$query->joinWith('Country', $joinBehavior);
|
||||
|
||||
return $this->getOrderAddresses($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCustomerTitleI18ns collection
|
||||
*
|
||||
@@ -2101,6 +2390,11 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collOrderAddresses) {
|
||||
foreach ($this->collOrderAddresses as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCustomerTitleI18ns) {
|
||||
foreach ($this->collCustomerTitleI18ns as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
@@ -2114,6 +2408,7 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
|
||||
$this->collCustomers = null;
|
||||
$this->collAddresses = null;
|
||||
$this->collOrderAddresses = null;
|
||||
$this->collCustomerTitleI18ns = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,10 @@ use Thelia\Model\Map\CustomerTitleTableMap;
|
||||
* @method ChildCustomerTitleQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation
|
||||
* @method ChildCustomerTitleQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation
|
||||
*
|
||||
* @method ChildCustomerTitleQuery leftJoinOrderAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddress relation
|
||||
* @method ChildCustomerTitleQuery rightJoinOrderAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddress relation
|
||||
* @method ChildCustomerTitleQuery innerJoinOrderAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddress relation
|
||||
*
|
||||
* @method ChildCustomerTitleQuery leftJoinCustomerTitleI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerTitleI18n relation
|
||||
* @method ChildCustomerTitleQuery rightJoinCustomerTitleI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitleI18n relation
|
||||
* @method ChildCustomerTitleQuery innerJoinCustomerTitleI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitleI18n relation
|
||||
@@ -584,6 +588,79 @@ abstract class CustomerTitleQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\OrderAddress object
|
||||
*
|
||||
* @param \Thelia\Model\OrderAddress|ObjectCollection $orderAddress the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCustomerTitleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderAddress($orderAddress, $comparison = null)
|
||||
{
|
||||
if ($orderAddress instanceof \Thelia\Model\OrderAddress) {
|
||||
return $this
|
||||
->addUsingAlias(CustomerTitleTableMap::ID, $orderAddress->getCustomerTitleId(), $comparison);
|
||||
} elseif ($orderAddress instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useOrderAddressQuery()
|
||||
->filterByPrimaryKeys($orderAddress->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByOrderAddress() only accepts arguments of type \Thelia\Model\OrderAddress or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the OrderAddress relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCustomerTitleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrderAddress($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('OrderAddress');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'OrderAddress');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the OrderAddress relation OrderAddress object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderAddressQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrderAddress($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderAddress', '\Thelia\Model\OrderAddressQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CustomerTitleI18n object
|
||||
*
|
||||
|
||||
@@ -17,6 +17,10 @@ use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Map\TableMap;
|
||||
use Propel\Runtime\Parser\AbstractParser;
|
||||
use Propel\Runtime\Util\PropelDateTime;
|
||||
use Thelia\Model\Country as ChildCountry;
|
||||
use Thelia\Model\CountryQuery as ChildCountryQuery;
|
||||
use Thelia\Model\CustomerTitle as ChildCustomerTitle;
|
||||
use Thelia\Model\CustomerTitleQuery as ChildCustomerTitleQuery;
|
||||
use Thelia\Model\Order as ChildOrder;
|
||||
use Thelia\Model\OrderAddress as ChildOrderAddress;
|
||||
use Thelia\Model\OrderAddressQuery as ChildOrderAddressQuery;
|
||||
@@ -141,6 +145,16 @@ abstract class OrderAddress implements ActiveRecordInterface
|
||||
*/
|
||||
protected $updated_at;
|
||||
|
||||
/**
|
||||
* @var CustomerTitle
|
||||
*/
|
||||
protected $aCustomerTitle;
|
||||
|
||||
/**
|
||||
* @var Country
|
||||
*/
|
||||
protected $aCountry;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects.
|
||||
*/
|
||||
@@ -641,6 +655,10 @@ abstract class OrderAddress implements ActiveRecordInterface
|
||||
$this->modifiedColumns[OrderAddressTableMap::CUSTOMER_TITLE_ID] = true;
|
||||
}
|
||||
|
||||
if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
|
||||
$this->aCustomerTitle = null;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setCustomerTitleId()
|
||||
@@ -851,6 +869,10 @@ abstract class OrderAddress implements ActiveRecordInterface
|
||||
$this->modifiedColumns[OrderAddressTableMap::COUNTRY_ID] = true;
|
||||
}
|
||||
|
||||
if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
|
||||
$this->aCountry = null;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setCountryId()
|
||||
@@ -1011,6 +1033,12 @@ abstract class OrderAddress implements ActiveRecordInterface
|
||||
*/
|
||||
public function ensureConsistency()
|
||||
{
|
||||
if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) {
|
||||
$this->aCustomerTitle = null;
|
||||
}
|
||||
if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) {
|
||||
$this->aCountry = null;
|
||||
}
|
||||
} // ensureConsistency
|
||||
|
||||
/**
|
||||
@@ -1050,6 +1078,8 @@ abstract class OrderAddress implements ActiveRecordInterface
|
||||
|
||||
if ($deep) { // also de-associate any related objects?
|
||||
|
||||
$this->aCustomerTitle = null;
|
||||
$this->aCountry = null;
|
||||
$this->collOrdersRelatedByInvoiceOrderAddressId = null;
|
||||
|
||||
$this->collOrdersRelatedByDeliveryOrderAddressId = null;
|
||||
@@ -1176,6 +1206,25 @@ abstract class OrderAddress implements ActiveRecordInterface
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their corresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aCustomerTitle !== null) {
|
||||
if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) {
|
||||
$affectedRows += $this->aCustomerTitle->save($con);
|
||||
}
|
||||
$this->setCustomerTitle($this->aCustomerTitle);
|
||||
}
|
||||
|
||||
if ($this->aCountry !== null) {
|
||||
if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
|
||||
$affectedRows += $this->aCountry->save($con);
|
||||
}
|
||||
$this->setCountry($this->aCountry);
|
||||
}
|
||||
|
||||
if ($this->isNew() || $this->isModified()) {
|
||||
// persist changes
|
||||
if ($this->isNew()) {
|
||||
@@ -1496,6 +1545,12 @@ abstract class OrderAddress implements ActiveRecordInterface
|
||||
}
|
||||
|
||||
if ($includeForeignObjects) {
|
||||
if (null !== $this->aCustomerTitle) {
|
||||
$result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
|
||||
}
|
||||
if (null !== $this->aCountry) {
|
||||
$result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
|
||||
}
|
||||
if (null !== $this->collOrdersRelatedByInvoiceOrderAddressId) {
|
||||
$result['OrdersRelatedByInvoiceOrderAddressId'] = $this->collOrdersRelatedByInvoiceOrderAddressId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
@@ -1765,6 +1820,108 @@ abstract class OrderAddress implements ActiveRecordInterface
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a ChildCustomerTitle object.
|
||||
*
|
||||
* @param ChildCustomerTitle $v
|
||||
* @return \Thelia\Model\OrderAddress The current object (for fluent API support)
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setCustomerTitle(ChildCustomerTitle $v = null)
|
||||
{
|
||||
if ($v === null) {
|
||||
$this->setCustomerTitleId(NULL);
|
||||
} else {
|
||||
$this->setCustomerTitleId($v->getId());
|
||||
}
|
||||
|
||||
$this->aCustomerTitle = $v;
|
||||
|
||||
// Add binding for other direction of this n:n relationship.
|
||||
// If this object has already been added to the ChildCustomerTitle object, it will not be re-added.
|
||||
if ($v !== null) {
|
||||
$v->addOrderAddress($this);
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated ChildCustomerTitle object
|
||||
*
|
||||
* @param ConnectionInterface $con Optional Connection object.
|
||||
* @return ChildCustomerTitle The associated ChildCustomerTitle object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCustomerTitle(ConnectionInterface $con = null)
|
||||
{
|
||||
if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) {
|
||||
$this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->customer_title_id, $con);
|
||||
/* The following can be used additionally to
|
||||
guarantee the related object contains a reference
|
||||
to this object. This level of coupling may, however, be
|
||||
undesirable since it could result in an only partially populated collection
|
||||
in the referenced object.
|
||||
$this->aCustomerTitle->addOrderAddresses($this);
|
||||
*/
|
||||
}
|
||||
|
||||
return $this->aCustomerTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a ChildCountry object.
|
||||
*
|
||||
* @param ChildCountry $v
|
||||
* @return \Thelia\Model\OrderAddress The current object (for fluent API support)
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setCountry(ChildCountry $v = null)
|
||||
{
|
||||
if ($v === null) {
|
||||
$this->setCountryId(NULL);
|
||||
} else {
|
||||
$this->setCountryId($v->getId());
|
||||
}
|
||||
|
||||
$this->aCountry = $v;
|
||||
|
||||
// Add binding for other direction of this n:n relationship.
|
||||
// If this object has already been added to the ChildCountry object, it will not be re-added.
|
||||
if ($v !== null) {
|
||||
$v->addOrderAddress($this);
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated ChildCountry object
|
||||
*
|
||||
* @param ConnectionInterface $con Optional Connection object.
|
||||
* @return ChildCountry The associated ChildCountry object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCountry(ConnectionInterface $con = null)
|
||||
{
|
||||
if ($this->aCountry === null && ($this->country_id !== null)) {
|
||||
$this->aCountry = ChildCountryQuery::create()->findPk($this->country_id, $con);
|
||||
/* The following can be used additionally to
|
||||
guarantee the related object contains a reference
|
||||
to this object. This level of coupling may, however, be
|
||||
undesirable since it could result in an only partially populated collection
|
||||
in the referenced object.
|
||||
$this->aCountry->addOrderAddresses($this);
|
||||
*/
|
||||
}
|
||||
|
||||
return $this->aCountry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initializes a collection based on the name of a relation.
|
||||
@@ -2572,6 +2729,8 @@ abstract class OrderAddress implements ActiveRecordInterface
|
||||
|
||||
$this->collOrdersRelatedByInvoiceOrderAddressId = null;
|
||||
$this->collOrdersRelatedByDeliveryOrderAddressId = null;
|
||||
$this->aCustomerTitle = null;
|
||||
$this->aCountry = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,6 +55,14 @@ use Thelia\Model\Map\OrderAddressTableMap;
|
||||
* @method ChildOrderAddressQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildOrderAddressQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildOrderAddressQuery leftJoinCustomerTitle($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerTitle relation
|
||||
* @method ChildOrderAddressQuery rightJoinCustomerTitle($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitle relation
|
||||
* @method ChildOrderAddressQuery innerJoinCustomerTitle($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitle relation
|
||||
*
|
||||
* @method ChildOrderAddressQuery leftJoinCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the Country relation
|
||||
* @method ChildOrderAddressQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation
|
||||
* @method ChildOrderAddressQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation
|
||||
*
|
||||
* @method ChildOrderAddressQuery leftJoinOrderRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation
|
||||
* @method ChildOrderAddressQuery rightJoinOrderRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation
|
||||
* @method ChildOrderAddressQuery innerJoinOrderRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation
|
||||
@@ -323,6 +331,8 @@ abstract class OrderAddressQuery extends ModelCriteria
|
||||
* $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCustomerTitle()
|
||||
*
|
||||
* @param mixed $customerTitleId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
@@ -625,6 +635,8 @@ abstract class OrderAddressQuery extends ModelCriteria
|
||||
* $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCountry()
|
||||
*
|
||||
* @param mixed $countryId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
@@ -742,6 +754,156 @@ abstract class OrderAddressQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(OrderAddressTableMap::UPDATED_AT, $updatedAt, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CustomerTitle object
|
||||
*
|
||||
* @param \Thelia\Model\CustomerTitle|ObjectCollection $customerTitle The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderAddressQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCustomerTitle($customerTitle, $comparison = null)
|
||||
{
|
||||
if ($customerTitle instanceof \Thelia\Model\CustomerTitle) {
|
||||
return $this
|
||||
->addUsingAlias(OrderAddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
|
||||
} elseif ($customerTitle instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(OrderAddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CustomerTitle relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderAddressQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CustomerTitle');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'CustomerTitle');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CustomerTitle relation CustomerTitle object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCustomerTitle($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Country object
|
||||
*
|
||||
* @param \Thelia\Model\Country|ObjectCollection $country The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderAddressQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCountry($country, $comparison = null)
|
||||
{
|
||||
if ($country instanceof \Thelia\Model\Country) {
|
||||
return $this
|
||||
->addUsingAlias(OrderAddressTableMap::COUNTRY_ID, $country->getId(), $comparison);
|
||||
} elseif ($country instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(OrderAddressTableMap::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Country relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderAddressQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Country');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Country');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Country relation Country object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCountry($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Order object
|
||||
*
|
||||
|
||||
@@ -194,6 +194,7 @@ class CountryTableMap extends TableMap
|
||||
$this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT');
|
||||
$this->addRelation('TaxRuleCountry', '\\Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountries');
|
||||
$this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'RESTRICT', 'RESTRICT', 'Addresses');
|
||||
$this->addRelation('OrderAddress', '\\Thelia\\Model\\OrderAddress', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'RESTRICT', 'RESTRICT', 'OrderAddresses');
|
||||
$this->addRelation('CouponCountry', '\\Thelia\\Model\\CouponCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', null, 'CouponCountries');
|
||||
$this->addRelation('OrderCouponCountry', '\\Thelia\\Model\\OrderCouponCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', null, 'OrderCouponCountries');
|
||||
$this->addRelation('CountryI18n', '\\Thelia\\Model\\CountryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CountryI18ns');
|
||||
|
||||
@@ -169,6 +169,7 @@ class CustomerTitleTableMap extends TableMap
|
||||
{
|
||||
$this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'title_id', ), 'RESTRICT', 'RESTRICT', 'Customers');
|
||||
$this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'title_id', ), 'RESTRICT', 'RESTRICT', 'Addresses');
|
||||
$this->addRelation('OrderAddress', '\\Thelia\\Model\\OrderAddress', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'RESTRICT', 'RESTRICT', 'OrderAddresses');
|
||||
$this->addRelation('CustomerTitleI18n', '\\Thelia\\Model\\CustomerTitleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CustomerTitleI18ns');
|
||||
} // buildRelations()
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ class OrderAddressTableMap extends TableMap
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', false, null, null);
|
||||
$this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
|
||||
$this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
|
||||
$this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
|
||||
@@ -202,7 +202,7 @@ class OrderAddressTableMap extends TableMap
|
||||
$this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null);
|
||||
$this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null);
|
||||
$this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
|
||||
$this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', true, null, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
} // initialize()
|
||||
@@ -212,6 +212,8 @@ class OrderAddressTableMap extends TableMap
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'RESTRICT', 'RESTRICT');
|
||||
$this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'RESTRICT', 'RESTRICT');
|
||||
$this->addRelation('OrderRelatedByInvoiceOrderAddressId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'invoice_order_address_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByInvoiceOrderAddressId');
|
||||
$this->addRelation('OrderRelatedByDeliveryOrderAddressId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'delivery_order_address_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByDeliveryOrderAddressId');
|
||||
} // buildRelations()
|
||||
|
||||
@@ -662,6 +662,12 @@
|
||||
<column name="city" required="true" size="255" type="VARCHAR" />
|
||||
<column name="phone" size="20" type="VARCHAR" />
|
||||
<column name="country_id" required="true" type="INTEGER" />
|
||||
<foreign-key foreignTable="customer_title" name="fk_order_address_customer_title_id" onDelete="RESTRICT" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="customer_title_id" />
|
||||
</foreign-key>
|
||||
<foreign-key foreignTable="country" name="fk_order_address_country_id" onDelete="RESTRICT" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="country_id" />
|
||||
</foreign-key>
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
<table name="order_product" namespace="Thelia\Model">
|
||||
|
||||
@@ -775,7 +775,19 @@ CREATE TABLE `order_address`
|
||||
`country_id` INTEGER NOT NULL,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`)
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `FI_order_address_customer_title_id` (`customer_title_id`),
|
||||
INDEX `FI_order_address_country_id` (`country_id`),
|
||||
CONSTRAINT `fk_order_address_customer_title_id`
|
||||
FOREIGN KEY (`customer_title_id`)
|
||||
REFERENCES `customer_title` (`id`)
|
||||
ON UPDATE RESTRICT
|
||||
ON DELETE RESTRICT,
|
||||
CONSTRAINT `fk_order_address_country_id`
|
||||
FOREIGN KEY (`country_id`)
|
||||
REFERENCES `country` (`id`)
|
||||
ON UPDATE RESTRICT
|
||||
ON DELETE RESTRICT
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
@@ -15,6 +15,21 @@ ALTER TABLE `order` ADD `version` INT DEFAULT 0 AFTER `updated_at`;
|
||||
ALTER TABLE `order` ADD `version_created_at` DATE AFTER `version`;
|
||||
ALTER TABLE `order` ADD `version_created_by` VARCHAR(100) AFTER `version_created_at`;
|
||||
|
||||
ALTER TABLE `order_address`
|
||||
ADD CONSTRAINT `fk_order_address_customer_title_id`
|
||||
FOREIGN KEY (`customer_title_id`)
|
||||
REFERENCES `customer_title` (`id`)
|
||||
ON UPDATE RESTRICT
|
||||
ON DELETE RESTRICT
|
||||
;
|
||||
ALTER TABLE `order_address`
|
||||
ADD CONSTRAINT `fk_order_address_country_id`
|
||||
FOREIGN KEY (`country_id`)
|
||||
REFERENCES `country` (`id`)
|
||||
ON UPDATE RESTRICT
|
||||
ON DELETE RESTRICT
|
||||
;
|
||||
|
||||
DROP TABLE IF EXISTS `order_version`;
|
||||
|
||||
CREATE TABLE `order_version`
|
||||
|
||||
Reference in New Issue
Block a user