Re: A new discussion about controllers which extend another-controller-other-than-AppController

2009-01-16 Thread caminante

Graham, thanks for your answer. The RemotingController class is loaded
fine with:

App::import('Controller', 'Remoting');

but components don't get initialized, it throws the same error. I also
tried adding after the App::import():

ClassRegistry::init('RemotingController');

But didn't initialized components.

Cheers.


On 15 ene, 18:54, Graham Weldon gra...@grahamweldon.com wrote:
 Hey,

 Better than including php files, use the CakePHP App::import() and
 ClassRegistry::init() methods.
 These locate, include and in the case of the ClassRegistry, instantiate and
 return the object for you.

 You would in this case, do something like:

 App::import('Controller', 'RemotingController');
 class RemotingUsersController extends RemotingController {
    /// implementation

 }

 Run a few tests with that, but its my understanding that this method should
 make the components available for the RemotingUsersController class.
 If not, ensuring that the __construct() passes back to the parent should
 ensure that the parent class is processed properly, but this should happen
 by default.

 Try the App::import() and let me know how you go with the components.

 Cheers,
 Graham

 On Thu, 15 Jan 2009 12:47:58 -0800 (PST), caminante

 running.ba...@gmail.com wrote:
  Being released 1.2 final version of CakePHP, I opened this discussion
  to try to bring some light together to this issue.

  My need:
  What's in the subject of this discussion; I have a couple of special
  controllers to be called from flash (through cakeswxphp). What I need
  is those controllers extending a RemotingController (with it's set
  of thingies for communication with flash) which in turn extends
  AppController. Sounded easy when I thought it, it's a common practice
  in OOP and I cannot see why it wouldn't be implemented in an OOP
  framework as CakePHP. Let's see:

  1) class RemotingController extends AppController {}   // dir: app/ or
  app/controllers/
  2) class RemotingUsersController extends RemotingController {}   //
  dir: app/controllers/

  When I make a request to an action in RemotingUsersController, Class
  'RemotingController' not found, either putting it at app/ or app/
  controllers/. Ok, CakePHP didn't noticed RemotingController class
  existed.

  There are a couple of (old or even antique) discussions on the
  subject:

 http://groups.google.com/group/cake-php/browse_thread/thread/83bad7a3... 
 (from 2005)
  and a more recent one:

 http://groups.google.com/group/cake-php/browse_thread/thread/f3c62f08...

  (from mid 2007)

  Neither seemed to found a (nice?) way to do this and according to
  dates, they were discussing on different stages in the evolution of
  the framework.
  I applied something said in the first one, suggesting the following:

  require_once('parent_controller.php');
  class ChildController extends ParentController {}

  The requirement for the php file with my RemotingController class
  would work fine (though not being a pretty/frameworkian solution, but
  I can live with that). Now my class seems to be recognized by Cake but
  I have another problem: The components I declare for this class don't
  work (Call to a member function requestedWith() on a non-object, for
  example). Seems that leaving a little bit the CakePHP rigorous-
  mechanics/convention-over-configuration of Cake, there are some
  things that stop working automagically, such as automatic components
  initialization.

  My questions:
  How, then, can I initialize components? (and maybe why there's nothing
  in the book on this subject?)
  What can be the most practical and conventional way of doing what I
  need?
  Are others there that achieved good results with this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: A new discussion about controllers which extend another-controller-other-than-AppController

2009-01-16 Thread caminante

Bernardo, we need to separate very differently our web-apps in two
parts: communication with flash client-side and HTML back-end
administration panel. So we have general app-wide logic and another
very specific logic for client-side that is general to all the
controllers that will be used in the communication with flash
(RemotingUsersController, etc).

