/** * Start the site Scraping process. * * @param string $url * @param \GuzzleHttp\Psr7\Stream $body * * @return void */ protected function writePage($url, $body) { $page = $this->getPage($url); $body = str_replace($this->localSite, $this->remo, "{$body}"); $write = $this->fs->put($page, $body); return $write; }
/** * {@inheritdoc} */ public function slash() { $app_path = str_replace(config('path.root'), '', config()->path->app); $arg_name = studly_case(str_slug($this->input->getArgument('name'), '_')); $stub = file_get_contents(__DIR__ . '/stubs/makeRoute.stub'); $stub = stubify($stub, ['routeName' => $arg_name, 'prefixRouteName' => strtolower($arg_name)]); $file_name = $arg_name . 'Routes.php'; $module = $this->input->getArgument('module'); $has_dir = is_dir(config()->path->app . $module); if ($has_dir === false) { $this->error('Module not found `' . $module . '`'); return; } $module = $this->input->getArgument('module'); if ($this->app->has($module) === false) { $this->error('Module not found `' . $module . '`'); return; } $routes = $module . '/routes/'; if ($this->app->has($routes) === false) { $this->error('Routes folder not found from your module: `' . $module . '`'); return; } $stub = stubify($stub, ['namespace' => path_to_namespace($app_path . $routes), 'controllerNamespace' => path_to_namespace($app_path . $module . '/controllers/')]); $this->info('Crafting Route...'); if ($this->app->has($file_name)) { $this->error(' Route already exists!'); return; } $this->app->put($routes . $file_name, $stub); $this->info(' ' . $file_name . ' created!'); $this->callDumpAutoload(); }
public function testDeleteMockResourceExistsSizes() { $resourceDO = $this->getResourceDOMock(); $this->filesystem->put($resourceDO->getFilePath(), ''); $resourceDOSize10x11 = $this->getResourceDOMock(); $resourceDOSize10x11->setWidth(10); $resourceDOSize10x11->setHeight(11); $this->filesystem->put($resourceDOSize10x11->getFilePath(), ''); $resourceDOSize20x21 = $this->getResourceDOMock(); $resourceDOSize20x21->setWidth(20); $resourceDOSize20x21->setHeight(21); $this->filesystem->put($resourceDOSize20x21->getFilePath(), ''); $yetAnotherWrongDO = clone $resourceDO; $yetAnotherWrongDO->setWidth(998); $yetAnotherWrongDO->setHeight(999); $this->wrongFiles->create($resourceDO, 'Wrong1'); $this->wrongFiles->create($resourceDOSize10x11, 'Wrong2'); $this->wrongFiles->create($resourceDOSize20x21, 'Wrong3'); $this->wrongFiles->create($yetAnotherWrongDO, 'Wrong4'); $modelFiles = $this->filesystem->listContents('/', true); // Make the expected model looks like filesystem after the command execution // With this model we will be sure that other files have not been deleted unset($modelFiles[56], $modelFiles[57]); $modelFiles[55] = ['type' => 'dir', 'path' => 'testBase/png/def/def/0/c9f/20x21', 'dirname' => 'testBase/png/def/def/0/c9f', 'basename' => '20x21', 'filename' => '20x21']; $command = $this->getCommand($resourceDO); $result = $command(); $this->assertTrue($result); $this->assertFalse($this->filesystem->has($resourceDOSize10x11->getFilePath())); $this->assertFalse($this->filesystem->has($resourceDOSize20x21->getFilePath())); $result = $this->filesystem->listContents('/', true); $this->assertEquals($modelFiles, $result); }
/** * {@inheritdoc} */ public function write(Configuration $configuration) { $ini = $this->getRenderer()->render($configuration->toArray()); if (false === ($result = $this->filesystem->put($this->file, $ini))) { throw new WriterException(sprintf('Cannot write configuration into file %s', $this->file)); } return $result; }
public function storeVersion(Versionable $versionable, Version $version, $tempFile) { $pathName = $this->getVersionPathName($versionable, $version); $ret = $this->filesystem->put($pathName, file_get_contents($tempFile), ['visibility' => AdapterInterface::VISIBILITY_PRIVATE]); if (!$ret) { throw new FileIOException(sprintf("Failed to store version '%s' of versionable %s;%s", $version->toString(), get_class($versionable), $versionable->getId())); } return new Retrieved($tempFile); }
public function write($id, $config, array $options = []) { $this->id = $id; $this->config = $config; $this->timestamp = time(); if (!$this->filesystem->put($this->getPathFromId($id), $this->dump(['lunch_guy' => $config]))) { throw new \RuntimeException("Failed to write configuration {$id}"); } }
/** * Downloads a request * * @param RequestInterface $request * * @return boolean */ public function download(RequestInterface $request, $path) { $response = $this->httpAdapter->sendRequest($request); if (!($body = $response->getBody())) { return false; } $stream = $body->detach(); if (is_resource($stream)) { return $this->filesystem->putStream($path, $stream); } return $this->filesystem->put($path, $stream); }
/** * Returns the historical price data as a csv string for $ticker * @param string $ticker * @param bool $fromCache * @param bool $saveToCache * @param bool $return * @return TickerCollection */ public function getData($ticker, $fromCache = true, $saveToCache = true, $return = true) { if ($fromCache && $this->fileSystem->has($ticker)) { return $this->present($ticker, $this->fileSystem->read($ticker)); } $data = (string) $this->guzzle->request('GET', '', ['query' => ['s' => $ticker, 'ignore' => '.csv']])->getBody(); if ($saveToCache) { $this->fileSystem->put($ticker, $data); } if ($return) { return $this->present($ticker, $data); } }
public function testFindVersion8() { $resourceDO_v0 = $this->getResourceDOMock(); $this->filesystem->put($resourceDO_v0->getFilePath(), ''); // Put one more version on disk $expectedVersion = $resourceDO_v0->getVersion() + 7; $resourceDO_v1 = clone $resourceDO_v0; $resourceDO_v1->setVersion($expectedVersion); $this->filesystem->put($resourceDO_v1->getFilePath(), ''); $command = $this->getCommand($resourceDO_v0); $result = $command(); $this->assertEquals($expectedVersion, $result); }
function it_throws_an_exception_when_configuration_cannot_be_written(Flysystem $filesystem, Renderer $renderer, Configuration $configuration) { $renderer->render($configuration)->willReturn('contents'); $filesystem->put('file', 'contents')->willReturn(false); $this->beConstructedWith($filesystem, 'file', $renderer); $this->shouldThrow('Indigo\\Supervisor\\Exception\\WrittingFailed')->duringWrite($configuration); }
public function testDestroyResourceAllVariantsAndVersions() { $resourceDO = $this->getResourceDOMock(); $this->filesystem->put($resourceDO->getFilePath(), ''); $resourceDO_v2 = clone $resourceDO; $resourceDO_v2->setVersion(2); $this->filesystem->put($resourceDO_v2->getFilePath(), ''); $resourceDO_var1 = clone $resourceDO; $resourceDO_var1->setVariant('1'); $this->filesystem->put($resourceDO_var1->getFilePath(), ''); // variant version must be deleted too $resourceDO_var1_v1 = clone $resourceDO_var1; $resourceDO_var1_v1->setVersion(1); $this->filesystem->put($resourceDO_var1_v1->getFilePath(), ''); $resourceDO_var2 = clone $resourceDO; $resourceDO_var2->setVariant('2'); $this->filesystem->put($resourceDO_var2->getFilePath(), ''); $resourceDO_var2_v1 = clone $resourceDO_var2; $resourceDO_var2_v1->setVersion(2); $this->filesystem->put($resourceDO_var2_v1->getFilePath(), ''); $command = $this->getCommand($resourceDO); $result = $command(); $this->assertEquals($resourceDO, $result); $this->assertFalse($this->filesystem->has($resourceDO_var1->getFilePath())); $this->assertFalse($this->filesystem->has($resourceDO_var1_v1->getFilePath())); $this->assertFalse($this->filesystem->has($resourceDO_v2->getFilePath())); $this->assertFalse($this->filesystem->has($resourceDO_var2->getFilePath())); $this->assertFalse($this->filesystem->has($resourceDO_var2_v1->getFilePath())); $this->assertFalse($this->filesystem->has($resourceDO->getFilePath())); }
public function testPutUpdate() { $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->put($path, $contents)); }
/** * @inheritdoc */ public function put($path, $contents, array $config = []) { if (parent::put($path, $contents, $config)) { return $this->getAdapter()->getModel(); } else { return false; } }
public function testBackupResourceWhenAnotherCopyAlreadyExist() { $resourceDO_v0 = $this->getResourceDOMock(); $this->filesystem->put($resourceDO_v0->getFilePath(), ''); // Put one more version on disk $resourceDO_v1 = clone $resourceDO_v0; $resourceDO_v1->setVersion($resourceDO_v0->getVersion() + 1); $this->filesystem->put($resourceDO_v1->getFilePath(), ''); $expectedVersion = (string) ($resourceDO_v0->getVersion() + 2); $command = $this->getCommand($resourceDO_v0); $result = $command(); $this->assertInstanceOf(ResourceDOInterface::class, $result); $this->assertEquals($expectedVersion, $result->getVersion()); $resourceDO_v2 = clone $resourceDO_v0; $resourceDO_v2->setVersion($expectedVersion); $this->assertTrue($this->filesystem->has($resourceDO_v2->getFilePath(), '')); }
/** * Creates/uploads/updates a file on oc remote * * @param string $localPath File on local server * @param string $remotePath File on oc Server * @throws FileNotFoundException * @return bool * */ public function createFile($localPath, $remotePath = '') { //if local file not exists throw exception if (!file_exists($localPath)) { throw new FileNotFoundException("OwncloudApi: Local file not found"); } //otherwise upload to server return $this->fs->put($remotePath, file_get_contents($localPath)); }
function it_handles_ivory_interface_incompatibility(Filesystem $filesystem, HttpAdapterInterface $httpAdapter, Request $request, Response $response, Stream $stream) { $httpAdapter->sendRequest($request)->willReturn($response); $response->getBody()->willReturn($stream); $stream->detach()->willReturn('text'); $filesystem->putStream('path/to/file', Argument::type('resource'))->shouldNotBeCalled(); $filesystem->put('path/to/file', 'text')->willReturn(true); $this->download($request, 'path/to/file')->shouldReturn(true); }
public function upload(FileInterface $file, $name, $path = null) { $path = is_null($path) ? $name : sprintf('%s/%s', $path, $name); if ($file instanceof FlysystemFile) { if ($file->getFilesystem() == $this->filesystem) { $file->getFilesystem()->rename($file->getPath(), $path); return new FlysystemFile($this->filesystem->get($path), $this->filesystem, $this->streamWrapperPrefix); } } $this->filesystem->put($name, file_get_contents($file)); if ($file instanceof FlysystemFile) { $file->delete(); } else { $filesystem = new LocalFilesystem(); $filesystem->remove($file->getPathname()); } return new FlysystemFile($this->filesystem->get($path), $this->filesystem, $this->streamWrapperPrefix); }
/** * @inheritdoc */ public function put($path, $contents, array $config = []) { $addToIndex = !$this->has($path); $innerPath = $this->getInnerPath($path); $return = $this->fileSystem->put($innerPath, $contents, $config); if ($return !== false && $addToIndex) { $this->invokePlugin("addPathToIndex", [$path, $innerPath], $this); } return $return; }
/** * {@inheritdoc} */ public function set($key, $value, $expire = 0) { // we don't really need a lock for this operation, but we need to make // sure it's not locked by another operation, which we could overwrite if (!$this->lock($key)) { return false; } $expire = $this->normalizeTime($expire); if ($expire !== 0 && $expire < time()) { $this->unlock($key); // don't waste time storing (and later comparing expiration // timestamp) data that is already expired; just delete it already return !$this->exists($key) || $this->delete($key); } $path = $this->path($key); $data = $this->wrap($value, $expire); $success = $this->filesystem->put($path, $data); return $success !== false && $this->unlock($key); }
/** * @param Filesystem $mount * @param string $file * @param string $contents * @param string $check * * @throws \Exception */ protected function _doFileTest($mount, $file, $contents, $check) { $mount->put($file, $contents); try { $this->assertTrue($contents == file_get_contents($check . DIRECTORY_SEPARATOR . $file)); @$mount->delete($file); } catch (\Exception $_ex) { @$mount->delete($file); throw $_ex; } }
/** * @return mixed */ public function doBackup() { $date = date('YmdHisO'); $dumpName = trim($this->options->getPath() . $date . '.sql', '/'); switch ($this->dumperOptions->getCompress()) { case Mysqldump::GZIP: $dumpName = $dumpName . '.gz'; break; case Mysqldump::BZIP2: $dumpName = $dumpName . '.bz2'; break; } $tmpFile = tempnam(sys_get_temp_dir(), 'bsb-flysystem-mysql-backup-'); $fileStream = fopen($tmpFile, 'rb'); try { if (false === $fileStream) { throw new \RuntimeException("A temp file could not be created"); } // start dump and backup $this->dumper->start($tmpFile); $this->filesystem->writeStream($dumpName, $fileStream); // write a latest file if ($this->options->getWriteLatest()) { $this->filesystem->put($this->options->getPath() . $this->options->getWriteLatest(), pathinfo($dumpName, PATHINFO_BASENAME)); } if ($this->options->getAutoPrune()) { $this->pruneStorage(); } } catch (\Exception $e) { throw new \RuntimeException($e->getMessage()); } finally { if (is_resource($fileStream)) { fclose($fileStream); } if (file_exists($tmpFile)) { unlink($tmpFile); } } return $dumpName; }
public function testReplaceExistsCopy() { $resourceDOSource = $this->getResourceDOMock(); $resourceDODest = $this->getResourceDOMock(); $resourceDODest->setVersion($resourceDOSource->getVersion() + 1); $contentExpected = 'New content'; $this->filesystem->put($resourceDOSource->getFilePath(), $contentExpected); $this->filesystem->put($resourceDODest->getFilePath(), 'Exist content'); $command = $this->getCommand($resourceDOSource, $resourceDODest); $result = $command(true); $this->assertEquals($resourceDODest, $result); $this->assertEquals($contentExpected, $this->filesystem->read($resourceDODest->getFilePath())); }
/** * @dataProvider testFindResourceDataProvider */ public function testFindResourceMock($namespace, $type, $variant, $version, $name, $nameAlternative, $author) { $content = 'just a test'; $resourceDO = $this->prepareResource($namespace, $type, $variant, $version, $name, $nameAlternative, $author); $uuid = $resourceDO->getUuid(); // SAVE CURRENT $filePath = $resourceDO->getFilePath(); $this->filesystem->put($filePath, $content); $this->assertTrue($this->filesystem->has($filePath)); // SAVE ANOTHER VERSION $resourceDOVersion = clone $resourceDO; $version2 = (string) ($version + 1); $resourceDOVersion->setVersion($version2); $filePath = $resourceDOVersion->getFilePath(); $this->filesystem->put($filePath, $content); $this->assertTrue($this->filesystem->has($filePath)); // SAVE ANOTHER VARIANT $resourceDOVariant = clone $resourceDO; $variant2 = $variant . '_second'; $resourceDOVariant->setVariant($variant2); $filePath = $resourceDOVariant->getFilePath(); $this->filesystem->put($filePath, $content); $this->assertTrue($this->filesystem->has($filePath)); // SAVE WRONG FILES $this->wrongFiles->create($resourceDO, $content); $modelBaseDir = substr(self::BASE_DIR, 1, 100); $shardVariant = substr($variant, 0, ResourceDOAbstract::SHARD_SLICE_LENGTH); $shardFilename = substr($uuid, 0, ResourceDOAbstract::SHARD_SLICE_LENGTH); $namespacePath = $namespace ? $namespace . '/' : ''; $model = [[ResourceDOAbstract::TOKEN_TYPE => $type, 'visibility' => 'public', 'path' => $modelBaseDir . '/' . $namespacePath . $type . '/' . $shardVariant . '/' . $variant . '/' . $version . '/' . $shardFilename . '/' . $uuid . '.' . $type, 'dirname' => $modelBaseDir . '/' . $namespacePath . $type . '/' . $shardVariant . '/' . $variant . '/' . $version . '/' . $shardFilename, 'basename' => $uuid . '.' . $type, 'extension' => $type, 'filename' => $uuid, 'directory_relative' => $type . '/' . $shardVariant . '/' . $variant . '/' . $version . '/' . $shardFilename, ResourceDOAbstract::TOKEN_SHARD_VARIANT => $shardVariant, ResourceDOAbstract::TOKEN_VARIANT => $variant, ResourceDOAbstract::TOKEN_VERSION => $version, ResourceDOAbstract::TOKEN_SHARD_FILENAME => $shardFilename], [ResourceDOAbstract::TOKEN_TYPE => $type, 'visibility' => 'public', 'path' => $modelBaseDir . '/' . $namespacePath . $type . '/' . $shardVariant . '/' . $variant . '/' . $version2 . '/' . $shardFilename . '/' . $uuid . '.' . $type, 'dirname' => $modelBaseDir . '/' . $namespacePath . $type . '/' . $shardVariant . '/' . $variant . '/' . $version2 . '/' . $shardFilename, 'basename' => $uuid . '.' . $type, 'extension' => $type, 'filename' => $uuid, 'directory_relative' => $type . '/' . $shardVariant . '/' . $variant . '/' . $version2 . '/' . $shardFilename, ResourceDOAbstract::TOKEN_SHARD_VARIANT => $shardVariant, ResourceDOAbstract::TOKEN_VARIANT => $variant, ResourceDOAbstract::TOKEN_VERSION => $version2, ResourceDOAbstract::TOKEN_SHARD_FILENAME => $shardFilename], [ResourceDOAbstract::TOKEN_TYPE => $type, 'visibility' => 'public', 'path' => $modelBaseDir . '/' . $namespacePath . $type . '/' . $shardVariant . '/' . $variant2 . '/' . $version . '/' . $shardFilename . '/' . $uuid . '.' . $type, 'dirname' => $modelBaseDir . '/' . $namespacePath . $type . '/' . $shardVariant . '/' . $variant2 . '/' . $version . '/' . $shardFilename, 'basename' => $uuid . '.' . $type, 'extension' => $type, 'filename' => $uuid, 'directory_relative' => $type . '/' . $shardVariant . '/' . $variant2 . '/' . $version . '/' . $shardFilename, ResourceDOAbstract::TOKEN_SHARD_VARIANT => $shardVariant, ResourceDOAbstract::TOKEN_VARIANT => $variant2, ResourceDOAbstract::TOKEN_VERSION => $version, ResourceDOAbstract::TOKEN_SHARD_FILENAME => $shardFilename]]; $command = $this->getCommand($resourceDO); $result = $command(); foreach ($result as &$item) { $this->assertArrayHasKey('size', $item); $this->assertArrayHasKey('timestamp', $item); unset($item['size'], $item['timestamp']); } $this->assertEquals($model, $result); }
public function testDestroyEqualResourceWithDifferentContent() { $resourceDOOrigin = $this->getResourceDOMock(); $resourceDOSuspect = $this->getResourceDOMock(); $resourceDOSuspect->setVersion($resourceDOOrigin->getVersion() + 1); $this->filesystem->put($resourceDOOrigin->getFilePath(), 'Same content'); $this->filesystem->put($resourceDOSuspect->getFilePath(), 'Different content'); $command = $this->getCommand($resourceDOOrigin, $resourceDOSuspect); $result = $command(); $this->assertEquals($resourceDOOrigin, $result); $this->assertTrue($this->filesystem->has($resourceDOOrigin->getFilePath())); $this->assertTrue($this->filesystem->has($resourceDOSuspect->getFilePath())); }
/** * @param array $files * @param string $commitId * @return array */ public function downloadFiles($files, $commitId) { $downloadedFiles = []; foreach ($files as $file) { if (!preg_match('/.*\\.php$/', $file['filename']) || $file['status'] === "removed") { continue; } $fileContent = $this->client->api('repo')->contents()->download($this->owner, $this->repository, $file['filename'], $commitId); $file = sys_get_temp_dir() . "/" . $file['filename']; $this->filesystem->put($file, $fileContent); $downloadedFiles[] = $file; } return $downloadedFiles; }
protected function execute(InputInterface $input, OutputInterface $output) { $baseDir = dirname(dirname(__FILE__)); $loader = new \Twig_Loader_Filesystem($baseDir . '/../app/Resources/templates/'); $twig = new \Twig_Environment($loader); $baseDirAdapter = new Local($baseDir . '/../'); $genericFS = new Filesystem($baseDirAdapter); $sectionRepository = new SectionRepository($genericFS); $pres = new PresentationRepository($genericFS, $sectionRepository); $adapter = new Local($baseDir . '/../web'); $filesystem = new Filesystem($adapter); $filesystem->put('index.html', $twig->render('basic.html.twig', ['pres' => $pres->get()])); $output->writeln('Success'); }
function it_archives_unvalid_items(InvalidItemsCollector $collector, CsvWriter $writer, JobExecution $jobExecution, JobInstance $jobInstance, Filesystem $filesystem) { $collector->getInvalidItems()->willReturn(['items']); $jobExecution->getId()->willReturn('id'); $jobExecution->getJobInstance()->willReturn($jobInstance); $jobInstance->getType()->willReturn('type'); $jobInstance->getAlias()->willReturn('alias'); $filesystem->put('type/alias/id/invalid/invalid_items.csv', '')->shouldBeCalled(); $writer->setFilePath('/tmp/archivist/type/alias/id/invalid/invalid_items.csv')->shouldBeCalled(); $writer->initialize()->shouldBeCalled(); $writer->write(['items'])->shouldBeCalled(); $writer->flush()->shouldBeCalled(); $this->archive($jobExecution); }
/** * build the languages configuration file from db. * * @return boolean return true on success, false on failed. */ private function buildConfigFile() { $qb = $this->Conn->createQueryBuilder(); $stmt = $qb->select('*')->from('`' . $this->Db->getTableName('languages') . '`')->where('`language_enable` = :langenable')->addOrderBy('`language_order`', 'ASC')->setParameter('langenable', 1)->execute(); $result = $stmt->fetchAll(); unset($qb); $output = '<?php' . "\n"; $output .= '/**' . "\n"; $output .= ' * Languages generated from db. (prefix_languages table)' . "\n"; $output .= ' * Do not edit this file, it will be overwritten when re-generate the languages.' . "\n"; $output .= ' */' . "\n"; $output .= "\n"; $output .= 'return [' . "\n"; $output .= ' \'language_fallback\' => [' . "\n"; $output .= ' \'en-US\' => [' . "\n"; $output .= ' \'language_locale\' => \'en-US.UTF-8, en-US, en\',' . "\n"; $output .= ' \'language_locale_uri\' => \'en-US\',' . "\n"; $output .= ' \'language_name\' => \'English\',' . "\n"; $output .= ' ],' . "\n"; $output .= ' ],' . "\n"; $output .= ' \'languages\' => [' . "\n"; if (is_array($result)) { foreach ($result as $row) { $output .= ' \'' . $row->language_locale_uri . '\' => [' . "\n"; $output .= ' \'language_locale\' => \'' . $row->language_locale . '\',' . "\n"; $output .= ' \'language_locale_uri\' => \'' . $row->language_locale_uri . '\',' . "\n"; $output .= ' \'language_name\' => \'' . $row->language_name . '\',' . "\n"; $output .= ' \'language_default\' => ' . ($row->language_default == '1' ? 'true' : 'false') . ',' . "\n"; $output .= ' \'language_enable\' => ' . ($row->language_enable == '1' ? 'true' : 'false') . ',' . "\n"; $output .= ' ],' . "\n"; } // endforeach; unset($row); } else { \System\Libraries\Log::write('LanguagesDb', 'warning', 'There is no language in the database!'); } $output .= ' ],' . "\n"; $output .= '];' . "\n"; // end return [ (array) ]; // write these languages config file. $adapter = new Local($this->language_config_folder); $filesystem = new Filesystem($adapter); unset($adapter); $filesystem->put($this->language_db_file, $output); unset($filesystem, $output); $stmt->closeCursor(); unset($result, $stmt); return true; }
/** * Salva o bloco em um arquivo TXT * @param string $filename * @return boolean */ public function save($filename = '') { if ($filename == '') { $aG = explode("\\", $this->group); $aG = array_slice($aG, -1); $filename = strtolower($aG[0]) . '.txt'; } $path = realpath(dirname(dirname(dirname(dirname(__FILE__))))); $adapter = new Local($path, LOCK_EX, Local::DISALLOW_LINKS, ['file' => ['public' => 0744, 'private' => 0700], 'dir' => ['public' => 0755, 'private' => 0700]]); $filesystem = new Filesystem($adapter); //somente são aceitos caracteres ASCII ===> utf8_decode() //$filesystem->createDir('path/to/nested/directory'); $filesystem->put($filename, implode("\n", $this->bloco), ['visibility' => 'public']); return true; }
protected function _createFileOnDir(Local $adapter, $outFile) { $filesystem = new Filesystem($adapter); $dir = pathinfo($adapter->getPathPrefix() . $outFile, PATHINFO_DIRNAME) . '/'; if (!is_dir($dir)) { $this->logger->info('Creo directory mancante: ' . $dir); mkdir($dir, 0700, true); } if ($filesystem->has($outFile)) { $filesystem->put($outFile, (string) $this->currentFile); } else { $filesystem->write($outFile, (string) $this->currentFile); } return $outFile; //$io->text('Outfile: '.$outFile); }