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
> <[email protected]> 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 [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
-~----------~----~----~----~------~----~------~--~---