/**
  * Process a php target file to append PHP syntax-sensitive content 
  * from multiple template sources.
  *
  * @param  string $file, a php file to modify
  * @param  array  $templates list of key (property name), value (template file)
  * @param  string $data used to replace placeholders inside all template files
  * @param Boolean $front, set location to the front of the array 
  */
 protected function processFile($file, $templates, $data, $front = false)
 {
     $content = $this->files->get($file);
     $phpParser = new GenericPhpParser($content, $data, $this->parser);
     foreach ($templates as $property => $template) {
         $phpParser->parse($property, $template, $front);
     }
     $content = $phpParser->prettyPrint();
     if (!is_null($content)) {
         $this->files->put($file, $content);
     }
 }
 /**
  * Write the contents of a file
  *
  * @param  string  $path
  * @param  string  $contents
  * @param  bool  $lock
  * @return int
  */
 public function put($path, $contents, $avoid = false, $lock = false)
 {
     return $this->files->put($path, $contents, $avoid, $lock);
 }
예제 #3
0
 private function exportToJson($sJsonFilePath, array $aData, $bCompress = false)
 {
     $sNewJsonContent = Conversion::getJsonFromArray($aData, $bCompress);
     if (Filesystem::put($sJsonFilePath, $sNewJsonContent) !== false) {
         return Filesystem::name($sJsonFilePath) . '.' . Filesystem::extension($sJsonFilePath);
     } else {
         throw new FileNotCreatedException('File : ' . $sJsonFilePath);
     }
 }
예제 #4
0
 public function testFailingPut()
 {
     $mock = \Mockery::mock('League\\Flysystem\\Adapter\\AbstractAdapter');
     $cachemock = \Mockery::mock('League\\Flysystem\\Cache\\AbstractCache');
     $cachemock->shouldReceive('load')->andReturn(array());
     $cachemock->shouldReceive('has')->andReturn(false);
     $cachemock->shouldReceive('isComplete')->andReturn(false);
     $cachemock->shouldReceive('updateObject')->andReturn(false);
     $mock->shouldReceive('__toString')->andReturn('Flysystem\\Adapter\\AbstractAdapter');
     $cachemock->shouldReceive('__toString')->andReturn('Flysystem\\Cache\\AbstractCache');
     $filesystem = new Filesystem($mock, $cachemock);
     $mock->shouldReceive('write')->andReturn(false);
     $mock->shouldReceive('update')->andReturn(false);
     $mock->shouldReceive('has')->with('dummy.txt')->andReturn(true);
     $this->assertFalse($filesystem->put('dummy.txt', 'content'));
     $mock->shouldReceive('has')->with('dummy2.txt')->andReturn(false);
     $this->assertFalse($filesystem->put('dummy2.txt', 'content'));
 }