title: Where should the business logic be placed when using Doctrine 2 and Zend Framework
body: <p>I've a question related to Doctrine 2 and Zend Framework.</p>
  
  <p>If you use Zend Framework without Doctrine by default you place business logic in the models. But as Doctrine 2 does have Entities where should the business logic be placed?</p>
  
  <p>I first had created models where the entity manager did calls to the Entities. But when I wanted to write unit tests for my models without database calls. I needed to move the entity manager to the controllers. But I'm getting business logic in my controllers which is not good.</p>
  
  <p>The code below shows a part of an controller action:</p>
  
  <pre><code>        $customerAddress = $this-&gt;_model-&gt;save($values, $id);
  
          $this-&gt;_em-&gt;persist($customerAddress);
  
          // Update default billing address
          $defaultBilling = $this-&gt;_model-&gt;saveDefaultBilling($values, $customerAddress);
          if ($defaultBilling != FALSE) {
              $this-&gt;_em-&gt;persist($defaultBilling);
          }
  
          // Update default shipping address
          $defaultShipping = $this-&gt;_model-&gt;saveDefaultShipping($values, $customerAddress);
          if ($defaultShipping != FALSE) {
              $this-&gt;_em-&gt;persist($defaultShipping);
          }
  
          $this-&gt;_em-&gt;flush();
  </code></pre>
  
  <p>Can somebody say what's the best practice for this issue? Thx</p>