* An array of type in the form 'type name' => 'int representing type'
*/
public static function getValidTypes() {
- return array(
+ return [
'Int' => self::T_INT,
'String' => self::T_STRING,
'Enum' => self::T_ENUM,
'Money' => self::T_MONEY,
'Email' => self::T_EMAIL,
'Mediumblob' => self::T_MEDIUMBLOB,
- );
+ ];
}
/**
}
// Normal clause.
- $part = preg_replace_callback('/^(?:(?:((?:`[\w-]{1,64}`|[\w-]{1,64}))(?:\.))?(`[\w-]{1,64}`|[\w-]{1,64})(?: (asc|desc))?)$/i', array('CRM_Utils_Type', 'mysqlOrderByCallback'), trim($part));
+ $part = preg_replace_callback('/^(?:(?:((?:`[\w-]{1,64}`|[\w-]{1,64}))(?:\.))?(`[\w-]{1,64}`|[\w-]{1,64})(?: (asc|desc))?)$/i', ['CRM_Utils_Type', 'mysqlOrderByCallback'], trim($part));
}
return implode(', ', $parts);
}
*/
public static function validate($data, $type, $abort = TRUE, $name = 'One of parameters ', $isThrowException = FALSE) {
- $possibleTypes = array(
+ $possibleTypes = [
'Integer',
'Int',
'Positive',
'ExtensionKey',
'Json',
'Alphanumeric',
- );
+ 'Color',
+ ];
if (!in_array($type, $possibleTypes)) {
if ($isThrowException) {
throw new CRM_Core_Exception(ts('Invalid type, must be one of : ' . implode($possibleTypes)));
return $data;
}
break;
+
+ case 'Color':
+ if (CRM_Utils_Rule::color($data)) {
+ return $data;
+ }
+ break;
}
if ($abort) {
* @return array
*/
public static function dataTypes() {
- $types = array(
+ $types = [
'Integer',
'String',
'Date',
'Timestamp',
'Money',
'Email',
- );
+ ];
return array_combine($types, $types);
}