本文整理汇总了PHP中FileSystem::dumpFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::dumpFile方法的具体用法?PHP FileSystem::dumpFile怎么用?PHP FileSystem::dumpFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::dumpFile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* Write a file
*
* @param string $path The directory to put the file in (in the current destination)
* @param string $content The file content
* @param string $filename The file name
* @param string $extension The file extension
*/
public function write($path, $content, $extension = 'html', $filename = 'index')
{
$directory = sprintf('%s/%s', $this->destination, trim($path, '/'));
$file = sprintf('%s.%s', $filename, $extension);
if (!$this->files->exists($directory)) {
$this->files->mkdir($directory);
}
$this->files->dumpFile(sprintf('%s/%s', $directory, $file), $content);
}
示例2: highlight
/**
* Highlight a portion of code with pygmentize
*
* @param string $value
* @param string $language
*
* @return string
*/
public function highlight($value, $language)
{
$path = tempnam($this->tmp, 'pyg');
if ($language === 'php' && substr($value, 0, 5) !== '<?php') {
$value = '<?php ' . PHP_EOL . $value;
}
$this->files->dumpFile($path, $value);
$value = $this->pygmentize($path, $language);
unlink($path);
if (preg_match('#^<div class="highlight"><pre>#', $value) && preg_match('#</pre></div>$#', $value)) {
return substr($value, 28, strlen($value) - 40);
}
return $value;
}
示例3: testCleanUp
public function testCleanUp()
{
$fs = new FileSystem();
$fs->dumpFile($this->tmpDir . '/dummy-file', 'Dummy content.');
$dw = new FilesystemDataWriter(new Filesystem(), $this->tmpDir);
$dw->setUp();
$this->assertFileNotExists($this->tmpDir . '/dummy-file');
}
示例4: save
public function save()
{
$items = array();
foreach ($this->instances as $key => $instance) {
$items[$key] = $this->encodeItem($instance);
}
$this->fs->dumpFile($this->getFile(), $this->encodeDocument($items), $this->getFileMode());
}
示例5: setSystemCrontab
protected function setSystemCrontab(OutputInterface $output, $newContents)
{
$tempCronFileName = '/tmp/madrak_io_easy_cron_deployment.cron.' . time();
$filesystem = new FileSystem();
$filesystem->dumpFile($tempCronFileName, $newContents);
$process = new Process('crontab ' . $tempCronFileName);
try {
$process->mustRun();
return $process->getOutput();
} catch (ProcessFailedException $e) {
$this->outputFormattedBlock($output, ['Error!', 'There was an error while attempting to overwrite the existing crontab list.', $e->getMessage()], 'error');
exit;
}
}
示例6: generate
/**
* @param FormMetadata $formMetadata
* @return string
*/
public function generate(FormMetadata $formMetadata)
{
$formMetadata->setCode($this->view->render('templates/class.php.twig', ['form' => $formMetadata]));
$this->fileSystem->mkdir($formMetadata->classDirectory());
$this->fileSystem->dumpFile($formMetadata->classFilename(), $formMetadata->code());
}
示例7: writeDrushAlias
/**
* Writes a local drush alias file.
*/
public function writeDrushAlias()
{
$drush_alias_file_path = "{$_SERVER['HOME']}/.drush/{$this->app->name}.aliases.drushrc.php";
$drush_alias_file = array();
$drush_alias_file[] = '<?php';
foreach ($this->app->environments as $environment_name => $environment) {
$factory = new self($environment, $this->app);
$path = "/source/" . $environment['document_root'];
$drush_alias_file[] = '// DO NOT EDIT. This is generated by Terra. Any changes will be overridden when the environment is re-enabled.';
$drush_alias_file[] = "\$aliases['{$environment_name}'] = array(";
$drush_alias_file[] = " 'uri' => '{$factory->getHost()}:{$factory->getPort()}',";
$drush_alias_file[] = " 'root' => '{$path}',";
$drush_alias_file[] = " 'remote-host' => '{$factory->getHost()}',";
$drush_alias_file[] = " 'remote-user' => 'root',";
$drush_alias_file[] = " 'ssh-options' => '-p {$factory->getDrushPort()}',";
$drush_alias_file[] = ');';
}
$fs = new FileSystem();
try {
$fs->dumpFile($drush_alias_file_path, implode("\n", $drush_alias_file));
return true;
} catch (IOException $e) {
return false;
}
}
示例8: writeConfig
/**
* Write the docker-compose.yml file.
* @return bool
*/
public function writeConfig()
{
// Create the app/environment folder
$fs = new FileSystem();
try {
$fs->mkdir($this->getDockerComposePath());
} catch (IOExceptionInterface $e) {
return FALSE;
}
// Create the environments docker-compose file.
$dumper = new Dumper();
try {
$fs->remove($this->getDockerComposePath() . '/docker-compose.yml');
$fs->dumpFile($this->getDockerComposePath() . '/docker-compose.yml', $dumper->dump($this->getDockerComposeArray(), 10));
return TRUE;
} catch (IOExceptionInterface $e) {
return FALSE;
}
}
示例9: save
public function save()
{
$this->load();
$this->fs->dumpFile($this->getFile(), Yaml::dump($this->data), $this->getFileMode());
}
示例10: writeBehatYamlFiles
/**
* Install Behat yaml files.
*
* @codeCoverageIgnore
*/
protected function writeBehatYamlFiles()
{
$filesystem = new FileSystem();
try {
$filesystem->dumpFile($this->settings->getBaseDir() . '/behat.yml', $this->twig->render('behat.yml.dist', $this->settings->getArrayCopy()));
$filesystem->dumpFile($this->settings->getBaseDir() . '/behat.dev.yml', $this->twig->render('behat.dev.yml.dist', $this->settings->getArrayCopy()));
} catch (IOException $e) {
$this->output->writeln(sprintf('<error>Could not write behat config file, error: "%s"</error>', $e->getMessage()));
return;
}
$this->output->writeln('Behat configuration files are written');
}