On 15 ene, 19:15, Bernardo Vieira bvieira.li...@gmail.com wrote:
 Just one question though, why can't you just use app_controller for
 this? Or better yet, for added flexibility, put whatever you need in a
 component and use it in the controllers where you need remoting
 capabilities.

 Graham Weldon wrote:
  Hey,

  Better than including php files, use the CakePHP App::import() and
  ClassRegistry::init() methods.
  These locate, include and in the case of the ClassRegistry, instantiate and
  return the object for you.

  You would in this case, do something like:

  App::import('Controller', 'RemotingController');
  class RemotingUsersController extends RemotingController {
     /// implementation
  }

  Run a few tests with that, but its my understanding that this method should
  make the components available for the RemotingUsersController class.
  If not, ensuring that the __construct() passes back to the parent should
  ensure that the parent class is processed properly, but this should happen
  by default.

  Try the App::import() and let me know how you go with the components.

  Cheers,
  Graham

  On Thu, 15 Jan 2009 12:47:58 -0800 (PST), caminante
  running.ba...@gmail.com wrote:

  Being released 1.2 final version of CakePHP, I opened this discussion
  to try to bring some light together to this issue.

  My need:
  What's in the subject of this discussion; I have a couple of special
  controllers to be called from flash (through cakeswxphp). What I need
  is those controllers extending a RemotingController (with it's set
  of thingies for communication with flash) which in turn extends
  AppController. Sounded easy when I thought it, it's a common practice
  in OOP and I cannot see why it wouldn't be implemented in an OOP
  framework as CakePHP. Let's see:

  1) class RemotingController extends AppController {}   // dir: app/ or
  app/controllers/
  2) class RemotingUsersController extends RemotingController {}   //
  dir: app/controllers/

  When I make a request to an action in RemotingUsersController, Class
  'RemotingController' not found, either putting it at app/ or app/
  controllers/. Ok, CakePHP didn't noticed RemotingController class
  existed.

  There are a couple of (old or even antique) discussions on the
  subject:

 http://groups.google.com/group/cake-php/browse_thread/thread/83bad7a3...

  (from 2005)
  and a more recent one:

 http://groups.google.com/group/cake-php/browse_thread/thread/f3c62f08...

  (from mid 2007)

  Neither seemed to found a (nice?) way to do this and according to
  dates, they were discussing on different stages in the evolution of
  the framework.
  I applied something said in the first one, suggesting the following:

  require_once('parent_controller.php');
  class ChildController extends ParentController {}

  The requirement for the php file with my RemotingController class
  would work fine (though not being a pretty/frameworkian solution, but
  I can live with that). Now my class seems to be recognized by Cake but
  I have another problem: The components I declare for this class don't
  work (Call to a member function requestedWith() on a non-object, for
  example). Seems that leaving a little bit the CakePHP rigorous-
  mechanics/convention-over-configuration of Cake, there are some
  things that stop working automagically, such as automatic components
  initialization.

  My questions:
  How, then, can I initialize components? (and maybe why there's nothing
  in the book on this subject?)
  What can be the most practical and conventional way of doing what I
  need?
  Are others there that achieved good results with this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: A new discussion about controllers which extend another-controller-other-than-AppController

2009-01-16 Thread mark_story

You components are missing because __mergeVars() which does the
variable merging only works with AppController / PluginAppController.
In all other situations related to inheritance you will need to
redeclare the components, uses and helpers.

-Mark

On Jan 16, 10:14 am, caminante running.ba...@gmail.com wrote:
 Bernardo, we need to separate very differently our web-apps in two
 parts: communication with flash client-side and HTML back-end
 administration panel. So we have general app-wide logic and another
 very specific logic for client-side that is general to all the
 controllers that will be used in the communication with flash
 (RemotingUsersController, etc).

 On 15 ene, 19:15, Bernardo Vieira bvieira.li...@gmail.com wrote:

  Just one question though, why can't you just use app_controller for
  this? Or better yet, for added flexibility, put whatever you need in a
  component and use it in the controllers where you need remoting
  capabilities.

  Graham Weldon wrote:
   Hey,

   Better than including php files, use the CakePHP App::import() and
   ClassRegistry::init() methods.
   These locate, include and in the case of the ClassRegistry, instantiate 
   and
   return the object for you.

   You would in this case, do something like:

   App::import('Controller', 'RemotingController');
   class RemotingUsersController extends RemotingController {
      /// implementation
   }

   Run a few tests with that, but its my understanding that this method 
   should
   make the components available for the RemotingUsersController class.
   If not, ensuring that the __construct() passes back to the parent should
   ensure that the parent class is processed properly, but this should happen
   by default.

   Try the App::import() and let me know how you go with the components.

   Cheers,
   Graham

   On Thu, 15 Jan 2009 12:47:58 -0800 (PST), caminante
   running.ba...@gmail.com wrote:

   Being released 1.2 final version of CakePHP, I opened this discussion
   to try to bring some light together to this issue.

   My need:
   What's in the subject of this discussion; I have a couple of special
   controllers to be called from flash (through cakeswxphp). What I need
   is those controllers extending a RemotingController (with it's set
   of thingies for communication with flash) which in turn extends
   AppController. Sounded easy when I thought it, it's a common practice
   in OOP and I cannot see why it wouldn't be implemented in an OOP
   framework as CakePHP. Let's see:

   1) class RemotingController extends AppController {}   // dir: app/ or
   app/controllers/
   2) class RemotingUsersController extends RemotingController {}   //
   dir: app/controllers/

   When I make a request to an action in RemotingUsersController, Class
   'RemotingController' not found, either putting it at app/ or app/
   controllers/. Ok, CakePHP didn't noticed RemotingController class
   existed.

   There are a couple of (old or even antique) discussions on the
   subject:

  http://groups.google.com/group/cake-php/browse_thread/thread/83bad7a3...

   (from 2005)
   and a more recent one:

  http://groups.google.com/group/cake-php/browse_thread/thread/f3c62f08...

   (from mid 2007)

   Neither seemed to found a (nice?) way to do this and according to
   dates, they were discussing on different stages in the evolution of
   the framework.
   I applied something said in the first one, suggesting the following:

   require_once('parent_controller.php');
   class ChildController extends ParentController {}

   The requirement for the php file with my RemotingController class
   would work fine (though not being a pretty/frameworkian solution, but
   I can live with that). Now my class seems to be recognized by Cake but
   I have another problem: The components I declare for this class don't
   work (Call to a member function requestedWith() on a non-object, for
   example). Seems that leaving a little bit the CakePHP rigorous-
   mechanics/convention-over-configuration of Cake, there are some
   things that stop working automagically, such as automatic components
   initialization.

   My questions:
   How, then, can I initialize components? (and maybe why there's nothing
   in the book on this subject?)
   What can be the most practical and conventional way of doing what I
   need?
   Are others there that achieved good results with this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: A new discussion about controllers which extend another-controller-other-than-AppController

