/** * @see FrontController::initContent() */ public function initContent() { parent::initContent(); try { if (!Maestrano::param('connec.enabled')) { return false; } $client = new Maestrano_Connec_Client(); $notification = json_decode(file_get_contents('php://input'), false); $entity_name = strtoupper(trim($notification->entity)); $entity_id = $notification->id; switch ($entity_name) { case "PERSONS": $customerMapper = new CustomerMapper(); $customerMapper->fetchConnecResource($entity_id); break; case "ITEMS": $productMapper = new ProductMapper(); $productMapper->fetchConnecResource($entity_id); break; case "TAXCODES": $taxMapper = new TaxMapper(); $taxMapper->fetchConnecResource($entity_id); break; } } catch (Exception $e) { error_log("Caught exception in subscribe " . json_encode($e->getMessage())); } }
public function updateCustomer(RequestModels\CustomerUpdate $requestModel) { $customrMapper = new CustomerMapper($requestModel); $requestPayload = array('authorization' => $this->_apiSetting->getSecretKey(), 'mode' => $this->_apiSetting->getMode(), 'postedParam' => $customrMapper->requestPayloadConverter()); $updateCustomerUri = $this->_apiUrl->getCustomersApiUri() . '/' . $requestModel->getCustomerId(); $processCharge = \com\checkout\helpers\ApiHttpClient::putRequest($updateCustomerUri, $this->_apiSetting->getSecretKey(), $requestPayload); $responseModel = new \com\checkout\ApiServices\SharedModels\OkResponse($processCharge); return $responseModel; }
public function hookActionObjectCustomerUpdateAfter($params) { $CustomerMapper = new CustomerMapper(); $CustomerMapper->processLocalUpdate($params['object'], true, false); }
<?php // Mocks, just placeholders class DAO { } require 'EntityInterface.php'; require 'Customer.php'; require 'CustomerMapper.php'; require 'IdentityMap.php'; $identityMap = new IdentityMap(); $customerMapper = new CustomerMapper(new DAO(), $identityMap); // Fetch the customer with ID 42 two times. This results in $customer2 being the same // object as customer1 and not just an object with the same values. $customer1 = $customerMapper->findById(42); $customer2 = $customerMapper->findById(42); $customer3 = $customerMapper->findById(1337); // Changing the e-mail of the first entity $customer1->email = '*****@*****.**'; // Proof that also customer 2 was updated, but 3 isn't. var_dump('$customer1->email: ' . $customer1->email, '$customer2->email: ' . $customer2->email, '$customer3->email: ' . $customer3->email);
$customer_data['Address'] = filter_var($data['address'], FILTER_SANITIZE_STRING); $customer_data['Telephone'] = filter_var($data['phone'], FILTER_SANITIZE_STRING); $customer_mapper = new CustomerMapper($this->db); $customer = $customer_mapper->getCustomerById($customer_data['CustomerNumber']); $this->logger->info("Updating customer " . $customer->getName()); $customer->setName($customer_data['Name']); $customer->setAddress($customer_data['Address']); $customer->setPhoneNumber($customer_data['Telephone']); $customer_mapper->update($customer); $response = $response->withRedirect("/index.php/customers"); return $response; }); // Delete Customer $app->get('/customer/{id}/delete', function ($request, $response, $args) { $customer_id = (int) $args['id']; $customer_mapper = new CustomerMapper($this->db); $customer = $customer_mapper->getCustomerById($customer_id); $this->logger->info("Customer retrieved " . $customer->getName()); $customer_mapper->delete($customer); $response = $response->withRedirect("/index.php/customers"); return $response; }); /**********************DEPARTMENTS**********************/ // Departments $app->get('/departments', function ($request, $response, $args) { $this->logger->info("Departments page"); $mapper = new DepartmentMapper($this->db); $departments = $mapper->getDepartments(); return $this->renderer->render($response, 'department/departments.phtml', [$args, "departments" => $departments]); }); // New Department