/**
  * 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);
     }
 }
 public function create(array $data)
 {
     try {
         $this->validator->with($data)->passesOrFail(ValidatorInterface::RULE_CREATE);
         $projectFile = $this->repository->skipPresenter()->create($data);
         $this->storage->put($projectFile->getFileName(), $this->filesystem->get($data['file']));
         return ['success' => true];
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag(), "messageDev" => 'ValidatorException'];
     } catch (\Exception $e) {
         return ["error" => true, "message" => 'Falha ao gravar registro.', "messageDev" => $e->getMessage()];
     }
 }
Beispiel #3
0
 protected function extendLexicon(array &$aLexicon)
 {
     $sPatchFile = Config::get('path.real.root') . Config::get('path.relative.root_to_app') . Config::get('path.relative.app_to_data') . Config::get('jsreal.lexicon.simple_nlg.extension.' . $this->sLanguage);
     $sJsonExtension = Filesystem::get($sPatchFile);
     $aExtension = Conversion::getArrayFromJson($sJsonExtension);
     $aLexicon = array_merge_recursive($aLexicon, $aExtension);
 }
 protected static function newTempDir()
 {
     $tmp['tok'] = getUser() . time() . rand(5, 20);
     $tmp['dir'] = addslash(self::$config['tempdir']) . '.rutorrent/.fman/' . $tmp['tok'] . '/';
     Filesystem::get()->mkdir($tmp['dir'], true, 777);
     return $tmp;
 }
 /**
  * Get a form template by name
  *
  * @param  string $type
  * @return string
  */
 protected function getTemplate($type = 'list')
 {
     return $this->file->get(static::$templatePath . "/{$type}.txt");
 }
Beispiel #6
0
 protected function applyLexiconPatchToTestVerb(array &$aTestConjugatedVerb)
 {
     $aTenseList = array('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'ps1', 'ps2', 'ps3', 'ps4', 'ps5', 'ps6', 's1', 's2', 's3', 's4', 's5', 's6', 'ip2', 'ip4', 'ip5', 'pr', 'pp');
     $sPatchFile = Config::get('path.real.root') . Config::get('path.relative.root_to_app') . Config::get('path.relative.app_to_data') . Config::get('jsreal.lexicon.simple_nlg.patch.' . $this->sLanguage);
     $sJsonPatch = Filesystem::get($sPatchFile);
     $aPatch = Conversion::getArrayFromJson($sJsonPatch);
     foreach ($aPatch as $sUnit => $aInfo) {
         if (isset($aInfo['V'])) {
             foreach ($aInfo['V'] as $sTenseAndPerson => $sConjugatedVerb) {
                 if (Arr::in($aTenseList, $sTenseAndPerson)) {
                     $aTestConjugatedVerb[$sUnit][$sTenseAndPerson] = $sConjugatedVerb;
                 }
             }
         }
     }
 }
Beispiel #7
0
 public function __construct($sFileRealPath, $sStrStart, $sStrEnd)
 {
     $sFullContent = Filesystem::get($sFileRealPath);
     $this->sSelectedContent = Str::getStringBetween($sFullContent, $sStrStart, $sStrEnd);
 }
Beispiel #8
0
 public function testCopyFails()
 {
     $adapter = $this->getMock('League\\Flysystem\\AdapterInterface');
     $adapter->expects($this->exactly(2))->method('has')->withConsecutive(['file.txt'], ['files/copied.txt'])->willReturnOnConsecutiveCalls(true, false);
     $adapter->expects($this->once())->method('copy')->with('file.txt', 'files/copied.txt')->willReturn(false);
     $filesystem = new Filesystem($adapter);
     /** @var File $file */
     $file = $filesystem->get('file.txt', new File());
     $result = $file->copy('files/copied.txt');
     $this->assertFalse($result);
 }