Friday, November 5, 2010

Re: build_acl() method creates too much acos! How to make non-action-methods private? --psybear

Hey AD7six, thanks for your very detailed answer!

> You seem to have tens or hunderds of methods in your controllers e,g,

Yes, that's true, I'm working on renaming them to protected ones using
"_" as prefix.

>  isSuperuser <- user model
>  afterView <- model
>  OR
>    if more relevant just put it in the action, where's the benfit of
> having 2 view functions

I don't really understand. isSuperuser should be a model method, I
agree with this, too. But what about afterView being a model method?
In my concrete scenario, I have an AppController::view() method that
handles all the view logic for every descending controller, and in the
end of this view method the afterView() method is called, so
descending controllers can do some magic in them (I'm using the
Template pattern here).

So what about "put it in the action" and having 2 view functions?

> _ = protected, __ = private. It's a convetion for php4 compatibility,
> and it doesn't make any difference (but I'd suggest you only use
> protected).

I guess I'll only use one underscore. I never worked with strictly
visibility enforcing languages like Java too long, so I don't really
have the "feeling" on when a method should be private or protected,
anyway.

> If you drop the acos table that means any existing permisions you've
> got are useless - because most likly the aco_ids will change. That's
> most likely not what you want.

That's right, thank you!

> PS. use visibility keywords - if you do so you'll recognise the use/
> difference between e.g.
>  protected function _someCommonController method()
>  public function _calledFromADifferentObject() <- e.g. blackhole must
> be public but is not an action.

But this will only work with PHP5, right? My whole app is written in
PHP4 style code, so I guess I will stick to that...

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: