title: Symfony 2: Creating a service from a Repository
body: <p>I'm learning Symfony and I've been trying to create a service, using a repository.
  I've created my repositories and entities from generate:entity, so they should be fine.</p>
  
  <p>So far what I got in my services.yml is:</p>
  
  <pre><code>parameters:
      mytest.entity: TestTestBundle:Brand
      mytest.class:  Test\TestBundle\Entity\Brand
      default_repository.class: Doctrine\ORM\EntityRepository
  
  services:
       myservice:
            class: %default_repository.class%
            factory-service: doctrine.orm.default_entity_manager
            factory-method: getRepository
            arguments:
              - %mytest.entity%
  </code></pre>
  
  <p>But when I try to call the service, I get this error:</p>
  
  <pre><code>Catchable Fatal Error: Argument 2 passed to Doctrine\ORM\EntityRepository::__construct() must be an instance of Doctrine\ORM\Mapping\ClassMetadata, none given, called in 
  </code></pre>
  
  <p>Then I tried to create the service just using an entity. My services.yml would look like:</p>
  
  <pre><code>services:
       myservice:
            class: %mytest.class%
            factory-service: doctrine.orm.default_entity_manager
            factory-method: getRepository
            arguments:
              - %mytest.entity%
  </code></pre>
  
  <p>But for this, I get:</p>
  
  <pre><code>Error: Call to undefined method 
                  Test\TestBundle\Entity\Brand::findAll
  </code></pre>
  
  <p>Does anybody know what am I doing wrong?</p>
  
  <p>Thanks</p>