public function BotchaFormController::getForm in BOTCHA Spam Prevention 7.3
Same name and namespace in other branches
- 6.3 controller/form/botcha.form.controller.inc \BotchaFormController::getForm()
Gets a form from cache. If it does not exists in cache - gets from database. If it does not exists there also - returns new form or BotchaFormNone depending on input parameter.
Parameters
string $form_id:
boolean $create: Determines should we construct new form or return NULL if it does not exist.
Return value
Overrides IBotchaFormController::getForm
2 calls to BotchaFormController::getForm()
- BotchaFormController::getForms in controller/
form/ botcha.form.controller.inc - Get a list of available BOTCHA form objects. @todo Respect reset (?via Cacher?)
- BotchaFormController::save in controller/
form/ botcha.form.controller.inc
File
- controller/
form/ botcha.form.controller.inc, line 43 - Controller layer of the BotchaForm objects.
Class
- BotchaFormController
- Special class to abstract operations with form_id. It looks like additional layer of abstraction after DatabaseAbstractionLayer. It helps us to get necessary data - while we don't have to repeat ourselves in many places, writing queries to the…
Code
public function getForm($form_id, $create = TRUE) {
$none = TRUE;
// Respect form exceptions (done by forbidden_forms recipe book).
//if (!in_array($form_id, array('user_login', 'user_login_block', 'update_script_selection_form'))) {
$form = $this
->getModel()
->getForm($form_id);
if ($form || $create) {
$none = FALSE;
}
//}
if ($none) {
$botcha_form = new BotchaFormNone($form_id);
}
else {
$botcha_form = new BotchaForm($form_id);
$botcha_form
->getRecipebook();
}
return $botcha_form;
}