Unable to get repository from Library in Symfony : Ok, so I created a library in my symfony project and is located in Library folder under the bundle. Here's how the code looks like:

    namespace AppBundle\Library;
    
    use Symfony\Component\DependencyInjection\ContainerInterface as Container;
    use Doctrine\Common\Persistence\ObjectManager;
    
    class MooLibrary
    {
        private $container  = null;
        private $em         = null;
    
        public function __construct(ObjectManager $em, Container $container)
        {
          $this->container    = $container;
          $this->em           = $em;
        }
    
        public function getTypeContent($type = null, $id = 0)
        {
            $content = array();
            $dataClass = ucfirst($type);
    
            $content = $this->em->getRepository('AppBundle:Post')->findOneById($id);
    
            return $content;
        }
    }

this gives me an error:

    Using $this when not in object context