本文整理汇总了PHP中FileWriter::write方法的典型用法代码示例。如果您正苦于以下问题:PHP FileWriter::write方法的具体用法?PHP FileWriter::write怎么用?PHP FileWriter::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileWriter
的用法示例。
在下文中一共展示了FileWriter::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
function create(&$dto)
{
if (!$dto->copyImageDir) {
$dto->copyImageDir = IMAGES_DIR;
}
if ($dto->copyImageDir == THEME_IMAGES_DIR . "thumbnail/") {
$filename = $this->config->getValue("WEBAPP_THEME_DIR");
$pathList = explode("_", $dto->actionName);
if (isset($pathList[1])) {
$filename .= "/" . $pathList[0] . "/images/" . $pathList[1] . "/";
} else {
$filename .= "/" . $pathList[0] . "/images/";
}
} else {
if ($dto->copyImageDir == THEME_IMAGES_DIR . "images/") {
$filename = $this->config->getValue("WEBAPP_THEME_DIR");
$filename .= "/" . $dto->themeName . "/images/";
} else {
if ($dto->templateDir) {
$filename = $this->config->getValue("WEBAPP_MODULE_DIR") . "/" . $dto->moduleName . "/files/images/" . $dto->templateDir . "/";
} else {
$filename = $this->config->getValue("WEBAPP_MODULE_DIR") . "/" . $dto->moduleName . "/files/images/";
}
}
}
return $this->writer->write($filename, $dto->copyImageDir);
}
示例2: addReport
public function addReport(AnalyzerReport $analyzerReport)
{
$report = $analyzerReport->getTimestampedReport()->getReport();
if ($this->task->isHaltonerror() && '' === $this->buildErrorMessage && $analyzerReport->getAnalyzer()->getSeverity() === Severity::ERROR) {
$this->buildErrorMessage = $report->report();
}
if ($this->logfileWriter && $this->logFormat === 'plain') {
/** @noinspection PhpParamsInspection */
$this->logfileWriter->write(Plain::formatReportReadable($analyzerReport));
} else {
$this->task->log(self::formatReport($analyzerReport), self::severityToPhingLevel($analyzerReport->getAnalyzer()->getSeverity()));
}
}
示例3: output
/**
* $templateを読み込んで$outputFileに書き出す
* 文字エンコーディングには$outputEncodingを使用する
* $varsはテンプレートから $skeleton としてアクセスできる
*
* 基本的に処理は$writerに委譲し、
* 結果を配列の形にまとめる
*
* $templateの指定がない場合、getTemplateFileで自動生成
* $outputEncodingの指定がない場合、SCRIPT_CODEを使用
*
* @param String $outputFile
* @param array $vars
* @param String $outputEncoding [optional]
* @param String $template [optional]
* @return array
*/
function output($outputFile, $vars, $outputEncoding = 'SCRIPT_CODE', $template = "")
{
if ($template == "") {
$template = $this->getTemplateFile();
}
$stat = '';
if (file_exists($outputFile)) {
$stat = 'exists';
} else {
$stat = $this->writer->write($template, $outputFile, $vars, $outputEncoding) ? 'create' : 'fail';
}
return array($outputFile => $stat);
}
示例4: writeLocalConfigurationArray
protected function writeLocalConfigurationArray()
{
$configuration = new ConfigurationUtility($this->localConfiguration);
$phpCode = $configuration->getLocalConfigurationArray();
$this->fileWriter->write($phpCode);
$this->fileWriter->close();
}
示例5: save
public static function save(Utility $utility)
{
$file = UTILITIES . "/{$utility->name}";
FileWriter::write($file, $utility->body, Symphony::Configuration()->core()->symphony->{'file-write-mode'});
//General::writeFile($file, $utility->body,Symphony::Configuration()->core()->symphony->{'file-write-mode'});
return file_exists($file);
}
示例6: testWriter
public function testWriter()
{
$filename = tempnam(sys_get_temp_dir(), 'phpwriter');
$writer = new FileWriter($filename);
$writer->write('some text');
$writer->close();
$this->assertEquals('some text', file_get_contents($filename));
// clean up temp file
unlink($filename);
}
示例7: connect
/**
* Returns routes to connect to the given application.
*
* @param Application $app An Application instance
*
* @return ControllerCollection A ControllerCollection instance
*/
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
$controllers->get('{_locale}', function ($_locale) use($app) {
$directoryTrans = __DIR__ . '/../../../../../../app/trans/en.json';
$oldCatalogue = new DataCatalogue();
$oldCatalogue->load($directoryTrans, 'json', 'en');
$extractor = new FileExtractor($this->twig);
$catalogue = $extractor->extract();
$fileWriter = new FileWriter();
$fileWriter->write($catalogue, $directoryTrans, 'json');
return $app['twig']->render('Demo/Default/test.html.twig');
})->bind('blueLinesHome');
return $controllers;
}
示例8: main
public function main()
{
if (NULL === $this->base) {
throw new BuildException('You must specify the base file!');
}
if (NULL === $this->update) {
throw new BuildException('You must specify the update file!');
}
$baseConfiguration = (array) (include $this->base->getAbsolutePath());
$updateConfiguration = (array) (include $this->update->getAbsolutePath());
$mergedConfiguration = ArrayUtility::array_merge_recursive_overrule($baseConfiguration, $updateConfiguration, FALSE, $this->includeEmptyValues);
$configuration = new ConfigurationUtility($mergedConfiguration);
$phpCode = $configuration->getLocalConfigurationArray();
if (NULL === $this->fileWriter) {
$this->addFileWriter();
}
$this->fileWriter->write($phpCode);
$this->fileWriter->close();
}
示例9: transform
private function transform(DOMDocument $document)
{
$dir = new PhingFile($this->toDir);
if (!$dir->exists()) {
throw new BuildException("Directory '" . $this->toDir . "' does not exist");
}
$xslfile = $this->getStyleSheet();
$xsl = new DOMDocument();
$xsl->load($xslfile->getAbsolutePath());
$proc = new XSLTProcessor();
$proc->importStyleSheet($xsl);
if ($this->format == "noframes") {
$writer = new FileWriter(new PhingFile($this->toDir, "checkstyle-noframes.html"));
$writer->write($proc->transformToXML($document));
$writer->close();
} else {
ExtendedFileStream::registerStream();
// no output for the framed report
// it's all done by extension...
$dir = new PhingFile($this->toDir);
$proc->setParameter('', 'output.dir', $dir->getAbsolutePath());
$proc->transformToXML($document);
}
}
示例10: main
/**
* Execute lint check against PhingFile or a FileSet
*/
public function main()
{
if (!isset($this->file) and count($this->filesets) == 0) {
throw new BuildException("Missing either a nested fileset or attribute 'file' set");
}
if ($this->file instanceof PhingFile) {
$this->lint($this->file->getPath());
} else {
// process filesets
$project = $this->getProject();
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($project);
$files = $ds->getIncludedFiles();
$dir = $fs->getDir($this->project)->getPath();
foreach ($files as $file) {
$this->lint($dir . DIRECTORY_SEPARATOR . $file);
}
}
}
// write list of 'bad files' to file (if specified)
if ($this->tofile) {
$writer = new FileWriter($this->tofile);
foreach ($this->badFiles as $file => $messages) {
foreach ($messages as $msg) {
$writer->write($file . "=" . $msg . PHP_EOL);
}
}
$writer->close();
}
// save list of 'bad files' with errors to property errorproperty (if specified)
if ($this->errorProperty) {
$message = '';
foreach ($this->badFiles as $file => $messages) {
foreach ($messages as $msg) {
$message .= $file . "=" . $msg . PHP_EOL;
}
}
$this->project->setProperty($this->errorProperty, $message);
}
if ($this->haltOnFailure && $this->hasErrors) {
throw new BuildException('Syntax error(s) in PHP files: ' . implode(', ', $this->badFiles));
}
}
示例11: testWriteToNonexistentDirectory
/**
* @covers Zepto\FileWriter::write()
* @expectedException Exception
*/
public function testWriteToNonexistentDirectory()
{
$this->writer->write(ROOT_DIR . 'tests/fail/testfile.txt', 'Test content');
}
示例12: main
/**
* Execute lint check against PhingFile or a FileSet
*/
public function main()
{
if (!isset($this->file) and count($this->filesets) == 0) {
throw new BuildException("Missing either a nested fileset or attribute 'file' set");
}
exec($this->executable, $output);
if (!preg_match('/JavaScript\\sLint/', implode('', $output))) {
throw new BuildException('Javascript Lint not found');
}
if ($this->file instanceof PhingFile) {
$this->lint($this->file->getPath());
} else {
// process filesets
$project = $this->getProject();
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($project);
$files = $ds->getIncludedFiles();
$dir = $fs->getDir($this->project)->getPath();
foreach ($files as $file) {
$this->lint($dir . DIRECTORY_SEPARATOR . $file);
}
}
}
// write list of 'bad files' to file (if specified)
if ($this->tofile) {
$writer = new FileWriter($this->tofile);
foreach ($this->badFiles as $file => $messages) {
foreach ($messages as $msg) {
$writer->write($file . "=" . $msg . PHP_EOL);
}
}
$writer->close();
}
if ($this->haltOnFailure && $this->hasErrors) {
throw new BuildException('Syntax error(s) in JS files:' . implode(', ', array_keys($this->badFiles)));
}
}
示例13: main
/**
* Default constructor.
* @return void
* @throws BuildException
*/
public function main()
{
$this->log("Propel - CreoleToXMLSchema starting");
$this->log("Your DB settings are:");
$this->log("driver : " . ($this->dbDriver ? $this->dbDriver : "(default)"));
$this->log("URL : " . $this->dbUrl);
//(not yet supported) $this->log("schema : " . $this->dbSchema);
//DocumentTypeImpl docType = new DocumentTypeImpl(null, "database", null,
// "http://jakarta.apache.org/turbine/dtd/database.dtd");
$this->doc = new DOMDocument('1.0', 'utf-8');
$this->doc->formatOutput = true;
// pretty printing
$this->doc->appendChild($this->doc->createComment("Autogenerated by CreoleToXMLSchema!"));
try {
$this->generateXML();
$this->log("Writing XML to file: " . $this->xmlSchema);
$outFile = new PhingFile($this->xmlSchema);
$out = new FileWriter($outFile);
$xmlstr = $this->doc->saveXML();
$out->write($xmlstr);
$out->close();
} catch (Exception $e) {
$this->log("There was an error building XML from metadata: " . $e->getMessage(), PROJECT_MSG_ERR);
}
$this->log("Propel - CreoleToXMLSchema finished");
}
示例14: _writeFile
/**
* Writing a file.
*
* @param PhingFile $file The file to write
* @param mixed $content The file's content
* @return void
* @throws BuildException
* @access protected
**/
protected function _writeFile(PhingFile $file, $content)
{
if ($this->_preserveLastModified) {
$lastModified = $file->lastModified();
}
$output = new FileWriter($file);
$output->write($content);
$output->close();
if ($this->_preserveLastModified) {
$file->setLastModified($lastModified);
}
}
示例15: appendFile
private function appendFile(FileWriter $writer, PhingFile $f)
{
$in = FileUtils::getChainedReader(new FileReader($f), $this->filterChains, $this->project);
while (-1 !== ($buffer = $in->read())) {
// -1 indicates EOF
$writer->write($buffer);
}
$this->log("Appending contents of " . $f->getPath() . " to " . $this->to->getPath());
}