I'm working on my ACL and still have some design issues. One of them is a place to specify the decorator for the result object.

The basic API goes like this:

$result = $acl->isAllowed('role', 'action', 'resource');
if ($result->isCriterial()) { $criteria = $result->getCriteria(); }
I want client code to be able to ask for the criteria in different formats, especially as an SQL string, not only as Criteria objects.

The main choice is between a strategy and decorator. I think decorator fits better here since I can leave the getCriteria() method to return Criteria objects and having the decorator implement a specific method for alternate criteria forms (eg: $result->getCriteriaAsSQL()).

I would like to avoid the client code to have to specify the specific decorator (and hence Criteria form it will use). One option would be to set a default decorator in the ACL (eg $acl->setDefaultResultDecorator());
There's one thing I don't like about this setup: clients don't know what decorator they will get, if the added methods will be available. And an 'if result object is SQLDecorator' doesn't seem like a good idea.

So I'm looking for tips on how I could handle this better than what I have know.