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


PHP Filesystem::update方法代码示例

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


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

示例1: testUpdate

 public function testUpdate()
 {
     $path = 'path.txt';
     $contents = 'contents';
     $this->prophecy->has($path)->willReturn(true);
     $this->prophecy->update($path, $contents, $this->config)->willReturn(compact('path', 'contents'));
     $this->assertTrue($this->filesystem->update($path, $contents));
 }
开发者ID:mechiko,项目名称:staff-october,代码行数:8,代码来源:FilesystemTests.php

示例2: publish

 /**
  * @param string $content
  * @param string $path
  * @return bool
  * @throws \InvalidArgumentException
  * @throws \League\Flysystem\FileNotFoundException
  */
 public function publish($content, $path = '')
 {
     if (empty($path)) {
         throw new \InvalidArgumentException('Path is mandatory!');
     }
     $config = new Config();
     try {
         return $this->storage->write($path, $content, $config);
     } catch (FileExistsException $e) {
         return $this->storage->update($path, $content, $config);
     }
 }
开发者ID:mespinosaz,项目名称:data-publisher,代码行数:19,代码来源:Filesystem.php

示例3: run

    public function run()
    {
        $log = new Stream('php://stdout');
        /** @var Config $config */
        $config = Di::getDefault()->getShared('config');
        $expireDate = new DateTime('now', new DateTimeZone('UTC'));
        $expireDate->modify('+1 month');
        $baseUrl = rtrim($config->get('site')->url, '/');
        $content = <<<EOL
User-agent: *
Allow: /
Sitemap: {$baseUrl}/sitemap.xml
EOL;
        $adapter = new Local(dirname(dirname(__FILE__)) . '/public');
        $filesystem = new Filesystem($adapter);
        if ($filesystem->has('robots.txt')) {
            $result = $filesystem->update('robots.txt', $content);
        } else {
            $result = $filesystem->write('robots.txt', $content);
        }
        if ($result) {
            $log->info('The robots.txt was successfully updated');
        } else {
            $log->error('Failed to update the robots.txt file');
        }
    }
开发者ID:phalcon,项目名称:forum,代码行数:26,代码来源:gen-robots.php

示例4: update

 public function update($path, $contents, array $config = [])
 {
     if (parent::update($path, $contents, $config)) {
         return $this->getAdapter()->getModel();
     } else {
         return false;
     }
 }
开发者ID:garrinar,项目名称:laravel,代码行数:8,代码来源:Filesystem.php

示例5: update

 /**
  * @inheritdoc
  */
 public function update($path, $contents, array $config = [])
 {
     try {
         return $this->fileSystem->update($this->getInnerPath($path), $contents, $config);
     } catch (FileNotFoundException $e) {
         throw $this->exceptionWrapper($e, $path);
     }
 }
开发者ID:petrknap,项目名称:php-filestorage,代码行数:11,代码来源:FileSystem.php