2009-01-16 Thread Websta*

I too went through the same issue when putting together an app
sometime back, as Mark said when inheriting like this the components,
uses and helpers controller vars need to be redeclared or merged by
you.

The obvious answer for me ended up being to create a plugin (given
that your happy using plugins), all your Remoting controller logic in
this case going in RemotingAppController and all your subsequent
remoting controllers extend from this.

An idea at least eh!?! Hth.

Paul.





On Jan 17, 1:03 pm, mark_story mark.st...@gmail.com wrote:
 You components are missing because __mergeVars() which does the
 variable merging only works with AppController / PluginAppController.
 In all other situations related to inheritance you will need to
 redeclare the components, uses and helpers.

 -Mark

 On Jan 16, 10:14 am, caminante running.ba...@gmail.com wrote:

  Bernardo, we need to separate very differently our web-apps in two
  parts: communication with flash client-side and HTML back-end
  administration panel. So we have general app-wide logic and another
  very specific logic for client-side that is general to all the
  controllers that will be used in the communication with flash
  (RemotingUsersController, etc).

  On 15 ene, 19:15, Bernardo Vieira bvieira.li...@gmail.com wrote:

   Just one question though, why can't you just use app_controller for
   this? Or better yet, for added flexibility, put whatever you need in a
   component and use it in the controllers where you need remoting
   capabilities.

   Graham Weldon wrote:
Hey,

Better than including php files, use the CakePHP App::import() and
ClassRegistry::init() methods.
These locate, include and in the case of the ClassRegistry, instantiate 
and
return the object for you.

You would in this case, do something like:

App::import('Controller', 'RemotingController');
class RemotingUsersController extends RemotingController {
   /// implementation
}

Run a few tests with that, but its my understanding that this method 
should
make the components available for the RemotingUsersController class.
If not, ensuring that the __construct() passes back to the parent should
ensure that the parent class is processed properly, but this should 
happen
by default.

Try the App::import() and let me know how you go with the components.

Cheers,
Graham

On Thu, 15 Jan 2009 12:47:58 -0800 (PST), caminante
running.ba...@gmail.com wrote:

Being released 1.2 final version of CakePHP, I opened this discussion
to try to bring some light together to this issue.

My need:
What's in the subject of this discussion; I have a couple of special
controllers to be called from flash (through cakeswxphp). What I need
is those controllers extending a RemotingController (with it's set
of thingies for communication with flash) which in turn extends
AppController. Sounded easy when I thought it, it's a common practice
in OOP and I cannot see why it wouldn't be implemented in an OOP
framework as CakePHP. Let's see:

1) class RemotingController extends AppController {}   // dir: app/ or
app/controllers/
2) class RemotingUsersController extends RemotingController {}   //
dir: app/controllers/

When I make a request to an action in RemotingUsersController, Class
'RemotingController' not found, either putting it at app/ or app/
controllers/. Ok, CakePHP didn't noticed RemotingController class
existed.

