Source of file ImageBackendFactory.php
Size: 0,985 Bytes - Last Modified: 2021-12-23T10:49:22+00:00
/var/www/docs.ssmods.com/process/src/src/Symbiote/ContentServiceAssets/ImageBackendFactory.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445 | <?php namespace Symbiote\ContentServiceAssets; use Director; use File; use ReflectionClass; use SilverStripe\Framework\Injector\Factory; /** * An image backend factory which ensures that files are downloaded from the CDN. */ class ImageBackendFactory implements Factory { private $backend; /** * @param string $backend The underlying backend name. */ public function __construct($backend) { $this->backend = $backend; } public function create($service, array $params = array()) { $path = $params[0]; if (!file_exists($path) || filesize($path) == 0) { $filename = Director::makeRelative($path); $file = File::find(trim($filename, '/')); if ($file) { $file->downloadFromContentService(); singleton('ContentDeliveryService')->removeLocalFile($file->getFullPath()); } else { $o = 1; } } $reflector = new ReflectionClass($this->backend); return $reflector->newInstanceArgs($params); } } |