File::get PHP Méthode

get() public static méthode

Get the contents of a file.
public static get ( string $path, boolean $lock = false ) : string
$path string
$lock boolean
Résultat string
        public static function get($path, $lock = false)
        {
            return \Illuminate\Filesystem\Filesystem::get($path, $lock);
        }

Usage Example

 public function run($request)
 {
     $number = $request->getVar('number');
     if (!$number) {
         $number = 50;
     }
     if (!$request->getVar('run')) {
         exit("Please supply the run= parameter, and a 'number' parameter (defaults to 50 if not set)");
     }
     $files = File::get()->filter(['FileSize' => 0, 'ClassName:not' => 'Folder', 'CDNFile:PartialMatch' => ':||'])->limit($number);
     echo "Processing " . $number . " files<br/>\n";
     flush();
     foreach ($files as $file) {
         echo "Downloading {$file->ClassName} #{$file->ID} " . $file->Title . " ... ";
         flush();
         $file->ensureLocalFile();
         if ($file->localFileExists()) {
             $file->FileSize = filesize($file->getFullPath());
             echo "filesize {$file->FileSize} ... ";
             flush();
             if ($file instanceof CdnImage) {
                 $dim = $file->getDimensions();
                 echo "dimensions {$dim} ... ";
                 flush();
             }
             $file->write();
             unlink($file->getFullPath());
         } else {
             echo " cannot download {$file->Title} - {$file->CDNFile} <br/>\n";
         }
         echo "<br/>\n";
     }
 }
All Usage Examples Of File::get