There are a couple of (old or even antique) discussions on the
subject:

   http://groups.google.com/group/cake-php/browse_thread/thread/83bad7a3...

(from 2005)
and a more recent one:

   http://groups.google.com/group/cake-php/browse_thread/thread/f3c62f08...

(from mid 2007)

Neither seemed to found a (nice?) way to do this and according to
dates, they were discussing on different stages in the evolution of
the framework.
I applied something said in the first one, suggesting the following:

require_once('parent_controller.php');
class ChildController extends ParentController {}

The requirement for the php file with my RemotingController class
would work fine (though not being a pretty/frameworkian solution, but
I can live with that). Now my class seems to be recognized by Cake but
I have another problem: The components I declare for this class don't
work (Call to a member function requestedWith() on a non-object, for
example). Seems that leaving a little bit the CakePHP rigorous-
mechanics/convention-over-configuration of Cake, there are some
things that stop working automagically, such as automatic components
initialization.

My questions:
How, then, can I initialize components? (and maybe why there's nothing
in the book on this subject?)
What can be the most practical and conventional way of doing what I
need?
Are others 

RE: A new discussion about controllers which extend another-controller-other-than-AppController

2009-01-16 Thread websta*

I should say too, I'm sure someone will moan about the suggestion of
creating a plugin for something that is not essentially that, but we have
built a number of large applications and found the plugin architecture quite
useful for segmenting parts of your application as much as creating drag and
drop type plugins.

The other alternative is really to override __mergeVars() or do something
additional to include these vars from your special controllers before
mergeVars is called.

And just a quick not on App::import, it’s a great little method for
sure, but if you know where something is and your certain its always going
to be in that relative location, why not just use include, every call to
App::import introduces unneeded overheads. Sure in a small app that’s sweet,
but start getting bigger and really pumping some traffic through and you'll
see all your App::import calls tallying the milliseconds pretty quick.


-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of Websta*
Sent: Saturday, January 17, 2009 1:58 PM
To: CakePHP
Subject: Re: A new discussion about controllers which extend
another-controller-other-than-AppController


I too went through the same issue when putting together an app
sometime back, as Mark said when inheriting like this the components,
uses and helpers controller vars need to be redeclared or merged by
you.

The obvious answer for me ended up being to create a plugin (given
that your happy using plugins), all your Remoting controller logic in
this case going in RemotingAppController and all your subsequent
remoting controllers extend from this.

An idea at least eh!?! Hth.

Paul.





On Jan 17, 1:03 pm, mark_story mark.st...@gmail.com wrote:
 You components are missing because __mergeVars() which does the
 variable merging only works with AppController / PluginAppController.
 In all other situations related to inheritance you will need to
 redeclare the components, uses and helpers.

 -Mark

 On Jan 16, 10:14 am, caminante running.ba...@gmail.com wrote:

  Bernardo, we need to separate very differently our web-apps in two
  parts: communication with flash client-side and HTML back-end
  administration panel. So we have general app-wide logic and another
  very specific logic for client-side that is general to all the
  controllers that will be used in the communication with flash
  (RemotingUsersController, etc).

  On 15 ene, 19:15, Bernardo Vieira bvieira.li...@gmail.com wrote:

   Just one question though, why can't you just use app_controller for
   this? Or better yet, for added flexibility, put whatever you need in a
   component and use it in the controllers where you need remoting
   capabilities.

   Graham Weldon wrote:
Hey,

Better than including php files, use the CakePHP App::import() and
ClassRegistry::init() methods.
These locate, include and in the case of the ClassRegistry,
instantiate and
return the object for you.

You would in this case, do something like:

App::import('Controller', 'RemotingController');
class RemotingUsersController extends RemotingController {
   /// implementation
}

Run a few tests with that, but its my understanding that this method
should
make the components available for the RemotingUsersController class.
If not, ensuring that the __construct() passes back to the parent
should
ensure that the parent class is processed properly, but this should
happen
by default.

Try the App::import() and let me know how you go with the
components.

Cheers,
Graham

On Thu, 15 Jan 2009 12:47:58 -0800 (PST), caminante
running.ba...@gmail.com wrote:

Being released 1.2 final version of CakePHP, I opened this
discussion
to try to bring some light together to this issue.

My need:
What's in the subject of this discussion; I have a couple of
special
controllers to be called from flash (through cakeswxphp). What I
need
is those controllers extending a RemotingController (with it's
set
of thingies for communication with flash) which in turn extends
AppController. Sounded easy when I thought it, it's a common
practice
in OOP and I cannot see why it wouldn't be implemented in an OOP
framework as CakePHP. Let's see:

