本文整理汇总了PHP中League\Flysystem\Config::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::get方法的具体用法?PHP Config::get怎么用?PHP Config::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Config
的用法示例。
在下文中一共展示了Config::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeStream
/**
* Write a new file using a stream.
*
* @param string $path
* @param resource $resource
* @param Config $config Config object
*
* @return array|false false on failure file meta data on success
*/
public function writeStream($path, $resource, Config $config)
{
$path = $this->applyPathPrefix($path);
$params = $config->get('params', null);
$mime = $config->get('mime', 'application/octet-stream');
$checkCrc = $config->get('checkCrc', false);
list($ret, $code) = $this->ufileSdk->put($path, $resource, ['Content-Type' => $mime]);
}
示例2: testGet
public function testGet()
{
$config = new Config();
$this->assertFalse($config->has('setting'));
$this->assertNull($config->get('setting'));
$config->set('setting', 'value');
$this->assertEquals('value', $config->get('setting'));
$fallback = new Config(['fallback_setting' => 'fallback_value']);
$config->setFallback($fallback);
$this->assertEquals('fallback_value', $config->get('fallback_setting'));
}
示例3: getOptionsFromConfig
/**
* Returns an array of options from the config.
*
* @param Config $config
* @return array
*/
protected function getOptionsFromConfig(Config $config)
{
$options = [];
if ($config->has('visibility')) {
$options['acl'] = $config->get('visibility') === AdapterInterface::VISIBILITY_PUBLIC ? 'publicRead' : 'private';
}
if ($config->has('mimetype')) {
$options['mimetype'] = $config->get('mimetype');
}
// TODO: consider other metadata which we can set here
return $options;
}
示例4: write
/**
* Write a new file.
*
* @param string $path
* @param string $contents
* @param Config $config Config object
*
* @return array|false false on failure file meta data on success
*/
public function write($path, $contents, Config $config)
{
if ($config->has('ttl') && !$config->has('expirationType')) {
$config->set('expirationType', self::EXPIRE_IN_SECONDS);
}
$args = array_merge([$path, $contents], array_filter([$config->get('expirationType'), $config->get('ttl'), $config->get('setFlag')], function ($value) {
return !is_null($value);
}));
if (!call_user_func_array([$this->client, 'set'], $args)) {
return false;
}
return compact('path', 'contents');
}
示例5: write
/**
* Write a new file.
*
* @param string $path
* @param string $contents
* @param Config $config Config object
*
* @return array|false false on failure file meta data on success
*/
public function write($path, $contents, Config $config)
{
$auth = $this->getAuth();
$token = $auth->uploadToken($this->bucket, $path);
$params = $config->get('params', null);
$mime = $config->get('mime', 'application/octet-stream');
$checkCrc = $config->get('checkCrc', false);
$upload_manager = $this->getUploadManager();
list($ret, $error) = $upload_manager->put($token, $path, $contents, $params, $mime, $checkCrc);
if ($error !== null) {
$this->logQiniuError($error);
return false;
} else {
return $ret;
}
}
示例6: write
/**
* @inheritdoc
*/
public function write($path, $contents, Config $config)
{
$type = 'file';
$result = compact('contents', 'type', 'path');
if ($visibility = $config->get('visibility')) {
$result['visibility'] = $visibility;
}
return $result;
}
示例7: write
/**
* {@inheritdoc}
*/
public function write($path, $contents, Config $config)
{
$location = $this->applyPathPrefix($path);
$headers = [];
if ($config && $config->has('headers')) {
$headers = $config->get('headers');
}
$response = $this->container->uploadObject($location, $contents, $headers);
return $this->normalizeObject($response);
}
示例8: createDir
/**
* {@inheritdoc}
*/
public function createDir($dirname, Config $config)
{
$location = $this->applyPathPrefix($dirname);
$umask = umask(0);
$visibility = $config->get('visibility', 'public');
if (!is_dir($location) && !@mkdir($location, $this->permissionMap['dir'][$visibility], true)) {
$return = false;
} else {
$return = ['path' => $dirname, 'type' => 'dir'];
}
umask($umask);
return $return;
}
示例9: write
/**
* {@inheritdoc}
*/
public function write($path, $contents, Config $config)
{
$location = $this->applyPathPrefix($path);
$this->ensureDirectory(dirname($location));
if (($size = file_put_contents($location, $contents)) === false) {
return false;
}
$type = 'file';
$result = compact('contents', 'type', 'size', 'path');
if ($visibility = $config->get('visibility')) {
$result['visibility'] = $visibility;
$this->setVisibility($path, $visibility);
}
return $result;
}
示例10: writeStream
/**
* {@inheritdoc}
*/
public function writeStream($path, $resource, Config $config)
{
$location = $this->applyPathPrefix($path);
$this->ensureDirectory(dirname($location));
$stream = fopen($location, 'wb+');
if ($stream === false) {
return false;
}
stream_copy_to_stream($resource, $stream);
if (!fclose($stream)) {
return false;
}
if ($visibility = $config->get('visibility')) {
$this->setVisibility($path, $visibility);
}
return compact('path', 'visibility');
}
示例11: writeStream
/**
* {@inheritdoc}
*/
public function writeStream($path, $resource, Config $config)
{
$location = $this->applyPathPrefix($path);
$this->ensureDirectory(dirname($location));
if (!($stream = fopen($location, 'w'))) {
return false;
}
while (!feof($resource)) {
fwrite($stream, fread($resource, 1024), 1024);
}
if (!fclose($stream)) {
return false;
}
if ($visibility = $config->get('visibility')) {
$this->setVisibility($path, $visibility);
}
return compact('path', 'visibility');
}
示例12: getOptionsFromConfig
/**
* Returns an array of options from the config.
*
* @param Config $config
* @return array
*/
protected function getOptionsFromConfig(Config $config)
{
$options = [];
if ($visibility = $config->get('visibility')) {
$options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility);
} else {
// if a file is created without an acl, it isn't accessible via the console
// we therefore default to private
$options['predefinedAcl'] = $this->getPredefinedAclForVisibility(AdapterInterface::VISIBILITY_PRIVATE);
}
return $options;
}
示例13: doMirror
private function doMirror($originDir, $targetDir, Flysystem\Config $config)
{
if ($config->get('delete', true) && $this->doHas($targetDir)) {
$it = $this->getIterator($targetDir, \RecursiveIteratorIterator::CHILD_FIRST);
foreach ($it as $handler) {
/** @var HandlerInterface $handler */
$origin = str_replace($targetDir, $originDir, $handler->getPath());
if (!$this->doHas($origin)) {
if ($handler->isDir()) {
$this->doDeleteDir($handler->getPath());
} else {
$this->doDelete($handler->getPath());
}
}
}
}
if ($this->doHas($originDir)) {
$this->doCreateDir($targetDir, $config);
}
$it = $this->getIterator($originDir, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($it as $handler) {
$target = str_replace($originDir, $targetDir, $handler->getPath());
if ($handler->isDir()) {
$this->doCreateDir($target, $config);
} else {
$this->doCopy($handler->getPath(), $target, $config->get('override'));
}
}
}
示例14: update
/**
* {@inheritdoc}
*/
public function update($path, $contents, Config $config)
{
if (!$this->hasFile($path)) {
return false;
}
$this->storage[$path]['contents'] = $contents;
$this->storage[$path]['timestamp'] = time();
$this->storage[$path]['size'] = Util::contentSize($contents);
$this->storage[$path]['mimetype'] = Util::guessMimeType($path, $contents);
if ($visibility = $config->get('visibility')) {
$this->setVisibility($path, $visibility);
}
return $this->getMetadata($path);
}
示例15: upload
/**
* Upload|Update item
*
* @param string $path
* @param string|resource $contents
* @param Config $config
*
* @return array|false item info array
*/
protected function upload($path, $contents, Config $config)
{
list($parentId, $fileName) = $this->splitPath($path);
$mode = 'update';
$mime = $config->get('mimetype');
$srcFile = $this->getFileObject($path);
$file = new Google_Service_Drive_DriveFile();
if (!$srcFile) {
$mode = 'insert';
$file->setName($fileName);
$file->setParents([$parentId]);
}
$isResource = false;
if (is_resource($contents)) {
$fstat = @fstat($contents);
if (!empty($fstat['size'])) {
$isResource = true;
}
if (!$isResource) {
$contents = stream_get_contents($contents);
}
}
if ($isResource) {
// set chunk size (max: 100MB)
$chunkSizeBytes = 100 * 1024 * 1024;
$memory = $this->getIniBytes('memory_limit');
if ($memory) {
$chunkSizeBytes = min([$chunkSizeBytes, intval($memory / 4 / 256) * 256]);
}
if ($fstat['size'] < $chunkSizeBytes) {
$isResource = false;
$contents = stream_get_contents($contents);
}
}
if (!$mime) {
$mime = Util::guessMimeType($fileName, $isResource ? '' : $contents);
}
$file->setMimeType($mime);
if ($isResource) {
$client = $this->service->getClient();
// Call the API with the media upload, defer so it doesn't immediately return.
$client->setDefer(true);
if ($mode === 'insert') {
$request = $this->service->files->create($file, ['fields' => self::FETCHFIELDS_GET]);
} else {
$request = $this->service->files->update($srcFile->getId(), $file, ['fields' => self::FETCHFIELDS_GET]);
}
// Create a media file upload to represent our upload process.
$media = new Google_Http_MediaFileUpload($client, $request, $mime, null, true, $chunkSizeBytes);
$media->setFileSize($fstat['size']);
// Upload the various chunks. $status will be false until the process is
// complete.
$status = false;
$handle = $contents;
while (!$status && !feof($handle)) {
// read until you get $chunkSizeBytes from TESTFILE
// fread will never return more than 8192 bytes if the stream is read buffered and it does not represent a plain file
// An example of a read buffered file is when reading from a URL
$chunk = $this->readFileChunk($handle, $chunkSizeBytes);
$status = $media->nextChunk($chunk);
}
// The final value of $status will be the data from the API for the object
// that has been uploaded.
if ($status != false) {
$obj = $status;
}
$client->setDefer(false);
} else {
$params = ['data' => $contents, 'uploadType' => 'media', 'fields' => self::FETCHFIELDS_GET];
if ($mode === 'insert') {
$obj = $this->service->files->create($file, $params);
} else {
$obj = $this->service->files->update($srcFile->getId(), $file, $params);
}
}
if ($obj instanceof Google_Service_Drive_DriveFile) {
$this->cacheFileObjects[$obj->getId()] = $obj;
if ($mode === 'insert') {
$this->cacheFileObjects[$fileName] = $obj;
}
$result = $this->normaliseObject($obj, Util::dirname($path));
if ($visibility = $config->get('visibility')) {
if ($this->setVisibility($path, $visibility)) {
$result['visibility'] = $visibility;
}
}
return $result;
}
return false;
}