开发者

using a component in a plugin and calling method

开发者 https://www.devze.com 2023-03-27 11:02 出处:网络
I am new to cake php and I have a plugin folder in my application app/plugins in plugin folder I have model and vendors folder. (Notice I dont have any view or controller folder)

I am new to cake php and I have a plugin folder in my application

app/plugins

in plugin folder I have model and vendors folder. (Notice I dont have any view or controller folder)

app/plugins/model
app/plugins/vendors

I w开发者_运维百科anted to add a component to plugin folder so I added controllers folder to it and place my component file there.

app/plugins/controllers
app/plugins/controllers/myComp.php

The method in myComp.php is

class myCompComponent extends EmailComponent    {

    function hilpot() {

In my vendors/shells/tasks folder I have a file called my_test.php

In the file I have included the component like

var $components = array('myComp');

in the same file, i have a method that suppose to call the myComp method

function _Maikle()
    {

            $this->myComp->hilpot() = array(

 ...................
..................

And it fails at this point with the following error

PHP Fatal error:  Call to undefined method stdClass::hilpot() in C:\wamp\www\folder\app\plugins\vendors\shells\my_test.php on line 87

Any help will be appreciated thanks


your plugin structure seems to be incorrect

/app/plugins/plugin_name/controllers/... etc

you probably didnt read the cookbook at all. otherwise you would have notices this as well as that components are in a sub directory:

/app/plugins/plugin_name/controllers/components/...

also note that you should always include the pluginname:

var $components = array('PluginName.MyComp');

and m should be capitalized: MyComp

0

精彩评论

暂无评论...
验证码 换一张
取 消