This commit is contained in:
Juan Pablo Vial
2025-03-03 14:55:57 -03:00
parent 4aa88d5164
commit ef54c36edc
6 changed files with 104 additions and 7 deletions

View File

@ -34,7 +34,7 @@ class Broker extends Ideal\Service
try {
$broker = $this->brokerRepository->create($filteredData);
$broker = $this->brokerRepository->save($broker);
} catch (PDOException | EmptyResult $exception) {
} catch (PDOException $exception) {
throw new ServiceAction\Create(__CLASS__, $exception);
}
}
@ -100,7 +100,7 @@ class Broker extends Ideal\Service
}
try {
$this->brokerRepository->remove($broker);
} catch (PDOException | EmptyResult $exception) {
} catch (PDOException $exception) {
throw new ServiceAction\Delete(__CLASS__, $exception);
} finally {
return $broker;
@ -116,6 +116,13 @@ class Broker extends Ideal\Service
return $broker;
}
/**
* @param Model\Proyecto\Broker $broker
* @param array $data
* @return Model\Proyecto\Broker\Data
* @throws ServiceAction\Create
*/
protected function addData(Model\Proyecto\Broker $broker, array $data): Model\Proyecto\Broker\Data
{
$data['broker_rut'] = $broker->rut;
@ -123,7 +130,7 @@ class Broker extends Ideal\Service
if (isset($filteredData['representative_rut'])) {
try {
$this->personaService->getById($filteredData['representative_rut']);
} catch (EmptyResult) {
} catch (ServiceAction\Read) {
unset($filteredData['representative_rut']);
}
}
@ -134,10 +141,17 @@ class Broker extends Ideal\Service
try {
$brokerData = $this->dataRepository->create($filteredData);
return $this->dataRepository->save($brokerData);
} catch (PDOException | EmptyResult $exception) {
} catch (PDOException $exception) {
throw new ServiceAction\Create(__CLASS__, $exception);
}
}
/**
* @param Model\Proyecto\Broker $broker
* @param array $data
* @return Model\Proyecto\Broker\Data
* @throws ServiceAction\Update
*/
protected function editData(Model\Proyecto\Broker $broker, array $data): Model\Proyecto\Broker\Data
{
try {