diff --git a/Api/Resource/CustomerCustomerFamily.php b/Api/Resource/CustomerCustomerFamily.php new file mode 100644 index 0000000..c829a66 --- /dev/null +++ b/Api/Resource/CustomerCustomerFamily.php @@ -0,0 +1,107 @@ +filterByCustomerId($activeRecord->getId())->findOne()) { + return $this; + } + + $this->setCode( + $activeRecord->hasVirtualColumn('CustomerCustomerFamily_code') + ? $activeRecord->getVirtualColumn('CustomerCustomerFamily_code') + : $customerCustomerFamily->getCustomerFamily()->getCode() + ); + + + return $this; + } + + public function buildFromArray(array $data, PropelResourceInterface $abstractPropelResource): ResourceAddonInterface + { + $this->setCode($data['code'] ?? null); + + return $this; + } + + /** + * @throws PropelException + */ + public function doSave(ActiveRecordInterface $activeRecord, PropelResourceInterface $abstractPropelResource): void + { + $model = new \CustomerFamily\Model\CustomerCustomerFamily(); + + if ($activeRecord->getCustomerCustomerFamily()) { + $id = $activeRecord->getCustomerCustomerFamily()->getCustomerId(); + $model = CustomerCustomerFamilyQuery::create()->filterByCustomerId($id)->findOne(); + } + + $model->setCustomerId($activeRecord->getId()); + $model->setCustomerFamilyId(CustomerFamilyQuery::create()->findOneByCode($this->getCode())?->getId()); + $model->save(); + } + + public function doDelete(ActiveRecordInterface $activeRecord, PropelResourceInterface $abstractPropelResource): void + { + $activeRecord->getCustomerCustomerFamily()?->delete(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function setId(?int $id): CustomerCustomerFamily + { + $this->id = $id; + return $this; + } + + public function getCode(): ?string + { + return $this->code; + } + + public function setCode(?string $code): CustomerCustomerFamily + { + $this->code = $code; + return $this; + } +} \ No newline at end of file diff --git a/Config/module.xml b/Config/module.xml index 3d61b78..643bfd3 100755 --- a/Config/module.xml +++ b/Config/module.xml @@ -7,7 +7,7 @@ Famille de clients et prix d'achat - 3.1.6 + 3.1.7 Guillaume Barral / Etienne Perriere gbarral@openstudio.fr / eperriere@openstudio.fr