示例6: run

 public function run()
 {
     $log = new Stream('php://stdout');
     /** @var Config $config */
     $config = Di::getDefault()->getShared('config');
     $expireDate = new DateTime('now', new DateTimeZone('UTC'));
     $expireDate->modify('+1 day');
     $sitemap = new DOMDocument("1.0", "UTF-8");
     $sitemap->formatOutput = true;
     $urlset = $sitemap->createElement('urlset');
     $urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     $urlset->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $baseUrl = $config->get('site')->url;
     $url = $sitemap->createElement('url');
     $url->appendChild($sitemap->createElement('loc', $baseUrl));
     $url->appendChild($sitemap->createElement('changefreq', 'daily'));
     $url->appendChild($sitemap->createElement('priority', '1.0'));
     $urlset->appendChild($url);
     $karmaSql = 'number_views + ' . '((IF(votes_up IS NOT NULL, votes_up, 0) - IF(votes_down IS NOT NULL, votes_down, 0)) * 4) + ' . 'number_replies';
     $parametersPosts = ['conditions' => 'deleted != 1', 'columns' => "id, slug, modified_at, {$karmaSql} AS karma", 'order' => 'karma DESC'];
     $posts = Posts::find($parametersPosts);
     $parametersKarma = ['column' => $karmaSql, 'conditions' => 'deleted != 1'];
     $karma = Posts::maximum($parametersKarma);
     $modifiedAt = new DateTime('now', new DateTimeZone('UTC'));
     foreach ($posts as $post) {
         $modifiedAt->setTimestamp($post->modified_at);
         $postKarma = $post->karma / ($karma + 100);
         $url = $sitemap->createElement('url');
         $href = trim($baseUrl, '/') . '/discussion/' . $post->id . '/' . $post->slug;
         $url->appendChild($sitemap->createElement('loc', $href));
         $valuePriority = $postKarma > 0.7 ? sprintf("%0.1f", $postKarma) : sprintf("%0.1f", $postKarma + 0.25);
         $url->appendChild($sitemap->createElement('priority', $valuePriority));
         $url->appendChild($sitemap->createElement('lastmod', $modifiedAt->format('Y-m-d\\TH:i:s\\Z')));
         $urlset->appendChild($url);
     }
     $sitemap->appendChild($urlset);
     $adapter = new Local(dirname(dirname(__FILE__)) . '/public');
     $filesystem = new Filesystem($adapter);
     if ($filesystem->has('sitemap.xml')) {
         $result = $filesystem->update('sitemap.xml', $sitemap->saveXML() . PHP_EOL);
     } else {
         $result = $filesystem->write('sitemap.xml', $sitemap->saveXML() . PHP_EOL);
     }
     if ($result) {
         $log->info('The sitemap.xml was successfully updated');
     } else {
         $log->error('Failed to update the sitemap.xml file');
     }
 }
开发者ID:phalcon,项目名称:forum,代码行数:49,代码来源:gen-sitemap.php

示例7: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $dir = $input->getOption("dir");
     $dir = realpath(getcwd() . "/" . ($dir ?: ""));
     if (!is_dir($dir) || !is_writeable($dir)) {
         $output->writeln("<error>Given directory does not exists or is not writeable</error>");
         return;
     }
     $fs = new Filesystem(new Adapter($dir));
     $files = $fs->listContents("", true);
     $updates = [];
     $errors = 0;
     foreach ($files as $file) {
         if ($file['type'] === 'dir') {
             continue;
         }
         $content = $fs->read($file['path']);
         $content = preg_replace_callback(static::SEMVER_REGEX, function ($matches) use(&$updates, &$errors, $input) {
             list($prefix, $ver) = array_slice($matches, 1);
             try {
                 $semver = new version($ver);
             } catch (\Exception $e) {
                 $errors++;
                 return $prefix . $ver;
             }
             if ($input->getOption("major")) {
                 $semver->inc("major");
             } elseif ($input->getOption("minor")) {
                 $semver->inc("minor");
             } elseif ($input->getOption("patch")) {
                 $semver->inc("patch");
             } else {
                 $semver->inc("patch");
             }
             if (!isset($updates[$ver])) {
                 $updates[$ver] = ["count" => 0, "ver" => $semver->getVersion()];
             }
             $updates[$ver]['count']++;
             return $prefix . $semver->getVersion();
         }, $content);
         $fs->update($file['path'], $content);
     }
     foreach ($updates as $update => $count) {
         $output->writeln("<info>{$count['count']} files have been updated from {$update} to {$count['ver']}</info>");
     }
 }
开发者ID:vkbansal,项目名称:php-doc-version,代码行数:46,代码来源:BumpCommand.php

示例8: touch

 /**
  * {@inheritdoc}
  */
 public function touch($key, $expire)
 {
     if (!$this->lock($key)) {
         return false;
     }
     $value = $this->get($key);
     if ($value === false) {
         $this->unlock($key);
         return false;
     }
     $path = $this->path($key);
     $data = $this->wrap($value, $expire);
     try {
         $success = $this->filesystem->update($path, $data);
         return $success && $this->unlock($key);
     } catch (FileNotFoundException $e) {
         $this->unlock($key);
         return false;
     }
 }
