本文整理汇总了PHP中League\Flysystem\Config::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::set方法的具体用法?PHP Config::set怎么用?PHP Config::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Config
的用法示例。
在下文中一共展示了Config::set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
示例2: 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');
}
示例3: upload
/**
* Upload an object.
*
* @param $path
* @param $body
* @param Config $config
*
* @return array
*/
protected function upload($path, $body, Config $config)
{
$key = $this->applyPathPrefix($path);
$mimetype = MimeType::detectByFileExtension(pathinfo($path, PATHINFO_EXTENSION));
$config->set('mimetype', $mimetype);
$return = parent::upload($path, $body, $config);
if (function_exists('getimagesizefromstring') && strpos($mimetype, 'image') !== false) {
if (is_resource($body)) {
rewind($body);
$size = getimagesizefromstring(stream_get_contents($body));
} else {
$size = getimagesizefromstring($body);
}
$this->s3Client->copyObject(['Bucket' => $this->bucket, 'CopySource' => $this->bucket . DS . $key, 'ContentType' => $mimetype, 'Metadata' => ['width' => $size[0], 'height' => $size[1]], 'MetadataDirective' => 'REPLACE', 'Key' => $key]);
}
return $return;
}
示例4: updateStream
/**
* {@inheritdoc}
*/
public function updateStream($path, $resource, Config $config)
{
if (!$config->has('visibility') && !$config->has('ACL')) {
$config->set('ACL', $this->getObjectACL($path));
}
return $this->writeStream($path, $resource, $config);
}
示例5: configureServer
/**
* Configure server files for this store
*
* @param bool $forceOverwrite Force regeneration even if files already exist
* @throws \Exception
*/
protected function configureServer($forceOverwrite = false)
{
// Get server type
$type = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '*';
list($type) = explode('/', strtolower($type));
// Determine configurations to write
$rules = Config::inst()->get(get_class($this), 'server_configuration', Config::FIRST_SET);
if (empty($rules[$type])) {
return;
}
$configurations = $rules[$type];
// Apply each configuration
$config = new FlysystemConfig();
$config->set('visibility', 'private');
foreach ($configurations as $file => $template) {
if ($forceOverwrite || !$this->has($file)) {
// Evaluate file
$content = $this->renderTemplate($template);
$success = $this->write($file, $content, $config);
if (!$success) {
throw new \Exception("Error writing server configuration file \"{$file}\"");
}
}
}
}