當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LabelUtil::makeModelAndAttributeNameCombinationLabel方法代碼示例

本文整理匯總了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;
 }
開發者ID:youprofit,項目名稱:Zurmo,代碼行數:43,代碼來源:ImportSanitizerUtil.php

示例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;
 }
開發者ID:youprofit,項目名稱:Zurmo,代碼行數:23,代碼來源:RedBeanModelErrorsToMessagesUtil.php

示例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;
 }
開發者ID:sandeep1027,項目名稱:zurmo_,代碼行數:67,代碼來源:ImportSanitizerUtil.php

示例4: testMakeModelAndAttributeNameCombinationLabel

 public function testMakeModelAndAttributeNameCombinationLabel()
 {
     $label = LabelUtil::makeModelAndAttributeNameCombinationLabel('A', 'a');
     $this->assertEquals('A - A', $label);
 }
開發者ID:youprofit,項目名稱:Zurmo,代碼行數:5,代碼來源:LabelUtilTest.php


注:本文中的LabelUtil::makeModelAndAttributeNameCombinationLabel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。