Thursday, February 26, 2015

Re: AppModel Subclass Constructor not called

José:

Furthermore, adding the following line instead of the previous one mentioned also alleviates the error. (FYI... this is from inside a Component where it stores has access to the controller via a member variable $ctl)

        $this->ctl->LocationPackage->getDataSource();

I appears that executing a find operation before to accessing the model in some other way uses some instance of the Model that is not constructed from the explicit class file.


Sincerely,

Charles

On Thu, Feb 26, 2015 at 9:41 AM, Charles Beasley <carmelchas@gmail.com> wrote:

José:

The database table name is 'location_packages', the file is located in "app/Model/LocationPackage.php", and the class is declared as follows.

class LocationPackage extends AppModel {

...

}


Does all this appear correct to you? CakePHP 2.4.2

Sincerely,

Charles A Beasley



On Thu, Feb 26, 2015 at 3:15 AM, José Lorenzo <jose.zap@gmail.com> wrote:
That means your class is not being loaded, check you wrote the right class name, and that it was placed in the right folder with the correct file name.

If your model is in a plugin, make sure it was loaded using the plugin notation.


On Thursday, February 26, 2015 at 9:06:57 AM UTC+1, Charles Beasley wrote:

I have a model that extends AppModel and overrides the constructor, but the constructor never gets called... instead only the AppModel constructor is called.  

As a result, the belongTo and other associations defined in the class are empty.  However, if I add the following LINE before calling "find", the Model has the defined belongsTo associations and works without error.

 if ( empty($this->ctl->LocationPackage->belongsTo) ) die('LocationPackage Model is corrupted');

Does anyone have any suggestions as to why the above LINE causes the Model to be constructed from the Subclass rather than only call the AppModel constructor?

Thanks in advance.


Sincerely,

Charles

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: