-
Notifications
You must be signed in to change notification settings - Fork 3
/
interface.php
54 lines (46 loc) · 1.47 KB
/
interface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
class midgardmvc_helper_forms
{
public static function create($form_namespace = null)
{
if (is_null($form_namespace))
{
throw new InvalidArgumentException('Namespace for form required');
}
// Each form namespace is a singleton
static $forms_by_namespace = array();
if (isset($forms_by_namespace[$form_namespace]))
{
return $forms_by_namespace[$form_namespace];
}
// Initialize a new form instance
$forms_by_namespace[$form_namespace] = new midgardmvc_helper_forms_form($form_namespace);
return $forms_by_namespace[$form_namespace];
}
public static function identify_post()
{
/*
//Removed to allow forms with method GET to pass
if (midgardmvc_core::get_instance()->context->request_method != 'post')
{
return null;
}
*/
if (isset($_POST) && isset($_POST['midgardmvc_helper_forms_namespace']))
{
return $_POST['midgardmvc_helper_forms_namespace'];
}
elseif(isset($_GET) && isset($_GET['midgardmvc_helper_forms_namespace']))
{
return $_GET['midgardmvc_helper_forms_namespace'];
}
return null;
}
}
class midgardmvc_helper_forms_exception_validation extends Exception
{
public function __construct($message = '', $code = 0)
{
parent::__construct($message, $code);
}
}