0

通常 KO3 是如何工作的: 1. 从“系统”获取文件 2. 用每个使用的“模块”替换一些 3. 最后 - 用“应用程序”替换

我必须做什么才能在这些链中再添加一个文件夹?如何扩展这个级联?例如我想在这里加载类:

  1. “/系统/”
  2. “/模块/”
  3. /之前的插件/
  4. /插件/
  5. /申请前/
  6. “/应用/”

我希望“插件”具有与“模块”相同的功能我可以将每个插件初始化为模块,方法是:

    Kohana::plugins(array(
         'plugin_1'       => PLUGPATH.'plugin_1',       // Plugin 1
         'plugin_2'       => PLUGPATH.'plugin_2',       // Plugin 2
         // and so on
        ));

我必须做些什么来创建一个看起来像应用程序的文件夹,它会在应用程序启动之前自动加载?(“ /before-application/ ”和“ /before-plugins/ ”)

我知道必须从 SYSPATH 复制到 application/classes/Kohana/Core.php 并做一些事情。但是什么?请帮帮我!

4

1 回答 1

2

你其实弄错了。Kohana::auto_load()用于Kohana::find_file('classes', $file)您的课程。这里适用的部分是

foreach (Kohana::$_paths as $dir)
{
    if (is_file($dir.$path))
    {
        // A path has been found
        $found = $dir.$path;

        // Stop searching
        break;
    }
}

因为Kohana::$_paths

array(11) (
    0 => string(32) "/var/www/guides/3.3/application/"
    1 => string(33) "/var/www/guides/3.3/modules/.../"
    9 => string(38) "/var/www/guides/3.3/modules/.../"
    10 => string(27) "/var/www/guides/3.3/system/"
)

将首先搜索应用程序。如果在那里没有找到任何东西,那么 Kohana 将在模块中查找。并且只有在没有找到现有类的情况下,才会查看系统目录。

现在通过编辑Kohana::$_paths,您可以轻松控制 Kohana 用于自动加载的顺序。

于 2014-11-22T20:26:37.137 回答