title: Get service container from entity in symfony 2.1 (Doctrine)
body: <p>How to use entity as service in doctrine (Using Symfony 2.1).</p>
  
  <p>Example usage:</p>
  
  <pre><code>&lt;?php
  
  namespace MyNamespace;
  
  class MyEntity
  {
    protected $container = NULL;
    public function __construct($container)
    {
      $this-&gt;container = $container;
    }
  
    /** 
     * @ORM\PrePersist
     */
    public function() 
    {
      // Must call to container and get any parameters
      // for defaults sets entity parameters
      $this-&gt;container-&gt;get('service.name');
    }
  }
  </code></pre>
  
  <p>As a result, I need to get access to the entire container.</p>