This commit is contained in:
Roly Rudy Gutierrez Pinto
2016-03-14 09:22:59 -04:00
parent eb614adb72
commit 3106877cfa
5 changed files with 130 additions and 58 deletions

View File

@@ -0,0 +1,15 @@
<?php
namespace ProcessMaker\BusinessModel\DynaForm;
abstract class Validator implements ValidatorInterface
{
protected $json;
public function __construct($json)
{
$this->json = $json;
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace ProcessMaker\BusinessModel\DynaForm;
class ValidatorCheckGroup extends Validator
{
public function validatePost(&$post)
{
$json = $this->json;
if ($json === null) {
return;
}
if (!isset($post[$json->variable])) {
$post[$json->variable] = array();
$post[$json->variable . "_label"] = \G::json_encode(array());
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace ProcessMaker\BusinessModel\DynaForm;
class ValidatorFactory
{
const TITLE = "title";
const SUBTITLE = "subtitle";
const LABEL = "label"; //deprecated
const LINK = "link";
const IMAGE = "image";
const FILE = "file";
const SUBMIT = "submit";
const BUTTON = "button";
const GRID = "grid";
const SUBFORM = "subform";
const TEXT = "text";
const TEXTAREA = "textarea";
const DROPDOWN = "dropdown";
const CHECKBOX = "checkbox";
const CHECKGROUP = "checkgroup";
const RADIO = "radio";
const DATETIME = "datetime";
const SUGGEST = "suggest";
const HIDDEN = "hidden";
const FORM = "form";
const CELL = "cell";
const ANNOTATION = "label"; //todo
const GEOMAP = "location";
const QRCODE = "scannerCode";
const SIGNATURE = "signature";
const IMAGEM = "imageMobile";
const AUDIOM = "audioMobile";
const VIDEOM = "videoMobile";
const PANEL = "panel";
const MSGPANEL = "msgPanel";
/**
*
* @param type $type
* @param type $json
* @return \ProcessMaker\BusinessModel\DynaForm\ValidatorInterface
*/
public static function createValidatorClass($type = '', $json = null)
{
switch ($type) {
case ValidatorFactory::CHECKGROUP:
return new ValidatorCheckGroup($json);
default :
return null;
}
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace ProcessMaker\BusinessModel\DynaForm;
interface ValidatorInterface
{
public function validatePost(&$post);
}