控制器如何在插件中调用模型? (cakephp 2.x(2.6)) (app -> plugin -> PluginName -> Controller)
how can controller call model in plugin? (cakephp 2.x(2.6)) (app -> plugin -> PluginName -> Controller)
我想在插件中调用模型,但我想在插件中调用此控制器。
-> 应用程序 -> 插件 -> 管理 -> 模型 -> exampleModel.php
-> app -> Plugin -> Admin -> Contoller(调用模型)
我试过了
$this->loadModel("ModelName");
或
$this->loadModel("PluginName.ModelName");
返回结果 app -> model -> exampleModel.php
如何称呼它?
从 app -> model -> exampleModel.php
和 Plugin -> Admin -> Model -> exampleModel.php
看来,您在这两个目录中有两个相同的 类,但不支持,恐怕:
Due to PHP lacking namespaces in older versions you cannot have the same class, or same filename, in your plugins. Even if it is two different plugins. So use unique classes and filenames, possible prefixing the class and filename with the plugin name.
来源:http://book.cakephp.org/2.0/en/plugins/how-to-create-plugins.html
写在bootstrap.php
App::uses('ClassRegistry', 'Utility');
$Setting = ClassRegistry::init('Configuration');
我想在插件中调用模型,但我想在插件中调用此控制器。
-> 应用程序 -> 插件 -> 管理 -> 模型 -> exampleModel.php
-> app -> Plugin -> Admin -> Contoller(调用模型)
我试过了
$this->loadModel("ModelName");
或
$this->loadModel("PluginName.ModelName");
返回结果 app -> model -> exampleModel.php
如何称呼它?
从 app -> model -> exampleModel.php
和 Plugin -> Admin -> Model -> exampleModel.php
看来,您在这两个目录中有两个相同的 类,但不支持,恐怕:
Due to PHP lacking namespaces in older versions you cannot have the same class, or same filename, in your plugins. Even if it is two different plugins. So use unique classes and filenames, possible prefixing the class and filename with the plugin name.
来源:http://book.cakephp.org/2.0/en/plugins/how-to-create-plugins.html
写在bootstrap.php
App::uses('ClassRegistry', 'Utility');
$Setting = ClassRegistry::init('Configuration');