5-group_converter.php 652 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace cx_newsletter;
  3. class group_converter
  4. extends database_converter
  5. implements database_converter_interface {
  6. public function get_array() : array {
  7. $this->check_target();
  8. $result = [];
  9. $result['name'] = $this->target->name;
  10. if ($this->target->has_id()) {
  11. $result['id'] = $this->target->get_id();
  12. }
  13. return $result;
  14. }
  15. public function load_array(array $target) : self {
  16. $this->check_all_exists($target, ['name']);
  17. $this->target = new group($this->id_or_null($target));
  18. $this->target->name = $target['name'];
  19. return $this;
  20. }
  21. }