get_file_contents() public static méthode

Get the content of the given file
public static get_file_contents ( string $filename ) : mixed | string
$filename string
Résultat mixed | string
 /**
  * Parse a sass file or Sass source code and
  * returns the document tree that can then be rendered.
  * The file will be searched for in the directories specified by the
  * load_paths option.
  * @param string name of source file or Sass source
  * @return SassRootNode Root node of document tree
  */
 public function parse($source, $isFile = true)
 {
     # Richard Lyon - 2011-10-25 - ignore unfound files
     # Richard Lyon - 2011-10-25 - add multiple files to load functions
     if (!$source) {
         return $this->toTree($source);
     }
     if (is_array($source)) {
         $return = null;
         foreach ($source as $key => $value) {
             if (is_numeric($key)) {
                 $code = $value;
                 $type = true;
             } else {
                 $code = $key;
                 $type = $value;
             }
             if ($return === null) {
                 $return = $this->parse($code, $type);
             } else {
                 $newNode = $this->parse($code, $type);
                 foreach ($newNode->children as $children) {
                     array_push($return->children, $children);
                 }
             }
         }
         return $return;
     }
     if ($isFile && ($files = SassFile::get_file($source, $this))) {
         $files_source = '';
         foreach ($files as $file) {
             $this->filename = $file;
             $this->syntax = substr(strrchr($file, '.'), 1);
             if ($this->syntax == SassFile::CSS) {
                 $this->property_syntax = "css";
             } elseif (!$this->property_syntax && $this->syntax == SassFile::SCSS) {
                 $this->property_syntax = "scss";
             }
             if ($this->syntax !== SassFile::SASS && $this->syntax !== SassFile::SCSS && $this->syntax !== SassFile::CSS) {
                 if ($this->debug) {
                     throw new SassException('Invalid {what}', array('{what}' => 'syntax option'));
                 }
                 return FALSE;
             }
             $files_source .= SassFile::get_file_contents($this->filename, $this);
         }
         return $this->toTree($files_source);
     } else {
         return $this->toTree($source);
     }
 }
Exemple #2
0
 /**
  * Parse a sass file or Sass source code and
  * returns the document tree that can then be rendered.
  * The file will be searched for in the directories specified by the
  * load_paths option.
  * @param string name of source file or Sass source
  * @return SassRootNode Root node of document tree
  */
 public function parse($source, $isFile = true)
 {
     # Richard Lyon - 2011-10-25 - ignore unfound files
     # Richard Lyon - 2011-10-25 - add multiple files to load functions
     if (!$source) {
         return $this->toTree($source);
     }
     if (is_array($source)) {
         $return = array();
         foreach ($source as $source_file) {
             $return = array_merge($return, $this->parse($source_file, TRUE));
         }
         return $return;
     }
     if ($isFile && ($files = SassFile::get_file($source, $this))) {
         $files_source = '';
         foreach ($files as $file) {
             $this->filename = $file;
             $this->syntax = substr(strrchr($file, '.'), 1);
             if ($this->syntax == SassFile::CSS) {
                 $this->property_syntax = "css";
             } elseif (!$this->property_syntax && $this->syntax == SassFile::SCSS) {
                 $this->property_syntax = "scss";
             }
             if ($this->syntax !== SassFile::SASS && $this->syntax !== SassFile::SCSS && $this->syntax !== SassFile::CSS) {
                 if ($this->debug) {
                     throw new SassException('Invalid {what}', array('{what}' => 'syntax option'));
                 }
                 return FALSE;
             }
             $files_source .= SassFile::get_file_contents($this->filename, $this);
         }
         return $this->toTree($files_source);
     } else {
         return $this->toTree($source);
     }
 }