0

我正在将 codeIgniter 与 smarty 集成为视图,我收到此致命错误:无法在第 83 行访问受保护CI_Output::$final_output/CodeIgniter_2.1.0/application/libraries/smarty_parser.php属性。

我在谷歌上搜索然后发现它是 protected $final_output; // in CodeIgniter_2.1.0/system/core/Output.php line no. 37

当我改为: public $final_output; // working fine

我担心的是更改 CodeIgniter 核心文件是否很好,或者将来会导致任何错误?

4

2 回答 2

2

Code Igniter, as other frameworks and libraries, should not be change manually, because you lost the posibility of doing updates to your system (If you update your system, public $final_output; will change to private $final_output; and you need to do the change again).

In this situation is only one change needed, but think that you change several more lines, will you remember all the changes to do it again?

My recomendation, open a issue in Code Igniter bug tracker https://github.com/EllisLab/CodeIgniter/issues comment your situation and ask for help. If despite all, you need to do the change, write a patch file containing the change and put it in the same folder of the original file with a descriptive name. In this manner you can apply the patch every time you update your system.

于 2012-10-13T15:03:14.073 回答
1

CodeIgniter 是开源的,因此如果您认为这是正确的做法,您可以根据需要对其进行修改。我一直在修改我的。将某些东西设为公共函数通常不会引起重大问题,但是您可以考虑单独保留现有的私有 final_output() 并在 Output.php 中创建一个新的公共函数,供 Smarty 访问。您可以将此作为核心的扩展。更多信息在这里

于 2012-10-13T15:03:57.430 回答