简体   繁体   English

如何确保每个控制器都能看到 DboSource?

[英]How can I make sure that every controller sees DboSource?

There were issues that some controllers are using DboSource methods and I added the一些控制器使用DboSource方法存在问题,我添加了

App::uses('DboSource', 'Model/DboSource');

line to the class file of some base controllers from which other controllers are inherited.行到一些基本控制器的类文件,其他控制器从这些基本控制器继承。 However, I wonder whether there is a way in Cake to make sure that a class is loaded by every controller.但是,我想知道 Cake 是否有办法确保每个控制器都加载一个类。 My current solution works, I just intend to improve it.我目前的解决方案有效,我只是打算改进它。 Is this possible?这可能吗? Thanks!谢谢!

您可以将其添加到您的app/Config/bootstrap.php文件中,它将在每个请求时加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何确保对CakePHP控制器/操作的jQuery自动完成调用中的路径正确解析? - How to I make sure the path in jQuery autocomplete call to CakePHP controller/action resolves correctly? 我如何在 cake php 3 中应用程序的每个网页中使用控制器的方法 - How can i use a controller's method in every web page of the application in cake php 3 在CakePHP中,如何有效地确保所有用户都已确认系统消息? - In CakePHP, how do I efficiently make sure all users have acknowledged system messages? 如何确保每个会话仅发送一次电子邮件? - How do I make sure email gets sent only one time per session? 如何检查人员 email 地址以确保他们拥有 paypal 帐户? - How do I check a persons email address to make sure they have a paypal account? cakephp-如何将控制器中的数据转发到另一个控制器? - cakephp - how can I forward data in the controller to another controller? CakePHP:如何在每个控制器中使用带模型的函数? - CakePHP: How to use a function with a model in every controller? 如何更改控制器输入的样式? 蛋糕PHP - How can i change the style of an input from controller ? CakePHP 如何在cakePHP中的控制器中设置paginator页面 - How can I set the paginator page from within the controller in cakePHP 如何为控制器的所有操作/视图设置相同的标题? - How can i set same title for all actions/views of a controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM