Re: View::controller is not initialized in the constructor

2007-06-26 Thread John David Anderson


On Jun 26, 2007, at 10:43 AM, migloth wrote:


 I recently downloaded CakePHP release 1.2.

 When I attempted to access the $controller member of the View object
 ($this-controller), I get a message similar to the following.

 Fatal error: Call to a member function on a non-object in /somesite/
 htdocs/app/views/elements/someElement.thtml on line 2
 The code for someElement.thtml is:
 ?php
 $user = $this-controller-someMethod();
 .
 .
 .
 ?

 I started poking around and discovered that the View constructor never
 initializes the $controller variable in release 1.2.

 It is initialized in release 1.1.x.x.

 Is this by design?

Yes - allowing the view layer to have full access to the controller  
layer violates MVC tenets.

What did you need the controller object for?

-- John




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: View::controller is not initialized in the constructor

2007-06-26 Thread migloth

I was calling component methods using $this-controller-component-
someMethod();

Oh well.  I'll figure out a different/better way.

Thanks.

On Jun 26, 11:59 am, John David Anderson [EMAIL PROTECTED]
wrote:
 On Jun 26, 2007, at 10:43 AM, migloth wrote:





  I recently downloaded CakePHP release 1.2.

  When I attempted to access the $controller member of the View object
  ($this-controller), I get a message similar to the following.

  Fatal error: Call to a member function on a non-object in /somesite/
  htdocs/app/views/elements/someElement.thtml on line 2
  The code for someElement.thtml is:
  ?php
  $user = $this-controller-someMethod();
  .
  .
  .
  ?

  I started poking around and discovered that the View constructor never
  initializes the $controller variable in release 1.2.

  It is initialized in release 1.1.x.x.

  Is this by design?

 Yes - allowing the view layer to have full access to the controller
 layer violates MVC tenets.

 What did you need the controller object for?

 -- John


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---