1) class RemotingController extends AppController {}   // dir: app/
or
app/controllers/
2) class RemotingUsersController extends RemotingController {}   //
dir: app/controllers/

When I make a request to an action in RemotingUsersController,
Class
'RemotingController' not found, either putting it at app/ or app/
controllers/. Ok, CakePHP didn't noticed RemotingController class
existed.

There are a couple of (old or even antique) discussions on the
subject:

  
http://groups.google.com/group/cake-php/browse_thread/thread/83bad7a3...

(from 2005)
and a more recent one:

  
http://groups.google.com/group/cake-php/browse_thread

A new discussion about controllers which extend another-controller-other-than-AppController

2009-01-15 Thread caminante

Being released 1.2 final version of CakePHP, I opened this discussion
to try to bring some light together to this issue.

My need:
What's in the subject of this discussion; I have a couple of special
controllers to be called from flash (through cakeswxphp). What I need
is those controllers extending a RemotingController (with it's set
of thingies for communication with flash) which in turn extends
AppController. Sounded easy when I thought it, it's a common practice
in OOP and I cannot see why it wouldn't be implemented in an OOP
framework as CakePHP. Let's see:

1) class RemotingController extends AppController {}   // dir: app/ or
app/controllers/
2) class RemotingUsersController extends RemotingController {}   //
dir: app/controllers/

When I make a request to an action in RemotingUsersController, Class
'RemotingController' not found, either putting it at app/ or app/
controllers/. Ok, CakePHP didn't noticed RemotingController class
existed.

There are a couple of (old or even antique) discussions on the
subject:

http://groups.google.com/group/cake-php/browse_thread/thread/83bad7a3498001c7
(from 2005)
and a more recent one:
http://groups.google.com/group/cake-php/browse_thread/thread/f3c62f08147fcfe9/
(from mid 2007)

Neither seemed to found a (nice?) way to do this and according to
dates, they were discussing on different stages in the evolution of
the framework.
I applied something said in the first one, suggesting the following:

require_once('parent_controller.php');
class ChildController extends ParentController {}

The requirement for the php file with my RemotingController class
would work fine (though not being a pretty/frameworkian solution, but
I can live with that). Now my class seems to be recognized by Cake but
I have another problem: The components I declare for this class don't
work (Call to a member function requestedWith() on a non-object, for
example). Seems that leaving a little bit the CakePHP rigorous-
mechanics/convention-over-configuration of Cake, there are some
things that stop working automagically, such as automatic components
initialization.

My questions:
How, then, can I initialize components? (and maybe why there's nothing
in the book on this subject?)
What can be the most practical and conventional way of doing what I
need?
Are others there that achieved good results with this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: A new discussion about controllers which extend another-controller-other-than-AppController

2009-01-15 Thread Graham Weldon


Hey,

Better than including php files, use the CakePHP App::import() and
ClassRegistry::init() methods.
These locate, include and in the case of the ClassRegistry, instantiate and
return the object for you.

You would in this case, do something like:

App::import('Controller', 'RemotingController');
class RemotingUsersController extends RemotingController {
   /// implementation
}

Run a few tests with that, but its my understanding that this method should
make the components available for the RemotingUsersController class.
If not, ensuring that the __construct() passes back to the parent should
ensure that the parent class is processed properly, but this should happen
by default.

Try the App::import() and let me know how you go with the components.

Cheers,
Graham


On Thu, 15 Jan 2009 12:47:58 -0800 (PST), caminante
running.ba...@gmail.com wrote:
 Being released 1.2 final version of CakePHP, I opened this discussion
 to try to bring some light together to this issue.
 
 My need:
 What's in the subject of this discussion; I have a couple of special
 controllers to be called from flash (through cakeswxphp). What I need
 is those controllers extending a RemotingController (with it's set
 of thingies for communication with flash) which in turn extends
 AppController. Sounded easy when I thought it, it's a common practice
 in OOP and I cannot see why it wouldn't be implemented in an OOP
 framework as CakePHP. Let's see:
 
 1) class RemotingController extends AppController {}   // dir: app/ or
 app/controllers/
 2) class RemotingUsersController extends RemotingController {}   //
 dir: app/controllers/
 
 When I make a request to an action in RemotingUsersController, Class
 'RemotingController' not found, either putting it at app/ or app/
 controllers/. Ok, CakePHP didn't noticed RemotingController class
 existed.
 
 There are a couple of (old or even antique) discussions on the
 subject:
 

