本文整理汇总了PHP中ArrayUtil::stringify方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtil::stringify方法的具体用法?PHP ArrayUtil::stringify怎么用?PHP ArrayUtil::stringify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil::stringify方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testStringify
public function testStringify()
{
$data = array('a', 'b', 'c');
$content = ArrayUtil::stringify($data);
$compareContent = 'a, b, c';
$this->assertEquals($compareContent, $content);
$data = array('a');
$content = ArrayUtil::stringify($data);
$compareContent = 'a';
$this->assertEquals($compareContent, $content);
}
示例2: stringifyOneToManyRelatedModelsValues
/**
* Given an array of data, create stringified content.
* @param array $values
*/
public function stringifyOneToManyRelatedModelsValues($values)
{
assert('is_array($values)');
return ArrayUtil::stringify($values);
}
示例3: resolveMergeTagToStandardOrRelatedAttribute
protected static function resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params)
{
$attributeName = strtok($attributeAccessorString, '->');
if (SpecialMergeTagsAdapter::isSpecialMergeTag($attributeName, $timeQualifier)) {
return SpecialMergeTagsAdapter::resolve($attributeName, $model, $errorOnFirstMissing, $params);
} else {
if (!isset($model)) {
return static::PROPERTY_NOT_FOUND;
} elseif (!method_exists($model, 'isAttribute') || !$model->isAttribute($attributeName)) {
if ($model instanceof Activity) {
$metadata = $model::getMetadata();
$activityItemsModelClassNamesData = $metadata['Activity']['activityItemsModelClassNames'];
foreach ($model->activityItems as $activityItem) {
if (ucfirst($attributeName) == get_class($activityItem)) {
$attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString);
return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $activityItem, $language, $timeQualifier, $errorOnFirstMissing, $params);
}
if (get_class($activityItem) == 'Item' && array_search(ucfirst($attributeName), $activityItemsModelClassNamesData) !== false) {
try {
$modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem(ucfirst($attributeName));
$castedDownModel = $activityItem->castDown(array($modelDerivationPathToItem));
if (ucfirst($attributeName) == get_class($castedDownModel)) {
$attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString);
return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $castedDownModel, $language, $timeQualifier, $errorOnFirstMissing, $params);
}
} catch (NotFoundException $e) {
//Do nothing
}
}
unset($activityItemsModelClassNamesData[get_class($activityItem)]);
}
foreach ($activityItemsModelClassNamesData as $relationModelClassName) {
if (ucfirst($attributeName) == $relationModelClassName) {
$model = new $relationModelClassName();
$attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString);
return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params);
}
}
}
return static::PROPERTY_NOT_FOUND;
} elseif ($model->{$attributeName} instanceof CurrencyValue) {
$model = $model->{$attributeName};
if ($attributeName === $attributeAccessorString) {
$attributeAccessorString = null;
} else {
$attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString);
}
if (empty($attributeAccessorString)) {
// If a user specific a relation merge tag but not a property, we assume he meant "value" property.
$currencyValueModel = $model;
$value = static::getAttributeValue($currencyValueModel, 'value', $timeQualifier);
return CLocale::getInstance($language)->getCurrencySymbol($currencyValueModel->currency->code) . $value;
// We can't use code below because it converts integer values in flat and also add slashes to '.' in float numbers
//return Yii::app()->numberFormatter->formatCurrency($value,
// $currencyValueModel->currency->code);
}
return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params);
} elseif ($model->{$attributeName} instanceof CustomField) {
$value = static::getAttributeValue($model->{$attributeName}, 'value', $timeQualifier);
// TODO: @Shoaibi/@Jason: Low: need to apply localizations(Date/time/currency formats, ...) here besides translation
if ($value) {
$value = Zurmo::t($model::getModuleClassName(), $value, array(), null, $language);
}
return $value;
} elseif ($model->isRelation($attributeName)) {
$model = $model->{$attributeName};
if ($attributeName === $attributeAccessorString) {
$attributeAccessorString = null;
} else {
$attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString);
}
if (empty($attributeAccessorString)) {
// If a user specific a relation merge tag but not a property, we assume he meant "value" property.
if (empty($timeQualifier)) {
return strval($model);
} else {
return static::PROPERTY_NOT_FOUND;
}
}
if ($model instanceof RedBeanModels) {
$modelClassName = $model->getModelClassName();
if ($attributeAccessorString == lcfirst($modelClassName)) {
$values = array();
foreach ($model as $relatedModel) {
$values[] = strval($relatedModel);
}
return ArrayUtil::stringify($values);
}
}
return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params);
} else {
$attributeType = ModelAttributeToMixedTypeUtil::getType($model, $attributeName);
//We don't have any accessor operator after the attributeName e.g. its the last in list
if ($attributeName === $attributeAccessorString) {
$content = static::getAttributeValue($model, $attributeName, $timeQualifier);
if ($attributeType == 'DateTime') {
$content .= ' GMT';
}
return $content;
} else {
//.........这里部分代码省略.........
示例4: stringifyOneToManyRelatedModelsValues
/**
* Given an array of data, create stringified content. Method is extended to provide support for translating
* the data into the correct language.
* (non-PHPdoc)
* @see RedBeanModel::stringifyOneToManyRelatedModelsValues()
*/
public function stringifyOneToManyRelatedModelsValues($values)
{
assert('is_array($values)');
$dataAndLabels = CustomFieldDataUtil::getDataIndexedByDataAndTranslatedLabelsByLanguage($this->data, Yii::app()->language);
foreach ($values as $key => $value) {
if (ArrayUtil::getArrayValue($dataAndLabels, $value) != null) {
$values[$key] = ArrayUtil::getArrayValue($dataAndLabels, $value);
}
}
return ArrayUtil::stringify($values);
}