1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 
<?php
namespace Omeka\File;

use Zend\ServiceManager\ServiceLocatorInterface;

class TempFileFactory
{
    /**
     * @var string
     */
    protected $tempDir;

    /**
     * @var array
     */
    protected $mediaTypeMap;

    /**
     * @var Omeka\File\Store\StoreInterface
     */
    protected $store;

    /**
     * @var Omeka\File\ThumbnailManager
     */
    protected $thumbnailManager;

    /**
     * @param ServiceLocatorInterface $services
     */
    public function __construct(ServiceLocatorInterface $services)
    {
        $config = $services->get('Config');
        $this->tempDir = $config['temp_dir'];
        $this->mediaTypeMap = $services->get('Omeka\File\MediaTypeMap');
        $this->store = $services->get('Omeka\File\Store');
        $this->thumbnailManager = $services->get('Omeka\File\ThumbnailManager');
    }

    /**
     * Build a temporary file object.
     *
     * @return TempFile
     */
    public function build()
    {
        return new TempFile($this->tempDir, $this->mediaTypeMap, $this->store, $this->thumbnailManager);
    }
}