本文整理汇总了PHP中Reflection::getProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP Reflection::getProperty方法的具体用法?PHP Reflection::getProperty怎么用?PHP Reflection::getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reflection
的用法示例。
在下文中一共展示了Reflection::getProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Valida las variables de un objeto o de un array en base a una definicion de configuracion de validacion
* Se puede utilizar la libreria que se desee pere debe respetar la inerfaz de la proporcionada por el framework.
* @param type $var
* @param string $lib
* @param string $locale
* @return bool
*/
protected function validate($var, $locale = NULL, $lib = '\\Enola\\Lib\\Validation')
{
$validacion = new $lib($locale);
$reglas = $this->configValidation();
if (is_object($var)) {
$reflection = new Reflection($var);
foreach ($reglas as $key => $regla) {
$validacion->add_rule($key, $reflection->getProperty($key), $regla);
}
} else {
foreach ($reglas as $key => $regla) {
$validacion->add_rule($key, $var[$key], $regla);
}
}
if (!$validacion->validate()) {
//Consigo los errores y retorno FALSE
$this->errors = $validacion->error_messages();
return FALSE;
} else {
return TRUE;
}
}
示例2: selectFull
public function selectFull($simple, $label, $id, $name, $value, $options, $varLabel = 0, $varValue = 1, $defaultLabel = NULL, $defaultValue = NULL, $onchange = NULL, $multiple = FALSE, $message = NULL, $typeError = NULL, $size = 'md')
{
$form = 'select';
if ($simple) {
$form = 'select_simple';
}
$valores = array('config.seccion' => 'cabecera', 'config.label' => $label, 'config.id' => $id, 'config.name' => $name, 'config.onchange' => $onchange, 'config.multiple' => $multiple ? 'si' : 'no', 'config.typeError' => $typeError, 'config.size' => $size);
if (!$simple) {
$valores['config.message'] = $message;
}
//Imprimo lo que seria el Head
$this->api->component($form, $valores);
//Imprimo los hijos
if ($defaultLabel != NULL) {
$valores_option = array('config.label' => $defaultLabel, 'config.value' => $defaultValue, 'config.checked' => 'no');
$this->api->component('select_option', $valores_option);
}
foreach ($options as $option) {
$optionLab = "";
$optionVal = "";
if (is_object($option)) {
$reflection = new Reflection($option);
$optionLab = $reflection->getProperty($varLabel);
$optionVal = $reflection->getProperty($varValue);
} else {
if (is_array($option)) {
$optionLab = $option[$varLabel];
$optionVal = $option[$varValue];
} else {
$optionLab = $option;
$optionVal = $option;
}
}
$valores_option = array('config.label' => $optionLab, 'config.value' => $optionVal);
$checked = FALSE;
if (is_array($value)) {
if (in_array($optionVal, $value)) {
$checked = TRUE;
}
} else {
if ($optionVal == $value) {
$checked = TRUE;
}
}
if ($checked == TRUE) {
$valores_option['config.checked'] = 'si';
} else {
$valores_option['config.checked'] = 'no';
}
$this->api->component('select_option', $valores_option);
}
//Armo el Pie
$valores = array('config.seccion' => 'pie');
if (!$simple) {
$valores['config.message'] = $message;
}
$this->api->component($form, $valores);
}