本文整理汇总了PHP中League\Flysystem\FilesystemInterface::put方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface::put方法的具体用法?PHP FilesystemInterface::put怎么用?PHP FilesystemInterface::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\FilesystemInterface
的用法示例。
在下文中一共展示了FilesystemInterface::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toFile
/**
* {@inheritdoc}
*/
public function toFile(Workout $workout, string $outputFile) : bool
{
$return = $this->filesystem->put($outputFile, $this->toString($workout));
if ($return !== true) {
throw new Exception(sprintf('Could not write to %s', $outputFile));
}
return true;
}
示例2: generate
/** @inheritdoc */
public function generate(array $replacements, $autoloader)
{
ReflectionEngine::init(new Locator($autoloader));
foreach ($replacements as $replacement) {
$fullPath = $this->vendorDir . '/' . $replacement['package'] . '/proxy/' . str_replace('\\', '/', $replacement['originalFullyQualifiedType']) . ".php";
$this->filesystem->put($fullPath, $this->buildClass($replacement));
}
}
示例3: put
/**
* Write the contents of a file.
*
* @param string $path
* @param string|resource $contents
* @param string $visibility
*
* @return bool
*/
public function put($path, $contents, $visibility = null)
{
$config = ['visibility' => $this->parseVisibility($visibility)];
if (is_resource($contents)) {
return $this->driver->putStream($path, $contents, $config);
}
return $this->driver->put($path, $contents, $config);
}
示例4: writeFile
/**
* @param $filePath
* @param $content
*/
protected function writeFile($filePath, $content)
{
if (is_resource($content)) {
$result = $this->filesystem->putStream($filePath, $content);
} else {
$result = $this->filesystem->put($filePath, $content);
}
if (!$result) {
throw new SaveResourceErrorException('File cannot be written to the path ' . $filePath);
}
}
示例5: put
/**
* Write the contents of a file.
*
* @param string $path
* @param string|resource $contents
* @param array $options
* @return bool
*/
public function put($path, $contents, $options = [])
{
if (is_string($options)) {
$options = ['visibility' => $options];
}
if ($contents instanceof File || $contents instanceof UploadedFile) {
return $this->putFile($path, $contents, $options);
}
if (is_resource($contents)) {
return $this->driver->putStream($path, $contents, $options);
} else {
return $this->driver->put($path, $contents, $options);
}
}
示例6: write
/**
* Write session data
* @link http://php.net/manual/en/sessionhandlerinterface.write.php
* @param string $session_id The session id.
* @param string $session_data <p>
* The encoded session data. This data is the
* result of the PHP internally encoding
* the $_SESSION superglobal to a serialized
* string and passing it as this parameter.
* Please note sessions use an alternative serialization method.
* </p>
* @return bool <p>
* The return value (usually TRUE on success, FALSE on failure).
* Note this value is returned internally to PHP for processing.
* </p>
* @since 5.4.0
*/
public function write($session_id, $session_data)
{
if (!$this->driver->has($path = $this->path . $session_id)) {
$this->driver->create($path);
}
return $this->driver->put($path, $session_data);
}
示例7: put
/**
* Write the contents of a file.
*
* @param string $path
* @param string|resource $contents
* @param string $visibility
* @return bool
*/
public function put($path, $contents, $visibility = null)
{
if ($contents instanceof File || $contents instanceof UploadedFile) {
return $this->putFile($path, $contents, $visibility);
}
if ($visibility = $this->parseVisibility($visibility)) {
$config = ['visibility' => $visibility];
} else {
$config = [];
}
if (is_resource($contents)) {
return $this->driver->putStream($path, $contents, $config);
} else {
return $this->driver->put($path, $contents, $config);
}
}
示例8: write
/**
* @inheritdoc
*/
public function write($path, $contents, $append = false)
{
$path = $this->strategy->encode($path);
if ($append === false && $this->filesystem->has($path)) {
$this->filesystem->delete($path);
}
$this->filesystem->put($path, $contents);
}
示例9: createFile
/**
* @override
* @inheritDoc
*/
public function createFile($path, $contents = '', $visibility = self::VISIBILITY_DEFAULT)
{
try {
$this->fs->put($path, $contents, $this->prepareConfig($visibility));
return;
} catch (Error $ex) {
} catch (Exception $ex) {
}
throw new WriteException("File {$path} could not be created.", $ex);
}
示例10: onGetClassGenerateFile
/**
* Use flysystem to save the file in the desired location.
*
* @param \Onema\ClassyFile\Event\GetClassEvent $event
*/
public function onGetClassGenerateFile(GetClassEvent $event)
{
$statement = $event->getStatements();
$fileLocation = $event->getFileLocation();
$code = $event->getCode();
$name = $statement->name;
if (!$this->filesystem->has($fileLocation)) {
// dir doesn't exist, make it
$this->filesystem->createDir($fileLocation);
}
$location = sprintf('%s/%s.php', $fileLocation, $name);
$this->filesystem->put($location, $code);
$adapter = $this->filesystem->getAdapter();
if ($adapter instanceof AbstractAdapter) {
$prefix = $adapter->getPathPrefix();
$location = Util::normalizePath($location);
$event->setFileLocation(sprintf('%s%s', $prefix, $location));
}
}
示例11: write
/**
* Create a file or update if exists.
*
* @param string $path
* @param string $contents
* @param string $visibility
* @throws IoWriteException
*/
public function write($path, $contents = '', $visibility = self::VISIBILITY_DEFAULT)
{
try {
$this->fs->put($path, $contents, $this->prepareConfig($visibility));
} catch (Error $ex) {
throw new IoWriteException("File {$path} could not be overwritten.", $ex);
} catch (Exception $ex) {
throw new IoWriteException("File {$path} could not be overwritten.", $ex);
}
}
示例12: create
/**
* Create a file or folder.
*
* @param string $path
* @param string|null $contents
*/
protected function create($path, $contents = null)
{
// If the file already exists, quit
$path = $this->formatPath($path);
if ($this->filesystem->has($path)) {
return;
}
// Create the file or folder
if ($contents) {
$this->filesystem->put($path, $contents);
} else {
$this->filesystem->createDir($path);
}
$this->output->writeln('<info>✓</info> Created <comment>' . $path . '</comment>');
}
示例13: downloadAndExtractPackageZipBall
/**
* Downloads the packages zipball from github and extracts it.
*
* @param array $package The selected version of the package.
* @return void
*/
private function downloadAndExtractPackageZipBall($package)
{
// NOTE: We actually use this list to determin if there are any stale
// packages that need to be deleted, so we generate the list here
// before we decide if we need to actually download the package or not.
if (!isset($this->downloaded[$package['name']])) {
$this->downloaded[$package['name']] = [];
}
if (!Linq::from($this->downloaded[$package['name']])->contains($package['version_normalized'])) {
$this->downloaded[$package['name']][] = $package['version_normalized'];
}
$packagePath = $this->vendorDir . '/' . $package['name'] . '/' . $package['version_normalized'];
if ($this->filesystem->has($packagePath)) {
$this->notify("ALREADY HAVE PACKAGE\n");
return;
}
$url = $package['dist']['url'];
$zipBall = $this->http->request('GET', $url)->getBody();
$zipBallPath = $packagePath . '/dist.zip';
$this->filesystem->put($zipBallPath, $zipBall);
$this->zip->extract($zipBallPath, $packagePath);
$this->filesystem->delete($zipBallPath);
$this->notify("DONE\n");
}
示例14: put
/**
* {@inheritdoc}
*/
public function put($path, $contents)
{
return $this->filesystem->put($path, $contents);
}
示例15: generate
/** @inheritdoc */
public function generate(array $installedPackages, array $renamedPackages)
{
$this->installedPackages = $installedPackages;
$this->renamedPackages = $renamedPackages;
$this->filesystem->put($this->vendorDir . '/autoload.php', $this->generateFile());
}