开发者ID:matthiasmullie,项目名称:scrapbook,代码行数:23,代码来源:Flysystem.php

示例9: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $version = $input->getArgument("version");
     try {
         $semver = new version($version);
     } catch (\Exception $e) {
         $output->writeln("<error>Given version is not valid. Please provide a semver version</error>");
         return;
     }
     $version = $semver->getVersion();
     $dir = $input->getOption("dir");
     $dir = realpath(getcwd() . "/" . ($dir ?: ""));
     if (!is_dir($dir) || is_writeable($dir)) {
         $output->writeln("Given directory does not exists or is not writeable");
         return;
     }
     $fs = new Filesystem(new Adapter($dir));
     $files = $fs->listContents("", true);
     $updates = [];
     foreach ($files as $file) {
         if ($file['type'] === 'dir') {
             continue;
         }
         $content = $fs->read($file['path']);
         $content = preg_replace_callback(static::SEMVER_REGEX, function ($matches) use($version, &$updates) {
             list($prefix, $ver) = array_slice($matches, 1);
             if (!isset($updates[$ver])) {
                 $updates[$ver] = 0;
             }
             $updates[$ver]++;
             return $prefix . $version;
         }, $content);
         $fs->update($file['path'], $content);
     }
     foreach ($updates as $update => $count) {
         $output->writeln("<info>{$count} files have been updated from {$update} to {$version}</info>");
     }
 }
开发者ID:vkbansal,项目名称:php-doc-version,代码行数:38,代码来源:SetCommand.php

示例10: update

 /**
  * {@inheritDoc}
  */
 public function update($path, $contents, array $config = [])
 {
     parent::update($path, $contents, $config);
     return $this->get($path);
 }
开发者ID:sohailaammarocs,项目名称:lfc,代码行数:8,代码来源:Filesystem.php

示例11: update

 /**
  * Update an existing file.
  *
  * @param string $path     The path of the existing file.
  * @param string $contents The file contents.
  * @param array  $config   An optional configuration array.
  *
  * @throws FileNotFoundException
  *
  * @return bool True on success, false on failure.
  */
 public function update($path, $contents, array $config = [])
 {
     $result = parent::update($path, $contents, $config);
     if ($result && ($resource = $this->get($path))) {
         return $this->dispatch(new SyncFile($resource));
     }
     return $result;
 }
开发者ID:ramcda,项目名称:files-module,代码行数:19,代码来源:AdapterFilesystem.php

示例12: krsort

            }
            krsort($files);
            $errorlog = $sqldir . array_shift($files)[0];
        }
        break;
    default:
        $file .= 'access_log';
        break;
}
// Windows is silly...
if (PHP_OS !== 'Darwin') {
    $errorlog = str_replace('_log', '.log', $file);
}
if (isset($_GET['action']) && $_GET['action'] == 'delete') {
    if ($filesystem->has($errorlog)) {
        $filesystem->update($errorlog, '');
    }
}
if ($filesystem->has($errorlog)) {
    $data = $filesystem->read($errorlog);
} else {
    $data = '';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://raw.githubusercontent.com/Section214/DS3-Log-Viewer/master/log-viewer.php');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$buffer = curl_exec($ch);
curl_close($ch);
if ($buffer) {
开发者ID:Section214,项目名称:DS3-Log-Viewer,代码行数:31,代码来源:page.php

示例13: testUpdate

 /**
  * 1.txt
  * 2.txt.
  */
 public function testUpdate()
 {
     $this->assertTrue($this->filesystem->update('1.txt', '456'));
 }
开发者ID:apollopy,项目名称:flysystem-aliyun-oss,代码行数:8,代码来源:AliyunOssAdapterTest.php

示例14: update

 /**
  * @inheritdoc
  */
 public function update($path, $contents, array $config = [])
 {
     try {
         return parent::update($path, $contents, $config);
     } catch (\Exception $e) {
         $this->errors[] = StringHelper::replace(FileException::FILE_EXISTS, ['path' => $path]);
     }
     return false;
 }
开发者ID:romeoz,项目名称:rock-file,代码行数:12,代码来源:FileManager.php


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