当前位置: 首页>>代码示例>>PHP>>正文


PHP Util::ensureConfig方法代码示例

本文整理汇总了PHP中League\Flysystem\Util::ensureConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::ensureConfig方法的具体用法?PHP Util::ensureConfig怎么用?PHP Util::ensureConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\Flysystem\Util的用法示例。


在下文中一共展示了Util::ensureConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor.
  *
  * @param AdapterInterface $adapter
  * @param CacheInterface   $cache
  * @param mixed            $config
  */
 public function __construct(AdapterInterface $adapter, CacheInterface $cache = null, $config = null)
 {
     $this->adapter = $adapter;
     $this->cache = $cache ?: new Cache\Memory();
     $this->cache->load();
     $this->config = Util::ensureConfig($config);
 }
开发者ID:nguyenducduy,项目名称:phblog,代码行数:14,代码来源:Filesystem.php

示例2: write

 public function write($path, $contents, $config = null)
 {
     $config = Util::ensureConfig($config);
     $this->client->request('PUT', $path, $contents);
     $result = compact('path', 'contents');
     if ($config && ($visibility = $config->get('visibility'))) {
         $this->setVisibility($path, $visibility);
     }
     return $result;
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:10,代码来源:WebDav.php

示例3: write

 /**
  * Write a file
  *
  * @param $path
  * @param $contents
  * @param null $config
  * @return array|bool
  */
 public function write($path, $contents, $config = null)
 {
     $type = 'file';
     $config = Util::ensureConfig($config);
     $result = compact('contents', 'type', 'size', 'path');
     if ($visibility = $config->get('visibility')) {
         $result['visibility'] = $visibility;
     }
     return $result;
 }
开发者ID:limweb,项目名称:webappservice,代码行数:18,代码来源:NullAdapter.php

示例4: write

 public function write($path, $contents, $config = null)
 {
     $dirname = Util::dirname($path);
     $config = Util::ensureConfig($config);
     if (!empty($dirname) && !$this->has($dirname)) {
         $this->createDir($dirname);
     }
     if (!$this->archive->addFromString($path, $contents)) {
         return false;
     }
     $result = compact('path', 'contents');
     if ($config && $config->get('visibility')) {
         throw new LogicException(get_class($this) . ' does not support visibility settings.');
     }
     return $result;
 }
开发者ID:luoshulin,项目名称:falcon,代码行数:16,代码来源:Zip.php

示例5: updateStream

 /**
  * Update a file with the contents of a stream
  *
  * @param   string    $path
  * @param   resource  $resource
  * @param   mixed     $config   Config object or visibility setting
  * @return  bool      success boolean
  * @throws  InvalidArgumentException
  */
 public function updateStream($path, $resource, $config = null)
 {
     if (!is_resource($resource)) {
         throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
     }
     $path = Util::normalizePath($path);
     $config = Util::ensureConfig($config);
     $config->setFallback($this->getConfig());
     $this->assertPresent($path);
     Util::rewindStream($resource);
     if (!($object = $this->adapter->updateStream($path, $resource, $config))) {
         return false;
     }
     $this->cache->updateObject($path, $object + ['contents' => false], true);
     return true;
 }
开发者ID:limweb,项目名称:webappservice,代码行数:25,代码来源:Filesystem.php

示例6: writeStream

 public function writeStream($path, $resource, $config = null)
 {
     $path = Util::normalizePath($path);
     $this->assertAbsent($path);
     $config = Util::ensureConfig($config);
     $config->setFallback($this->getConfig());
     if (!is_resource($resource)) {
         throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
     }
     if (!($object = $this->adapter->writeStream($path, $resource, $config))) {
         return false;
     }
     $this->cache->updateObject($path, $object, true);
     $this->cache->ensureParentDirectories($path);
     return true;
 }
开发者ID:luoshulin,项目名称:falcon,代码行数:16,代码来源:Filesystem.php

示例7: upload

 /**
  * Upload a file.
  *
  * @param string          $path
  * @param string|resource $contents
  * @param Config          $config
  * @return bool
  */
 public function upload($path, $contents, Config $config)
 {
     $connection = $this->getConnection();
     $this->ensureDirectory(Util::dirname($path));
     $config = Util::ensureConfig($config);
     if (!$connection->put($path, $contents, SFTP::SOURCE_STRING)) {
         return false;
     }
     if ($config && ($visibility = $config->get('visibility'))) {
         $this->setVisibility($path, $visibility);
     }
     return true;
 }
开发者ID:acucchieri,项目名称:flysystem-sftp,代码行数:21,代码来源:SftpAdapter.php

示例8: writeStream

 /**
  * Write using a stream
  *
  * @param $path
  * @param $resource
  * @param null $config
  * @return array|bool
  */
 public function writeStream($path, $resource, $config = null)
 {
     rewind($resource);
     $config = Util::ensureConfig($config);
     $location = $this->prefix($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');
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:28,代码来源:Local.php

示例9: setConfig

 /**
  * Set the config.
  *
  * @param Config|array|null $config
  */
 protected function setConfig($config)
 {
     $this->config = $config ? Util::ensureConfig($config) : null;
 }
开发者ID:delboy1978uk,项目名称:flysystem,代码行数:9,代码来源:Filesystem.php

示例10: writeStream

 public function writeStream($path, $resource, $config = null)
 {
     $this->ensureDirectory(Util::dirname($path));
     $config = Util::ensureConfig($config);
     if (!ftp_fput($this->getConnection(), $path, $resource, $this->transferMode)) {
         return false;
     }
     if ($visibility = $config->get('visibility')) {
         $this->setVisibility($path, $visibility);
     }
     return compact('path', 'visibility');
 }
开发者ID:bogolubov,项目名称:owncollab_talks-1,代码行数:12,代码来源:Ftp.php

示例11: write

 public function write($path, $contents, $config = null)
 {
     $connection = $this->getConnection();
     $this->ensureDirectory(Util::dirname($path));
     $config = Util::ensureConfig($config);
     if (!$connection->put($path, $contents, NET_SFTP_STRING)) {
         return false;
     }
     if ($config && ($visibility = $config->get('visibility'))) {
         $this->setVisibility($path, $visibility);
     }
     return compact('contents', 'visibility');
 }
开发者ID:luoshulin,项目名称:falcon,代码行数:13,代码来源:Sftp.php

示例12: writeStream

 /**
  * Write using a stream
  *
  * @param $path
  * @param $resource
  * @param null $config
  * @return array|bool
  */
 public function writeStream($path, $resource, Config $config)
 {
     $username = 'admin';
     $password = '12345678';
     $auth = base64_encode($username . ':' . $password);
     $this->client->setUri('http://192.168.10.47/api/wstest/upload/fg');
     // $this->client->setUri('http://files.local/api/v2/fs');
     $this->client->setMethod('POST');
     $headers = ['Accept' => '*/*', 'Cache-Control' => 'no-cache', 'Authorization' => 'Basic ' . $auth, 'X-File-Name' => 'todo.txt', 'Content-Type' => 'application/x-www-form-urlencoded'];
     $this->client->setHeaders($headers);
     file_put_contents('tmp', $resource);
     //        $this->client->setFileUpload('todo.txt', 'todo_txt', $resource);
     $text = 'this is some plain text';
     $this->client->setFileUpload('some_text.txt', 'some_text_txt', $text, 'text/plain');
     prn($this->client->send()->getContent());
     exit;
     $location = $this->applyPathPrefix($path);
     $config = Util::ensureConfig($config);
     $this->ensureDirectory(dirname($location));
     $this->client->setMethod('POST');
     $this->client->setUri($this->api_url);
     $this->client->setParameterPOST(array_merge($this->auth_param, ['filename' => $path]));
     $this->client->setHeaders(['wp_path' => $path]);
     file_put_contents('tmp', $resource);
     $this->client->setFileUpload('tmp', 'form');
     $response = $this->client->send();
     $path = json_decode($response->getContent())->file_id;
     $type = 'wepo_fs';
     $result = compact('contents', 'type', 'size', 'path');
     if ($visibility = $config->get('visibility')) {
         $result['visibility'] = $visibility;
     }
     return $result;
 }
开发者ID:modelframework,项目名称:modelframework,代码行数:42,代码来源:Wepo.php

示例13: writeStream

 /**
  * Write using a stream
  *
  * @param   string    $path
  * @param   resource  $resource
  * @param   mixed     $config
  *
  * @return  array     file metadata
  */
 public function writeStream($path, $resource, $config = null)
 {
     $config = Util::ensureConfig($config);
     $options = $this->getOptions($path, array('Body' => $resource), $config);
     $this->client->putObject($options);
     return $this->normalizeObject($options);
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:16,代码来源:AwsS3.php

示例14: write

 /**
  * Write a file
  *
  * @param   string  $path
  * @param   string  $contents
  * @param   mixed   $config
  * @return  array   file metadata
  */
 public function write($path, $contents, $config = null)
 {
     $mimeType = Util::guessMimeType($path, $contents);
     if (isset($config)) {
         if (isset($config["mimeType"])) {
             $mimeType = $config["mimeType"];
         }
     }
     $config = Util::ensureConfig($config);
     $options = $this->getOptions($path, array('ContentType' => $mimeType, 'ContentLength' => Util::contentSize($contents)), $config);
     $dirname = dirname($path);
     $filename = basename($path);
     if ($this->has($path)) {
         $isUpdate = true;
         $file = $this->service->files->get($path);
     } else {
         $file = new Google_Service_Drive_DriveFile();
         $file->setTitle($filename);
         $file->setMimeType($mimeType);
         if ($dirname != ".") {
             $parent = new Google_Service_Drive_ParentReference();
             $parent->setId($dirname);
             $file->setParents(array($parent));
         }
     }
     if (isset($isUpdate)) {
         $result = $this->service->files->update($file['id'], $file, array('data' => $contents, 'mimeType' => $mimeType, 'uploadType' => "multipart"));
     } else {
         $result = $this->service->files->insert($file, array('data' => $contents, 'mimeType' => $mimeType, 'uploadType' => "multipart"));
     }
     if ($result === false) {
         return false;
     }
     $result['mimeType'] = $mimeType;
     $result['title'] = $filename;
     $result['id'] = $result->getId();
     return $this->normalizeObject($result);
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:46,代码来源:GoogleDrive.php

示例15: writeStream

 /**
  * Write using a stream
  *
  * @param   string   $path
  * @param   resource $resource
  * @param   mixed    $config ['visibility'='private', 'mimetype'='', 'Metadata'=[]]
  *
  * @return  array     file metadata
  */
 public function writeStream($path, $resource, $config = null)
 {
     $config = Util::ensureConfig($config);
     $options = array('Body' => $resource);
     $options['ContentLength'] = Util::getStreamSize($resource);
     $options = $this->getOptions($path, $options, $config);
     return $this->writeObject($options);
 }
开发者ID:limweb,项目名称:webappservice,代码行数:17,代码来源:AwsS3.php


注:本文中的League\Flysystem\Util::ensureConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。