On Feb 16, 8:06 am, Richard <[email protected]> wrote:
> Hi,
>
> Firstly let me say I'm reasonably new to CakePHP, but not the design
> patterns it uses (I'm a fast learner and have used frameworks before).
>
> I've recently been given a CakePHP project, it's got hundreds of
> bugs,is poorly designed and written, hard-coding access levels in /
> cake/libs/controller/app_controller.php, etc. All of the previous
> developers code in the /cake/ folder I've *moved* to respected
> 'parent' controllers in the /app/ folder. For example, /app/
> app_helper.php, etc instead of /cake/libs/helpers/helper.php.
> Everything worked at this point.
>
> Secondly he uses constructs in every controller and to load models he
> uses $this->uses = array('discussion'), etc. I removed these
> constructs and changed it to var $uses = array('Discussion'); at top
> of each controller.
>
> However, now I'm getting errors.
> Here's one;
> ** CODE **
> Warning (512): Controller::paginate() - can't find model Discussion in
> controller DiscussionsController [CORE/cake/libs/controller/
> controller.php, line 947]
> ** /CODE **
>
> Now, thats not all if I remove his construct (which has
> parent::Controller) in the app_controller.php, and use my no-
> constructor method when i try go to a controller it redirects me to /
> users/login (Missing Controller error in title). This is really
> unexpected behaviour because I've searched contents of every file no
> reference of /users/login. And I don't know why it doesn't load any of
> my models when I use the var $uses method. Does it have something to
> do with the construct, as he was doing parent::Controller in each of
> his constructs and extending each controller to the AppController.
> Here is a small extract of the way I am writing controllers.
>
> ** CODE **
> class DiscussionsController extends AppController {
>
> /**
> * Name of the controller
> *
> * @var string
> */
> var $name = 'Discussions';
>
> /**
> * Specifies the models (or uses) used in this controller
> *
> * @var array
> */
> var $uses = array('Action', 'Discussion', 'DiscussionComment');
>
> /**
> * Specifies the components used in this controller
> *
> * @var array
> */
> var $components = array('Upload');
>
> /**
> * Specifies the helpers used in this controller
> *
> * @var array
> */
> var $helpers = array('Time');
>
> /**
> * Define the pagination defaults
> *
> * @var array
> */
> var $paginate = array('Discussion', array(
> 'fields' => array('Discussion.id', 'Discussion.title',
> 'Discussion.description', 'Discussion.image', 'Discussion.created',
> 'User.id', 'User.name'),
> 'order' => array('Discussion.id' => 'DESC'),
> 'limit' => 10,
> 'recursive' => 0
> ));
> ** /CODE **
>
> And this is his method;
>
> ** CODE **
> function __construct() {
> parent::__construct();
>
> $this->name = 'Discussions';
>
> $this->uses[] = 'Action';
> $this->uses[] = 'Discussion';
> $this->uses[] = 'DiscussionComment';
> $this->components[] = 'Upload';
> $this->helpers[] = 'Time';
>
> $this->noAccess = array(
> -1 => array('start', 'add_comment', 'delete', 'edit'),
> 0 => array(),
> 1 => array(),
> 2 => array()
> );
> }
> ** /CODE **
The Auth component will be performing the redirect (I assume you have
it included) from the look of that code you'd be better off starting
from nothing and applying what the old code did a bit at a time,
rather than trying to clean up the mess.
AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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?hl=en
-~----------~----~----~----~------~----~------~--~---