http://groups.google.com/group/cake-php/browse_thread/thread/83bad7a3498001c7
 (from 2005)
 and a more recent one:

http://groups.google.com/group/cake-php/browse_thread/thread/f3c62f08147fcfe9/
 (from mid 2007)
 
 Neither seemed to found a (nice?) way to do this and according to
 dates, they were discussing on different stages in the evolution of
 the framework.
 I applied something said in the first one, suggesting the following:
 
 require_once('parent_controller.php');
 class ChildController extends ParentController {}
 
 The requirement for the php file with my RemotingController class
 would work fine (though not being a pretty/frameworkian solution, but
 I can live with that). Now my class seems to be recognized by Cake but
 I have another problem: The components I declare for this class don't
 work (Call to a member function requestedWith() on a non-object, for
 example). Seems that leaving a little bit the CakePHP rigorous-
 mechanics/convention-over-configuration of Cake, there are some
 things that stop working automagically, such as automatic components
 initialization.
 
 My questions:
 How, then, can I initialize components? (and maybe why there's nothing
 in the book on this subject?)
 What can be the most practical and conventional way of doing what I
 need?
 Are others there that achieved good results with this?
 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: A new discussion about controllers which extend another-controller-other-than-AppController

2009-01-15 Thread Bernardo Vieira

Just one question though, why can't you just use app_controller for 
this? Or better yet, for added flexibility, put whatever you need in a 
component and use it in the controllers where you need remoting 
capabilities.

Graham Weldon wrote:
 Hey,

 Better than including php files, use the CakePHP App::import() and
 ClassRegistry::init() methods.
 These locate, include and in the case of the ClassRegistry, instantiate and
 return the object for you.

 You would in this case, do something like:

 App::import('Controller', 'RemotingController');
 class RemotingUsersController extends RemotingController {
/// implementation
 }

 Run a few tests with that, but its my understanding that this method should
 make the components available for the RemotingUsersController class.
 If not, ensuring that the __construct() passes back to the parent should
 ensure that the parent class is processed properly, but this should happen
 by default.

 Try the App::import() and let me know how you go with the components.

 Cheers,
 Graham


 On Thu, 15 Jan 2009 12:47:58 -0800 (PST), caminante
 running.ba...@gmail.com wrote:
   
 Being released 1.2 final version of CakePHP, I opened this discussion
 to try to bring some light together to this issue.

 My need:
 What's in the subject of this discussion; I have a couple of special
 controllers to be called from flash (through cakeswxphp). What I need
 is those controllers extending a RemotingController (with it's set
 of thingies for communication with flash) which in turn extends
 AppController. Sounded easy when I thought it, it's a common practice
 in OOP and I cannot see why it wouldn't be implemented in an OOP
 framework as CakePHP. Let's see:

 1) class RemotingController extends AppController {}   // dir: app/ or
 app/controllers/
 2) class RemotingUsersController extends RemotingController {}   //
 dir: app/controllers/

 When I make a request to an action in RemotingUsersController, Class
 'RemotingController' not found, either putting it at app/ or app/
 controllers/. Ok, CakePHP didn't noticed RemotingController class
 existed.

 There are a couple of (old or even antique) discussions on the
 subject:


 
 http://groups.google.com/group/cake-php/browse_thread/thread/83bad7a3498001c7
   
 (from 2005)
 and a more recent one:

 
 http://groups.google.com/group/cake-php/browse_thread/thread/f3c62f08147fcfe9/
   
 (from mid 2007)

 Neither seemed to found a (nice?) way to do this and according to
 dates, they were discussing on different stages in the evolution of
 the framework.
 I applied something said in the first one, suggesting the following:

 require_once('parent_controller.php');
 class ChildController extends ParentController {}

 The requirement for the php file with my RemotingController class
 would work fine (though not being a pretty/frameworkian solution, but
 I can live with that). Now my class seems to be recognized by Cake but
 I have another problem: The components I declare for this class don't
 work (Call to a member function requestedWith() on a non-object, for
 example). Seems that leaving a little bit the CakePHP rigorous-
 mechanics/convention-over-configuration of Cake, there are some
 things that stop working automagically, such as automatic components
 initialization.

 My questions:
 How, then, can I initialize components? (and maybe why there's nothing
 in the book on this subject?)
 What can be the most practical and conventional way of doing what I
 need?
 Are others there that achieved good results with this?

 

 

   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---