I have the following code that I put inside an entity class:

```
$filesystem = $this->container->get('knp_gaufrette.filesystem_map')->get('amazon');
$filesystem->write($this->file , $this->name, true);

```

However, this always generate an error of:

```
Notice: Undefined property: MySite\UserBundle\Entity\ProfilePicture::$container in /Users/Mike/Sites/MySite/src/MySite/MainBundle/Entity/Document.php line 98

```

Any idea why this is the case? How do I access a service container from an entity?

I've put this inside an abstract class:

```
abstract class Document
{

......
}

```