栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

FileLoader.php

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

FileLoader.php

 

namespace IlluminateTranslation;

 

use IlluminateFilesystemFilesystem;

 

class FileLoader implements LoaderInterface

{// FileLoader implements Loader Interface

   

    protected $files;//The filesystem instance.

 

   

    protected $path;//The default path for the loader.

 

   

    protected $hints = [];// All of the namespace hints.

 

   

    public function __construct(Filesystem $files, $path)

    {

        $this->path = $path;// path

        $this->files = $files;// files

    }//Create a new file loader instance.

 

   

    public function load($locale, $group, $namespace = null)

    {

        if (is_null($namespace) || $namespace == '*') {

            return $this->loadPath($this->path, $locale, $group);// two type,one is loadPath

        }//locale group and namespace

 

        return $this->loadNamespaced($locale, $group, $namespace);// Load Namespace

    }//Load the messages for the given locale.

 

   

    protected function loadNamespaced($locale, $group, $namespace)

    {//Load a namespaced translation group

        if (isset($this->hints[$namespace])) {// if it is set

            $lines = $this->loadPath($this->hints[$namespace], $locale, $group);//get this line

 

            return $this->loadNamespaceOverrides($lines, $locale, $group, $namespace);// return a wrap function

        }

 

        return [];//default null

    }

 

   

    protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace)

    {//another load space

        $file = "{$this->path}/vendor/{$namespace}/{$locale}/{$group}.php";//get this file

 

        if ($this->files->exists($file)) {// if it is exists

            return array_replace_recursive($lines, $this->files->getRequire($file));

        }// return this thing

 

        return $lines;// return line

    }

 

   

    protected function loadPath($path, $locale, $group)

    {

        if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {

            return $this->files->getRequire($full);

        }// like include file by path ,the full is the full path

 

        return [];// null

    }//load a locale from a given path

 

   

    public function addNamespace($namespace, $hint)

    {

        $this->hints[$namespace] = $hint;

    }// addNamespace

   //Add a new namespace to the loader

}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/229788.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号