I want some advice/guidance
I am trying to use inheritance with my models and am running into a few
problems.
I have workarounds, but I keep thinking there must be a better way.
First my goal -
I have a base class called "Context" with the children Users and Groups
all files are in my app/models directory
here are the snippets:
contexts.php:
abstract class Context extends AppModel {....}
groups.php
class Group extends Context {...}
users.php
class User extends Context {...}
Problems:
Now first, in Windows this works just fine since basics.php
loadModels() runs through the directory in alphabetical order and loads
Context before user or group. Once you move this over to Unix (Redhat)
you get a fatal error as it loads in reverse alphabetical with
users.php first.
Workaround
I tried putting loadModel('Context') at the top up users.php and
groups.php, no dice. I finally settled on this workaround that
requires a code change to basics.php
at top of users.php / group.php
require_once(ROOT. DS . APP_DIR . DS . 'models' . DS . 'contexts.php');
then in cake/basics.php loadModels() i changed
if (!key_exists($model_fn, $loadedModels)) {
require($path . $model_fn);
to
if (!key_exists($model_fn, $loadedModels)) {
require_once($path . $model_fn); // modified to allow Context
inheritance, bw 07/07/2006
I don't think this is the "right" way and have not submitted the change
as a patch to traq. What's a better approach? I'd rather do it the
cake way rather than starting to fork my framework.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---