Compiler.php

tony0087發表於2021-09-09

 

namespace IlluminateViewCompilers;

 

use IlluminateFilesystemFilesystem;

 

abstract class Compiler

{// a abstract class

   

    protected $files;//The filesystem instance.

 

   

    protected $cachePath;//Get the cache path for the compiled views.

 

   

    public function __construct(Filesystem $files, $cachePath)

    {

        $this->files = $files;

        $this->cachePath = $cachePath;

    }//_construct

   // files

   // set some construct

 

   

    public function getCompiledPath($path)

    {

        return $this->cachePath.'/'.sha1($path).'.php';

    }// get The Compiled Path

 

   

    public function isExpired($path)

    {// check is expired

        $compiled = $this->getCompiledPath($path);// compiled

 

        // If the compiled file doesn't exist we will indicate that the view is expired

        // so that it can be re-compiled. Else, we will verify the last modification

        // of the views is less than the modification times of the compiled views.

        if (! $this->cachePath || ! $this->files->exists($compiled)) {

            return true;

        }// true

 

        $lastModified = $this->files->lastModified($path);

// last Modified

        return $lastModified >= $this->files->lastModified($compiled);

    }// has this result

}

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/1747/viewspace-2801689/,如需轉載,請註明出處,否則將追究法律責任。