Extending ContainerAware does not automatically grant access to the service container - you would need to inject the container into your class. There are two ways to do that:
- If your class is registered as a service, you can inject
@service_container
- If your class is not a service, but is being accessed from a class that does have access to the container (like a controller), you can explicitly call
setContainer()
That being said, you should not inject the container into your classes. This makes it harder to test your classes. There are a few exceptions to this, but they don't come up often.
Instead, you should only inject services you need. In the case of the entity manager, you would inject @doctrine.orm.default_entity_manager.
In regards to accessing data from a config.yml, I would suggest including the file (which can be done when defining a service) and parsing the yml using either Symfony\Component\Yaml\Parser or Symfony\Component\Yaml\Yaml. The parsers converts a yml string to a PHP variable that you can then easily work with.