本文整理汇总了PHP中LabelUtil::makeModelAndAttributeNameCombinationLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP LabelUtil::makeModelAndAttributeNameCombinationLabel方法的具体用法?PHP LabelUtil::makeModelAndAttributeNameCombinationLabel怎么用?PHP LabelUtil::makeModelAndAttributeNameCombinationLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LabelUtil
的用法示例。
在下文中一共展示了LabelUtil::makeModelAndAttributeNameCombinationLabel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sanitizeValueBySanitizerTypes
/**
* Given an array of sanitizer util types, a value, as well as several other parameters, run through each
* sanitizer type on the value and process any sanitization messages or errors into the ImportSanitizeResultsUtil
* provided.
* @param array $sanitizerUtilTypes
* @param string $modelClassName
* @param string $attributeName
* @param mixed $value
* @param array $columnMappingData
* @param ImportSanitizeResultsUtil $importSanitizeResultsUtil
* @return mixed value
*/
public static function sanitizeValueBySanitizerTypes($sanitizerUtilTypes, $modelClassName, $attributeName, $value, $columnName, $columnMappingData, ImportSanitizeResultsUtil $importSanitizeResultsUtil)
{
assert('is_array($sanitizerUtilTypes)');
assert('is_string($modelClassName)');
assert('is_string($attributeName) || $attributeName == null');
assert('is_string($columnName)');
assert('is_array($columnMappingData)');
foreach ($sanitizerUtilTypes as $sanitizerUtilType) {
try {
$sanitizer = ImportSanitizerUtilFactory::make($sanitizerUtilType, $modelClassName, $attributeName, $columnName, $columnMappingData);
if ($sanitizer->shouldSanitizeValue()) {
$value = $sanitizer->sanitizeValue($value);
}
} catch (InvalidValueToSanitizeException $e) {
if ($e->getMessage() != null) {
if ($attributeName != null) {
$label = LabelUtil::makeModelAndAttributeNameCombinationLabel($modelClassName, $attributeName);
} else {
$label = $modelClassName::getModelLabelByTypeAndLanguage('Singular') . ' -';
}
$importSanitizeResultsUtil->addMessage($label . ' ' . $e->getMessage());
}
$value = null;
if ($sanitizer::shouldNotSaveModelOnSanitizingValueFailure()) {
$importSanitizeResultsUtil->setModelShouldNotBeSaved();
}
break;
}
}
return $value;
}
示例2: makeMessagesByModel
/**
* Make an array of message strings by RedBeanModel errors
* @param array $errors RedBeanModel errors
*/
public static function makeMessagesByModel(RedBeanModel $model)
{
$messages = array();
foreach ($model->getErrors() as $attributeName => $errors) {
foreach ($errors as $relationAttributeName => $errorOrRelatedError) {
if (is_array($errorOrRelatedError)) {
$relationModelClassName = $model->getRelationModelClassName($attributeName);
foreach ($errorOrRelatedError as $relatedError) {
if ($relatedError != '') {
$messages[] = LabelUtil::makeModelAndAttributeNameCombinationLabel(get_class($model), $attributeName) . ' - ' . $relatedError;
}
}
} elseif ($errorOrRelatedError != '') {
$messages[] = LabelUtil::makeModelAndAttributeNameCombinationLabel(get_class($model), $attributeName) . ' - ' . $errorOrRelatedError;
}
}
}
return $messages;
}
示例3: sanitizeValueBySanitizerTypes
/**
* Given an array of sanitizer util types, a value, as well as several other parameters, run through each
* sanitizer type on the value and process any sanitization messages or errors into the ImportSanitizeResultsUtil
* provided.
* @param array $sanitizerUtilTypes
* @param string $modelClassName
* @param string $attributeName
* @param mixed $value
* @param array $columnMappingData
* @param ImportSanitizeResultsUtil $importSanitizeResultsUtil
*/
public static function sanitizeValueBySanitizerTypes($sanitizerUtilTypes, $modelClassName, $attributeName, $value, $columnMappingData, ImportSanitizeResultsUtil $importSanitizeResultsUtil)
{
assert('is_array($sanitizerUtilTypes)');
assert('is_string($modelClassName)');
assert('is_string($attributeName) || $attributeName == null');
assert('is_array($columnMappingData)');
foreach ($sanitizerUtilTypes as $sanitizerUtilType) {
$sanitizerUtilClassName = $sanitizerUtilType . 'SanitizerUtil';
//For extra columns, only process sanitization for 'required' since that will add the default values.
//Other sanitization is not required since extra columns are not fed from external data.
if ($columnMappingData["type"] == 'extraColumn' && !is_subclass_of($sanitizerUtilClassName, 'RequiredSanitizerUtil') && $sanitizerUtilClassName != 'RequiredSanitizerUtil') {
continue;
}
$mappingRuleType = $sanitizerUtilClassName::getLinkedMappingRuleType();
if ($mappingRuleType != null) {
assert('$mappingRuleType != null');
$mappingRuleFormClassName = $mappingRuleType . 'MappingRuleForm';
if (!isset($columnMappingData['mappingRulesData'][$mappingRuleFormClassName])) {
assert('$columnMappingData["type"] = "extraColumn"');
$mappingRuleData = null;
} else {
$mappingRuleData = $columnMappingData['mappingRulesData'][$mappingRuleFormClassName];
}
} else {
$mappingRuleData = null;
}
try {
if ($sanitizerUtilClassName::supportsSanitizingWithInstructions()) {
if (!empty($columnMappingData['importInstructionsData'])) {
assert('isset($columnMappingData["importInstructionsData"])');
$importInstructionsData = $columnMappingData['importInstructionsData'];
} else {
$importInstructionsData = null;
}
$value = $sanitizerUtilClassName::sanitizeValueWithInstructions($modelClassName, $attributeName, $value, $mappingRuleData, $importInstructionsData);
} else {
$value = $sanitizerUtilClassName::sanitizeValue($modelClassName, $attributeName, $value, $mappingRuleData);
}
} catch (InvalidValueToSanitizeException $e) {
if ($e->getMessage() != null) {
if ($attributeName != null) {
$label = LabelUtil::makeModelAndAttributeNameCombinationLabel($modelClassName, $attributeName);
} else {
$label = $modelClassName::getModelLabelByTypeAndLanguage('Singular') . ' -';
}
$importSanitizeResultsUtil->addMessage($label . ' ' . $e->getMessage());
}
$value = null;
if ($sanitizerUtilClassName::shouldNotSaveModelOnSanitizingValueFailure()) {
$importSanitizeResultsUtil->setModelShouldNotBeSaved();
}
break;
}
}
return $value;
}
示例4: testMakeModelAndAttributeNameCombinationLabel
public function testMakeModelAndAttributeNameCombinationLabel()
{
$label = LabelUtil::makeModelAndAttributeNameCombinationLabel('A', 'a');
$this->assertEquals('A - A', $label);
}