/**
  * Get the decoded contents from the main composer.json file
  * @return object
  */
 private function getComposerFile()
 {
     $composerFile = $this->cache->remember('app.version', 1440, function () {
         return $this->filesystem->get('composer.json');
     });
     return json_decode($composerFile);
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function readCss($uri)
 {
     $path = sprintf('%s/%s.css', $this->storage, urlencode($uri));
     if (!$this->files->exists($path)) {
         return sprintf('/* Critical-path CSS for URI [%s] not found at [%s]. ' . 'Check the config and run `php artisan criticalcss:make`. */', $uri, $path);
     }
     return $this->files->get($path);
 }
Esempio n. 3
0
 /**
  * Get the exact installed version for the specified package.
  *
  * @param string $packageName
  *
  * @return string mixed
  */
 public function getPackageInfo($packageName)
 {
     $composerLock = json_decode($this->finder->get('composer.lock'));
     foreach ($composerLock->packages as $package) {
         if ($package->name == $packageName) {
             return $package;
         }
     }
 }
Esempio n. 4
0
 /**
  * Get the hydrated models.
  *
  * @param  array  $files
  * @return \Illuminate\Support\Collection
  */
 protected function getModels(array $files)
 {
     $collection = new Collection();
     foreach ($files as $path) {
         if (strpos($path, 'build-') !== false) {
             $contents = $this->storage->get($path);
             $collection->push($this->createModel(['path' => $path]));
         }
     }
     return $collection;
 }
 /**
  * create filtered image
  *
  * @param string $hash
  * @param string $filename
  * @param string[]|string $filters
  * @return void
  */
 public function create($hash, $filename, $filters)
 {
     $filteredImages = [];
     $imageContent = $this->filesystem->get(config('image-service.path') . '/original/' . $hash . '/' . $filename);
     $image = $this->imageManager->make($imageContent);
     // if just one filter as string
     if (is_string($filters)) {
         $filters = [$filters];
     }
     foreach ($filters as $filterName) {
         $filterData = config('image-service.filters.' . $filterName);
         /** @var Filter $filter */
         $filter = app('image.filters.' . $filterData['type']);
         $filteredImage = $filter->process($image, isset($filterData['options']) ? $filterData['options'] : []);
         // cache if needed
         if (isset($filterData['cache']) && $filterData['cache'] === true) {
             $filterPath = config('image-service.path') . '/' . $filterName . '/' . $hash;
             $this->filesystem->makeDirectory($filterPath);
             $this->filesystem->put($filterPath . '/' . $filename, $filteredImage->encode(null, 100));
         }
         // save to return it
         $filteredImages[$filterName] = $filteredImage;
     }
     return $filteredImages;
 }
Esempio n. 6
0
 public function contribute(Filesystem $fs)
 {
     $markdown = $fs->get('providers/CONTRIBUTING.md');
     $markdown = preg_replace('/^.+\\n/', '', $markdown);
     $html = \Parsedown::instance()->parse($markdown);
     return view('contribute', compact('html'));
 }
 /**
  * Test if screenshot exists
  * @return stream
  */
 public function doesScreenshotExist()
 {
     try {
         return $this->storage->get($this->getFullStoragePath());
     } catch (FileNotFoundException $e) {
         throw new ScreenshotNotExistsException("Screenshot can't be generated for URL {$this->getRequestUrl()}.", 400);
     }
 }
Esempio n. 8
0
 public function getFiles(Filesystem $filesystem)
 {
     $file = $filesystem->get('test.txt');
     return $file;
     //$file = $filesystem->append('test.txt', 'how are you');
     //return $filesystem->get('test.txt');
     //\File::get('test.txt');
 }
Esempio n. 9
0
 /**
  * Build thumbnails for each files that is image type.
  *
  * @param \Illuminate\Support\Collection $files
  * @return array
  */
 protected function buildThumbnails($files)
 {
     $thumbnails = [];
     foreach ($files as $file) {
         if (file_can_have_thumbnail($file)) {
             $thumbnails[$file] = (string) $this->image->make($this->storage->get($file))->resize(20, 20)->encode('data-url');
         }
     }
     return $thumbnails;
 }
Esempio n. 10
0
 /**
  * @param  \Codex\Codex\Project                   $project
  * @param  Filesystem                             $files
  * @param  \Illuminate\Contracts\Cache\Repository $cache
  * @param  string                                 $path
  * @return void
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function __construct(Project $project, Filesystem $files, Cache $cache, $path)
 {
     $this->cache = $cache;
     $this->files = $files;
     $this->path = $path;
     $this->project = $project;
     Factory::run('menu:ready', [$this]);
     $this->raw = $files->get($path);
     $this->menu = $this->parse($this->raw);
     Factory::run('menu:done', [$this]);
 }
Esempio n. 11
0
 protected function loadConfig(Filesystem $fs, $scraperDir)
 {
     $scraperConfigFile = $scraperDir . '/scraper.yml';
     if (!$fs->exists($scraperConfigFile)) {
         return null;
     }
     $configString = $fs->get($scraperConfigFile);
     $parser = new Parser();
     $config = $parser->parse($configString);
     if (!is_array($config) || !count($config) >= 2) {
         return null;
     }
     return $config;
 }
 /**
  * @param string $entry
  */
 private function saveOldImportFile(string $entry)
 {
     $content = '';
     try {
         $content = Crypt::decrypt($this->uploadDisk->get($entry));
     } catch (DecryptException $e) {
         Log::error('Could not decrypt old CSV import file ' . $entry . '. Skipped because ' . $e->getMessage());
     }
     if (strlen($content) > 0) {
         // add to export disk.
         $date = $this->getOriginalUploadDate($entry);
         $file = $this->job->key . '-Old import dated ' . $date . '.csv';
         $this->exportDisk->put($file, $content);
         $this->getFiles()->push($file);
     }
 }
 /**
  * @param Attachment $attachment
  *
  * @return bool
  */
 private function exportAttachment(Attachment $attachment) : bool
 {
     $file = $attachment->fileName();
     if ($this->uploadDisk->exists($file)) {
         try {
             $decrypted = Crypt::decrypt($this->uploadDisk->get($file));
             $exportFile = $this->exportFileName($attachment);
             $this->exportDisk->put($exportFile, $decrypted);
             $this->getFiles()->push($exportFile);
             // explain:
             $this->explain($attachment);
         } catch (DecryptException $e) {
             Log::error('Catchable error: could not decrypt attachment #' . $attachment->id . ' because: ' . $e->getMessage());
         }
     }
     return true;
 }
Esempio n. 14
0
 /**
  * @param $fs Filesystem
  * @param $scrapers Collection
  **/
 protected function processChunk(Filesystem $fs, Collection $scrapers)
 {
     $lastJob = 0;
     if ($fs->exists('lastScraperRun')) {
         $lastJob = $fs->get('lastScraperRun');
     }
     $scrapers->slice($lastJob, self::JOBS_PER_CALL);
     $this->scheduleScrapers($scrapers);
     $nextJob = 0;
     if ($lastJob + self::JOBS_PER_CALL > $scrapers->count()) {
         $nextJob = $lastJob + self::JOBS_PER_CALL;
     }
     $fs->put('lastScraperRun', $nextJob);
 }
Esempio n. 15
0
 /**
  * Get the contents of a file.
  *
  * @param  string $path
  * @return string
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function get($path)
 {
     $path = $this->getPathPrefix($path);
     return $this->drive->get($path);
 }
Esempio n. 16
0
 /**
  * Read Content File
  *
  * @param string $filename Path File
  *
  * @return bool
  */
 public function readFile($filename)
 {
     return $this->storage->get($filename);
 }
 /**
  * @param $path
  * @return string
  */
 public function get($path)
 {
     return $this->storage->get($path);
 }
Esempio n. 18
0
 /**
  * @return string
  */
 public function getStoredPhoto()
 {
     return $this->cloud->get($this->path);
 }
Esempio n. 19
0
 /**
  * Get a single file content.
  *
  * @param $file
  * @return string
  */
 private function getContent($file)
 {
     return $this->filesystem->get($file);
 }