Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
zendframework1
library
Zend
Filter
Null.php
Go to the documentation of this file.
1
<?php
25
#require_once 'Zend/Filter/Interface.php';
26
33
class
Zend_Filter_Null
implements
Zend_Filter_Interface
34
{
35
const
BOOLEAN
= 1;
36
const
INTEGER
= 2;
37
const
EMPTY_ARRAY
= 4;
38
const
STRING
= 8;
39
const
ZERO
= 16;
40
const
ALL
= 31;
41
42
protected
$_constants
= array(
43
self::BOOLEAN =>
'boolean'
,
44
self::INTEGER =>
'integer'
,
45
self::EMPTY_ARRAY =>
'array'
,
46
self::STRING =>
'string'
,
47
self::ZERO =>
'zero'
,
48
self::ALL =>
'all'
49
);
50
56
protected
$_type
=
self::ALL
;
57
63
public
function
__construct
(
$options
=
null
)
64
{
65
if
(
$options
instanceof
Zend_Config
) {
66
$options
=
$options
->toArray();
67
}
else
if
(!is_array(
$options
)) {
68
$options
= func_get_args();
69
$temp = array();
70
if
(!empty(
$options
)) {
71
$temp = array_shift(
$options
);
72
}
73
$options
= $temp;
74
}
else
if
(is_array(
$options
) && array_key_exists(
'type'
,
$options
)) {
75
$options
=
$options
[
'type'
];
76
}
77
78
if
(!empty(
$options
)) {
79
$this->
setType
(
$options
);
80
}
81
}
82
88
public
function
getType
()
89
{
90
return
$this->_type
;
91
}
92
100
public
function
setType
(
$type
=
null
)
101
{
102
if
(is_array(
$type
)) {
103
$detected = 0;
104
foreach
(
$type
as
$value
) {
105
if
(is_int(
$value
)) {
106
$detected +=
$value
;
107
}
else
if
(in_array(
$value
, $this->_constants)) {
108
$detected += array_search(
$value
, $this->_constants);
109
}
110
}
111
112
$type
= $detected;
113
}
else
if
(is_string(
$type
)) {
114
if
(in_array(
$type
, $this->_constants)) {
115
$type
= array_search(
$type
, $this->_constants);
116
}
117
}
118
119
if
(!is_int(
$type
) || (
$type
< 0) || (
$type
> self::ALL)) {
120
#require_once 'Zend/Filter/Exception.php';
121
throw
new
Zend_Filter_Exception
(
'Unknown type'
);
122
}
123
124
$this->_type =
$type
;
125
return
$this;
126
}
127
137
public
function
filter
(
$value
)
138
{
139
$type
= $this->
getType
();
140
141
// STRING ZERO ('0')
142
if
(
$type
>= self::ZERO) {
143
$type
-=
self::ZERO
;
144
if
(is_string(
$value
) && (
$value
==
'0'
)) {
145
return
null
;
146
}
147
}
148
149
// STRING ('')
150
if
(
$type
>= self::STRING) {
151
$type
-=
self::STRING
;
152
if
(is_string(
$value
) && (
$value
==
''
)) {
153
return
null
;
154
}
155
}
156
157
// EMPTY_ARRAY (array())
158
if
(
$type
>= self::EMPTY_ARRAY) {
159
$type
-=
self::EMPTY_ARRAY
;
160
if
(is_array(
$value
) && (
$value
== array())) {
161
return
null
;
162
}
163
}
164
165
// INTEGER (0)
166
if
(
$type
>= self::INTEGER) {
167
$type
-=
self::INTEGER
;
168
if
(is_int(
$value
) && (
$value
== 0)) {
169
return
null
;
170
}
171
}
172
173
// BOOLEAN (false)
174
if
(
$type
>= self::BOOLEAN) {
175
$type
-=
self::BOOLEAN
;
176
if
(is_bool(
$value
) && (
$value
==
false
)) {
177
return
null
;
178
}
179
}
180
181
return
$value
;
182
}
183
}
Zend_Filter_Null\filter
filter($value)
Definition:
Null.php:137
Zend_Filter_Null\ALL
const ALL
Definition:
Null.php:40
Zend_Filter_Null\STRING
const STRING
Definition:
Null.php:38
Zend_Filter_Null\BOOLEAN
const BOOLEAN
Definition:
Null.php:35
Zend_Filter_Null\$_constants
$_constants
Definition:
Null.php:42
Zend_Filter_Null
Definition:
Null.php:33
$type
$type
Definition:
item.phtml:13
$value
$value
Definition:
gender.phtml:16
Zend_Filter_Exception
Definition:
Exception.php:36
Zend_Filter_Null\ZERO
const ZERO
Definition:
Null.php:39
Zend_Filter_Null\getType
getType()
Definition:
Null.php:88
Zend_Filter_Interface
Definition:
Interface.php:30
Zend_Filter_Null\$_type
$_type
Definition:
Null.php:56
Zend_Filter_Null\INTEGER
const INTEGER
Definition:
Null.php:36
Zend_Config
Zend_Filter_Null\EMPTY_ARRAY
const EMPTY_ARRAY
Definition:
Null.php:37
Zend_Filter_Null\__construct
__construct($options=null)
Definition:
Null.php:63
Zend_Filter_Null\setType
setType($type=null)
Definition:
Null.php:100
$options
$options
Definition:
multiple_mixed_products.php:29