Re: Augmenting controller actions with components

2007-09-04 Thread [EMAIL PROTECTED]

To an extent, yes, this could be solved with base / mini controllers.

Of course then you have a whole other bunch of abstract controllers
which have to be protected from the web. Also, you very quickly end up
with very complex class hierarchies if you want to have, say some
actions from one base controller, some from another, but not the ones
from another etc etc. Adding actions as part of a component lets you
take a more aspect oriented approach to design.

Simon


--~--~-~--~~~---~--~~
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: Augmenting controller actions with components

2007-09-03 Thread francky06l

I have seen a discussion about this a while ago, it looks like having
a baseController from which other's could be derived... Also remind me
the mini controller of AD7Six

On Sep 2, 6:13 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Sure, it does sound a little convoluted... I'll try again!

 for example:

 class ExampleController extends AppController {
   var $actsAs = array('SomeComponent');

 }

 class SomeComponent extends Component {
   public function someAction() {

   }

 }

 What I want to be able to do is have the url
 (controller=ExampleController, action=SomeAction) result in the
 SomeAction member of the component being called as an action. Of
 course I could just write: function someAction() { return 
 $this-SomeComponent-someAction()); } lots of times in my controller (for

 all the actions), but it would be nice not to have to do all that
 typing.

 Essentially I view it working the same way as ModelBehaviours, the way
 you can call $model-functionInBehaviour() directly. The change would
 probably have to go in the dispatcher though, rather than the
 controller.

 Right now I am achieving the effect through the rather in-elegant, and
 potentially dangerous:
 class SomeComponent extends Component {
   function startup($controller) {
 $action = $controller-params['action'];
 if method_exists($this,$action) {
   $this-$action();
 }
   }
   function someAction() {
 ... do some stuff which results in a $this-controller-redirect,
 renderAction or such like, ie completely fulfills an action ...
   }

 }

 It's certainly an enhancement, but I think the design might need some
 discussion before it's worth submitting/rejecting as an enhancement.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Augmenting controller actions with components

2007-09-02 Thread [EMAIL PROTECTED]

Is it currently possible to augment controller actions with component
functions. What I'm looking for is something similar to the way that a
behaviour function can be accessed through its model, but for
controllers, so I can provide an action with a component, instead of
having to write a bunch of actions in the controller which do no more
than farm the work out to a component.

I've implemented this through startup hook, with a switch on the
controller-params, but suspect that this might be a less than elegant
solution. Do people think it might be worth a RFE?


--~--~-~--~~~---~--~~
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: Augmenting controller actions with components

2007-09-02 Thread Chris Hartjes

On 9/2/07, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 Is it currently possible to augment controller actions with component
 functions. What I'm looking for is something similar to the way that a
 behaviour function can be accessed through its model, but for
 controllers, so I can provide an action with a component, instead of
 having to write a bunch of actions in the controller which do no more
 than farm the work out to a component.

I'm having a hard time visualizing what you're trying to accomplish
here.  Could you show us a code example?  Given that you can create
methods in a component, and you can call these methods in an action in
your controller.

I think an example would be very helpful.

-- 
Chris Hartjes
Senior Developer
Cake Development Corporation

My motto for 2007:  Just build it, damnit!

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
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: Augmenting controller actions with components

2007-09-02 Thread [EMAIL PROTECTED]

Sure, it does sound a little convoluted... I'll try again!

for example:

class ExampleController extends AppController {
  var $actsAs = array('SomeComponent');
}

class SomeComponent extends Component {
  public function someAction() {

  }
}

What I want to be able to do is have the url
(controller=ExampleController, action=SomeAction) result in the
SomeAction member of the component being called as an action. Of
course I could just write: function someAction() { return $this-
SomeComponent-someAction()); } lots of times in my controller (for
all the actions), but it would be nice not to have to do all that
typing.

Essentially I view it working the same way as ModelBehaviours, the way
you can call $model-functionInBehaviour() directly. The change would
probably have to go in the dispatcher though, rather than the
controller.

Right now I am achieving the effect through the rather in-elegant, and
potentially dangerous:
class SomeComponent extends Component {
  function startup($controller) {
$action = $controller-params['action'];
if method_exists($this,$action) {
  $this-$action();
}
  }
  function someAction() {
... do some stuff which results in a $this-controller-redirect,
renderAction or such like, ie completely fulfills an action ...
  }
}

It's certainly an enhancement, but I think the design might need some
discussion before it's worth submitting/rejecting as an enhancement.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---