| 12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace cx_newsletter;
- class messages_converter
- extends database_converter
- implements database_converter_interface {
- public function get_array() : array {
- $this->check_target();
- $result = [];
- $result['title'] = $this->target->title;
- $result['content'] = base64_encode($this->target->content);
- 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, [ 'title', 'content' ]);
- $this->target = new message($this->id_or_null($target));
- $this->target->title = $target['title'];
- $this->target->content = base64_decode($target['content']);
- return $this;
- }
- }
|