Tiger_Ajax_ServiceFactory
@api
Tiger_Ajax_ServiceFactory — the single-gateway /api dispatcher.
Ported from AskLevi's proven Levi_Ajax_ServiceFactory (the TIGER "message
pattern"): the routing target rides INSIDE the request, not the URL path. One
/api endpoint; the POST body carries module + (service+method) OR
(controller+action) alongside the payload, and the whole message is handed
to the target.
Two first-class modes (not a fallback chain — you name one or the other):
- SERVICE (
servicepresent): resolve {Module}Service{Service}, construct it with the merged message, return its ResponseObject (ApiController JSON- encodes it). The service did its work in construction. - CONTROLLER (
controllerpresent): resolve {Module}_{Controller}Controller, ACL-check, then signal a _forward so the controller OWNS its response. More flexible/brittle — the whole payload just lands in the action as $params.
Param resolution per key: POST body > GET query > route (svc_* names, to avoid ZF1's reserved :module/:controller/:action).
ACL is deny-by-default (resource = target class, privilege = action). Nothing throws to the caller — every failure becomes a clean result=0 ResponseObject.
TIGER IMPROVEMENT over AskLevi: a RESERVED-MODULE guard. AskLevi's services are
Core_Service_*; Tiger's kernel services are Tiger_Service_* and must NEVER
be reachable through /api. Since the class name is built as
ucfirst(module)."Service"..., a module=tiger would resolve Tiger_Service_*
— so tiger (and the other framework namespaces) are reserved and refused
before any class is touched. Extend the list with reserve().
Methods
__construct()
__construct(Zend_Controller_Request_Http $request)
Build the dispatcher and process the request immediately (the response is ready on return).
$requestZend_Controller_Request_Http— the incoming /api request
reserve()
reserve($module)
Reserve an additional module name from /api dispatch.
$modulestring— the module name to reserve
isReserved()
isReserved($module)
Is this module name reserved (framework-internal, not API-routable)?
$modulestring— the module name to test
Returns bool — true if reserved
getResponse()
getResponse()
The processed response envelope for the request.
Returns Tiger_Model_ResponseObject
getForward()
getForward()
The controller-mode hand-off descriptor for ApiController to _forward.
Returns array|null — ['module','controller','action','params'], or null in service mode