|
definition: |
mainController :: ControllerGenerator
mainController _ (Entity entityName _) _ _ =
controllerFunction
("Choose the controller for a "++entityName++
" entity according to the URL parameter.")
entityName "main" 0
controllerType -- function type
[simpleRule [] -- no arguments
(doExpr
[CSPat (CPVar (1,"args"))
(constF (spiceyModule,"getControllerParams")),
CSExpr
(CCase CRigid (CVar (1,"args"))
([cBranch (listPattern [])
(constF (controllerFunctionName entityName "list")),
cBranch (listPattern [stringPattern "list"])
(constF (controllerFunctionName entityName "list")),
cBranch (listPattern [stringPattern "new"])
(constF (controllerFunctionName entityName "new"))] ++
map applyControllerBranch ["show", "edit", "delete", "destroy"] ++
[cBranch (CPVar (3,"_"))
(constF (spiceyModule, "displayUrlError"))])
)
]
)]
where
applyControllerBranch n = let svar = (2,"s") in
cBranch (listPattern [stringPattern n, CPVar svar])
(applyF (spiceyModule,"controllerOnKey")
[CVar svar, constF (controllerFunctionName entityName n)])
|
|
demand: |
argument 2 |
|
deterministic: |
deterministic operation |
|
documentation: |
Generates the main controller that dispatches to the various subcontrollers according to the URL parameters. |
|
failfree: |
(_, _, _, _) |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,{Entity},_,_) |-> _}
|
|
name: |
mainController |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
String -> Database.ERD.Entity -> [Database.ERD.Relationship] -> [Database.ERD.Entity] -> AbstractCurry.Types.CFuncDecl |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
reducible on all ground data terms |