/** * Constructor * * @param string $key File key * @param Storage $storage Storage to use * @param bool $recursive (Optional) By default, Directory will only read the first level if items. * If set to true, Directory will read all children items and list them as one-dimensional array. * @param null|string $filter (Optional) Filter to use when reading directory items * * @throws \Webiny\Component\Storage\StorageException */ public function __construct($key, Storage $storage, $recursive = false, $filter = null) { if (!$storage->supportsDirectories()) { $driver = get_class($storage->getDriver()); throw new StorageException(StorageException::DRIVER_CAN_NOT_WORK_WITH_DIRECTORIES, [$driver]); } $this->key = $key; $this->recursive = $recursive; $this->storage = $storage; if ($this->storage->keyExists($key) && !$this->storage->isDirectory($key)) { throw new StorageException(StorageException::DIRECTORY_OBJECT_CAN_NOT_READ_FILE_PATHS, [$key]); } $this->parseFilter($filter); }
/** * Touch a file (change time modified) * * @return $this */ public function touch() { if ($this->storage->supportsTouching()) { $this->storage->touchKey($this->key); $this->timeModified = null; } return $this; }
/** * Constructor * * @param $accessKeyId * @param $secretAccessKey * @param $bucket * @param bool $dateFolderStructure If true, will append Y/m/d to the key * @param bool $cdnDomain * * @internal param $config */ public function __construct($accessKeyId, $secretAccessKey, $bucket, $dateFolderStructure = false, $cdnDomain = false) { $bridge = Storage::getConfig()->get('Bridges.AmazonS3', '\\Webiny\\Component\\Amazon\\S3'); $this->s3Client = new $bridge($accessKeyId, $secretAccessKey); $this->bucket = $bucket; $this->dateFolderStructure = $dateFolderStructure; $this->cdnDomain = $cdnDomain; }
public function __construct($accessKeyId, $secretAccessKey) { $bridgeClass = Storage::getConfig()->get('Bridges.AmazonS3', '\\Webiny\\Component\\Amazon\\S3'); $mock = $this->getMockBuilder($bridgeClass)->disableOriginalConstructor()->getMock(); $mock->expects($this->any())->method('getObject')->willReturn(['Body' => 'Test contents']); $mock->expects($this->any())->method('deleteObject')->willReturn([]); $mock->expects($this->any())->method('putObject')->willReturn([]); $mock->expects($this->any())->method('doesObjectExist')->will($this->onConsecutiveCalls(true, false)); $this->instance = $mock; }
/** * Constructor * * @param array|ArrayObject $config * * @throws StorageException */ public function __construct($config) { if (is_array($config)) { $config = new ArrayObject($config); } if (!$config instanceof ArrayObject) { throw new StorageException('Storage driver config must be an array or ArrayObject!'); } $bridge = Storage::getConfig()->get('Bridges.AmazonS3', '\\Webiny\\Component\\Amazon\\S3'); $accessKeyId = $config->key('AccessKeyId'); $secretAccessKey = $config->key('SecretAccessKey'); $region = $config->key('Region'); $endpoint = $config->key('Endpoint'); $this->s3Client = new $bridge($accessKeyId, $secretAccessKey, $region, $endpoint); $this->bucket = $config->key('Bucket'); $this->cdnDomain = $config->key('CdnDomain'); $this->meta = $config->key('Meta'); }
public function driverSet() { Storage::setConfig(realpath(__DIR__ . '/' . self::CONFIG)); return [[$this->storage('LocalStorage')]]; }
public function DriverSet() { Storage::setConfig(realpath(__DIR__ . '/' . self::CONFIG)); Logger::setConfig(realpath(__DIR__ . '/' . self::CONFIG)); return [[$this->logger('Webiny')]]; }
public function setUp() { Storage::setConfig(realpath(__DIR__ . '/' . self::CONFIG)); }
public function testConfigServices() { $this->assertFalse(Storage::getConfig()->get('Bridges.FakeBridge', false)); }
public function testConfigServices() { $this->assertSame('%StorageClass%', Storage::getConfig()->get('Services.LocalStorage.Class')); $this->assertFalse(Storage::getConfig()->get('Bridges.FakeBridge', false)); }