| 1 | <?php |
||
| 8 | abstract class AbstractDoctrineLoader implements LoaderInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var ObjectManager |
||
| 12 | */ |
||
| 13 | protected $manager; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $class; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param ObjectManager $manager |
||
| 22 | * @param string $class |
||
| 23 | */ |
||
| 24 | public function __construct(ObjectManager $manager, $class = null) |
||
| 25 | { |
||
| 26 | $this->manager = $manager; |
||
| 27 | $this->class = $class; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Map the requested path (ie. subpath in the URL) to an id that can be used to lookup the image in the Doctrine store. |
||
| 32 | * |
||
| 33 | * @param string $path |
||
| 34 | * |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | abstract protected function mapPathToId($path); |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Return a stream resource from the Doctrine entity/document with the image content. |
||
| 41 | * |
||
| 42 | * @param object $image |
||
| 43 | * |
||
| 44 | * @return resource |
||
| 45 | */ |
||
| 46 | abstract protected function getStreamFromImage($image); |
||
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritdoc} |
||
| 50 | */ |
||
| 51 | public function find($path) |
||
| 69 | } |
||
| 70 |