本文整理汇总了PHP中eZ\Publish\API\Repository\Values\Content\Content::getFieldValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::getFieldValue方法的具体用法?PHP Content::getFieldValue怎么用?PHP Content::getFieldValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\API\Repository\Values\Content\Content
的用法示例。
在下文中一共展示了Content::getFieldValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdateContentWithTwoLanguagesInitialLanguageTranslationNotCreatedFields
/**
* Test for the updateContent() method.
*
* @see \eZ\Publish\API\Repository\ContentService::updateContent()
* @depends eZ\Publish\API\Repository\Tests\NonRedundantFieldSetTest::testUpdateContentWithTwoLanguagesInitialLanguageTranslationNotCreated
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
*/
public function testUpdateContentWithTwoLanguagesInitialLanguageTranslationNotCreatedFields(Content $content)
{
$emptyValue = $this->getRepository()->getFieldTypeService()->getFieldType("ezstring")->getEmptyValue();
$this->assertCount(3, $content->versionInfo->languageCodes);
$this->assertContains("ger-DE", $content->versionInfo->languageCodes);
$this->assertContains("eng-US", $content->versionInfo->languageCodes);
$this->assertContains("eng-GB", $content->versionInfo->languageCodes);
$this->assertCount(12, $content->getFields());
// eng-US
$this->assertEquals($emptyValue, $content->getFieldValue("field1", "eng-US"));
$this->assertEquals($emptyValue, $content->getFieldValue("field2", "eng-US"));
$this->assertEquals("value 3", $content->getFieldValue("field3", "eng-US"));
$this->assertEquals("value 4", $content->getFieldValue("field4", "eng-US"));
// eng-GB
$this->assertEquals($emptyValue, $content->getFieldValue("field1", "eng-GB"));
$this->assertEquals($emptyValue, $content->getFieldValue("field2", "eng-GB"));
$this->assertEquals("value 3 eng-GB", $content->getFieldValue("field3", "eng-GB"));
$this->assertEquals("value 4 eng-GB", $content->getFieldValue("field4", "eng-GB"));
// ger-DE
$this->assertEquals($emptyValue, $content->getFieldValue("field1", "ger-DE"));
$this->assertEquals($emptyValue, $content->getFieldValue("field2", "ger-DE"));
$this->assertEquals($emptyValue, $content->getFieldValue("field3", "ger-DE"));
$this->assertEquals($emptyValue, $content->getFieldValue("field4", "ger-DE"));
}
示例2: getFieldValue
/**
* Returns a field value for the given value
* $version->fields[$fieldDefId][$languageCode] is an equivalent call
* if no language is given on a translatable field this method returns
* the value of the initial language of the version if present, otherwise null.
* On non translatable fields this method ignores the languageCode parameter.
*
* @param string $fieldDefIdentifier
* @param string $languageCode
*
* @return mixed a primitive type or a field type Value object depending on the field type.
*/
public function getFieldValue($fieldDefIdentifier, $languageCode = null)
{
return $this->content->getFieldValue($fieldDefIdentifier, $languageCode);
}
示例3: testPublishedName
/**
* @depends testPublishContent
*/
public function testPublishedName(Content $content)
{
$this->assertEquals($content->getFieldValue('name') . ' ' . $this->getFieldName(), $content->contentInfo->name);
}
示例4: getAuthor
/**
* Returns author of the content.
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $contentValue
* @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
*
* @return string
*/
private function getAuthor(Content $contentValue, ContentType $contentType)
{
$author = $contentValue->getFieldValue($this->value->getConfiguredFieldIdentifier('author', $contentType));
if (null === $author) {
$ownerId = empty($contentValue->contentInfo->ownerId) ? $this->defaultAuthorId : $contentValue->contentInfo->ownerId;
$userContentInfo = $this->contentService->loadContentInfo($ownerId);
$author = $userContentInfo->name;
}
return (string) $author;
}
示例5: getRelation
/**
* Checks if content has image relation field, returns its ID if true.
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
* @param string $field
* @param string $language
*
* @return int|null
*/
private function getRelation(Content $content, $field, $language)
{
$fieldDefinitions = $this->getFieldDefinitionList();
$fieldNames = array_flip($fieldDefinitions);
$isRelation = in_array('ezobjectrelation', $fieldDefinitions) && $field == $fieldNames['ezobjectrelation'];
if ($isRelation && $field == $fieldNames['ezobjectrelation']) {
$fieldValue = $content->getFieldValue($fieldNames['ezobjectrelation'], $language);
if (isset($fieldValue->destinationContentId)) {
return $fieldValue->destinationContentId;
}
}
return null;
}
示例6: getFormSchemaFromContentObjectFields
//.........这里部分代码省略.........
break;
case 'ezemail':
$formFieldIdentifier = 'ezemail' . FormHandlerService::separator . $field->identifier;
$fieldArr['type'] = 'email';
$fieldArr['value'] = $field->defaultValue->email;
break;
case 'ezboolean':
$formFieldIdentifier = 'ezxmltext' . FormHandlerService::separator . $field->identifier;
$fieldArr['type'] = 'checkbox';
$fieldArr['value'] = $field->defaultValue->bool;
break;
case 'ezuser':
// ToDo: many
$formFieldIdentifier = 'ezuser' . FormHandlerService::separator . $field->identifier . FormHandlerService::separator . 'login';
$fieldArr['type'] = 'text';
$fieldArr['label'] = 'cjw_publishtools.formbuilder.user.login';
$fieldArr['value'] = '';
$fieldArr1 = array();
$fieldArr1['type'] = 'email';
$fieldArr1['label'] = 'cjw_publishtools.formbuilder.user.email';
$fieldArr1['required'] = true;
$formFieldIdentifier1 = 'ezuser' . FormHandlerService::separator . $field->identifier . FormHandlerService::separator . 'email';
$fieldArr1['value'] = '';
$fieldArr1['choices'] = false;
$fieldArr2 = array();
$fieldArr2['type'] = 'password';
$fieldArr2['label'] = 'cjw_publishtools.formbuilder.user.password';
$fieldArr2['required'] = true;
$formFieldIdentifier2 = 'ezuser' . FormHandlerService::separator . $field->identifier . FormHandlerService::separator . 'password';
$fieldArr2['value'] = '';
$fieldArr2['choices'] = false;
break;
// ToDo: multiple / single, select / radio / checkbox, etc.
// ToDo: multiple / single, select / radio / checkbox, etc.
case 'ezselection':
$formFieldIdentifier = 'ezselection' . FormHandlerService::separator . $field->identifier;
$fieldArr['type'] = 'choice';
$fieldArr['choices'] = array();
// Translate choices, which aren't translatable in eZ BackEnd
foreach ($field->fieldSettings['options'] as $fieldChoiceKey => $fieldChoice) {
$fieldArr['choices'][$fieldChoiceKey] = $this->container->get('translator')->trans($fieldChoice);
}
// http://stackoverflow.com/questions/17314996/symfony2-array-to-string-conversion-error
if ($field->fieldSettings['isMultiple']) {
$fieldArr['multiple'] = true;
$fieldArr['value'] = $field->defaultValue->selection;
} else {
$fieldArr['multiple'] = false;
$fieldArr['value'] = false;
if (isset($field->defaultValue->selection['0'])) {
$fieldArr['value'] = $field->defaultValue->selection['0'];
}
}
break;
default:
$formFieldIdentifier = 'default' . FormHandlerService::separator . $field->identifier;
$fieldArr['type'] = 'text';
$fieldArr['value'] = '';
}
// build / set entity array dynamicaly from fieldtype
if ($content) {
$formFieldIdentifierArr = explode(':', $formFieldIdentifier);
switch ($formFieldIdentifierArr['0']) {
case 'ezuser':
$userValue = $content->getFieldValue($field->identifier);
$fieldArr['value'] = $userValue->login;
$fieldArr1['value'] = $userValue->email;
break;
default:
switch ($fieldArr['type']) {
case 'choice':
// http://stackoverflow.com/questions/17314996/symfony2-array-to-string-conversion-error
if ($fieldArr['multiple']) {
$fieldArr['value'] = $content->getFieldValue($field->identifier)->selection;
} else {
$fieldArr['value'] = $content->getFieldValue($field->identifier)->selection['0'];
}
break;
default:
if (isset($content->getFieldValue($field->identifier)->text)) {
$fieldArr['value'] = $content->getFieldValue($field->identifier)->text;
}
}
}
}
$formValueArr[$formFieldIdentifier] = $fieldArr['value'];
$formSchemaArr[$formFieldIdentifier] = $fieldArr;
if ($fieldArr1 !== false) {
$formValueArr[$formFieldIdentifier1] = $fieldArr1['value'];
$formSchemaArr[$formFieldIdentifier1] = $fieldArr1;
}
if ($fieldArr2 !== false) {
$formValueArr[$formFieldIdentifier2] = $fieldArr2['value'];
$formSchemaArr[$formFieldIdentifier2] = $fieldArr2;
}
}
}
}
return array($formSchemaArr, $formValueArr);
}