| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace cx_newsletter;
- class customers_converter
- extends database_converter
- implements database_converter_interface {
- public function get_array() : array {
- $this->check_target();
- $result = [];
- $result['company'] = $this->target->company;
- $result['name'] = $this->target->name;
- $result['surname'] = $this->target->surname;
- $result['comments'] = $this->target->comments;
- $result['email'] = $this->target->email;
- $result['phone_number'] = $this->target->phone_number;
- $result['tester'] = $this->target->tester;
- if ($this->target->group !== null) {
- $result['grouped'] = $this->target->group->get_id();
- } else {
- $result['grouped'] = null;
- }
-
- if ($this->target->has_id()) {
- $result['id'] = $this->target->get_id();
- }
- return $result;
- }
- public function load_array(array $target) : self {
- $this->check_all_exists($target, [
- 'company',
- 'name',
- 'surname',
- 'comments',
- 'email',
- 'phone_number',
- 'tester',
- 'grouped'
- ]);
- $this->target = new customer($this->id_or_null($target));
- $this->target->company = $target['company'];
- $this->target->name = $target['name'];
- $this->target->surname = $target['surname'];
- $this->target->comments = $target['comments'];
- $this->target->email = $target['email'];
- $this->target->phone_number = $target['phone_number'];
- $this->target->tester = $target['tester'];
- if ($target['grouped'] === null) {
- $this->target->group = null;
- } else {
- $this->target->group = new group(intval($target['grouped']));
- }
- return $this;
- }
- }
|