A
A
Alexander Evgenievich2016-03-10 13:18:33
PHP
Alexander Evgenievich, 2016-03-10 13:18:33

What is the best way to organize communication between several Entities, storages and Domain Model?

Hello.
In the process of implementing DDD, it stalled on the following:
The application stores part of the data in the database, and implements part of the data through the API to a remote server. Accordingly, it was decided to create entities based on the data that correspond to the tables in the database - this is for ORM mapping, and others to correlate with the data necessary to work with the API. It was decided to combine the obtained entities by type into the corresponding Domain Models that would meet the set business requirements.
Those. for example:

class PostEntity{
  private $id;
  private $externalId;
  private $userId;
  private $date;
}

class ExternalPostEntity{
  private $id;
  private $postCode;
  private $author;
  private $title;
  private $description;
}

class PostModel{
  private /*PostID*/ $postId;
  private /*User*/ $user;
  private /*Date*/ $date;
  private $title;
  private $description;
  private $code;
}

To work with saving data, a repository is created, inside which data is processed for the database through ORM mapping and processing and mapping through API requests. When calling the find*() methods, the DomainModel is collected accordingly.
The question is, how objective is such an implementation, or should we look for other options?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question