Pimcore\File::isIncludeable PHP Метод

isIncludeable() публичный статический Метод

public static isIncludeable ( $filename ) : boolean
$filename
Результат boolean
    public static function isIncludeable($filename)
    {
        if (array_key_exists($filename, self::$isIncludeableCache)) {
            return self::$isIncludeableCache[$filename];
        }
        $isIncludeAble = false;
        // use stream_resolve_include_path if PHP is >= 5.3.2 because the performance is better
        if (function_exists("stream_resolve_include_path")) {
            if ($include = stream_resolve_include_path($filename)) {
                if (@is_readable($include)) {
                    $isIncludeAble = true;
                }
            }
        } else {
            // this is the fallback for PHP < 5.3.2
            $include_paths = explode(PATH_SEPARATOR, get_include_path());
            foreach ($include_paths as $path) {
                $include = $path . DIRECTORY_SEPARATOR . $filename;
                if (@is_file($include) && @is_readable($include)) {
                    $isIncludeAble = true;
                    break;
                }
            }
        }
        // add to store
        self::$isIncludeableCache[$filename] = $isIncludeAble;
        return $isIncludeAble;
    }

Usage Example

Пример #1
0
 /**
  * @param $className
  */
 protected function determineResourceClass($className)
 {
     $filesToInclude = [];
     $filePath = str_replace(["_", "\\"], "/", $className) . ".php";
     $filesToInclude[] = preg_replace("@^Pimcore/Model/@", "", $filePath);
     $filesToInclude[] = $filePath;
     foreach ($filesToInclude as $fileToInclude) {
         if ($fileToInclude == "Dao.php" || $fileToInclude == "Resource.php") {
             return;
         }
         if (File::isIncludeable($fileToInclude)) {
             include_once $fileToInclude;
             if (Tool::classExists($className)) {
                 return $className;
             }
         }
     }
     return;
 }
All Usage Examples Of Pimcore\File::isIncludeable