How do I use Doctrine in a service container?
The Code just causes an error message \"Fatal error: Call to undefined method ...::get()\".
        Please try this code:
 $em=$this->container->get('doctrine')->getEntityManager();
 $rolescheduels=$em->getRepository('OCSOCSBundle:RoleScheduel')->findByUser($user->getId());
                                                                        According to your code, you already have an EntityManager injected. You don't need to call $em = $this->get('doctrine')->getEntityManager() — just use $this->em.
If you don't inject an EntityManager already, read this.
UPDATE:
You need to make the container inject an EntityManager into your service. Here's an example of doing it in config.yml:
services:
    your.service:
        class: YourVendor\YourBundle\Service\YourService
        arguments: [ @doctrine.orm.entity_manager ]
I prefer to define bundles' services in their own services.yml files, but that's a bit more advanced, so using config.yml is good enough to get started.