title: How entities could be connected with each other inside the domain?
body: <p>Let's assume there are two domain entities:</p>
  
  <ul>
  <li><strong>UserImages</strong> with methods <strong>addNewImage()</strong>, <strong>removeImage</strong>(<em>$imageId</em>), <strong>getImages</strong>(<em>$from, $count</em>).</li>
  <li><strong>UserProfile</strong> with fields <strong>name</strong>, <strong>age</strong>, <strong>mainImageId</strong>, etc.</li>
  </ul>
  
  <p>Following functionality is desired inside the domain: when application layer calls <strong>UserImages</strong> -> <strong>addNewImage()</strong>, <strong>UserProfile</strong> -> <strong>mainImageId</strong> is set automatically in case it was empty. </p>
  
  <p>So, what is the best way and best place to implement an in-domain over-entity business logic? Domain events with observing services, referencing special services from the entities, or somewhat else? </p>
  
  <p>I create all the entities using a some kind of factory, i.e. </p>
  
  <pre><code>$userImages = Domain::userImages($userId); // getting an instance of UserImages
  $newImageId = $userImages -&gt; addNewImage();   // adding a new image
  </code></pre>
  
  <p>I also should mention that I will have a lot of logic like described above in my project.</p>
  
  <p>Thank you very much for help!</p>