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


PHP Content::getFieldValue方法代碼示例

本文整理匯總了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"));
 }
開發者ID:dfritschy,項目名稱:ezpublish-kernel,代碼行數:32,代碼來源:NonRedundantFieldSetTest.php

示例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);
 }
開發者ID:brookinsconsulting,項目名稱:ezecosystem,代碼行數:16,代碼來源:UserStub.php

示例3: testPublishedName

 /**
  * @depends testPublishContent
  */
 public function testPublishedName(Content $content)
 {
     $this->assertEquals($content->getFieldValue('name') . ' ' . $this->getFieldName(), $content->contentInfo->name);
 }
開發者ID:emodric,項目名稱:ezpublish-kernel,代碼行數:7,代碼來源:BaseIntegrationTest.php

示例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;
 }
開發者ID:krzyraj,項目名稱:EzSystemsRecommendationBundle,代碼行數:18,代碼來源:ContentController.php

示例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;
 }
開發者ID:sdaoudi,項目名稱:EzSystemsRecommendationBundle,代碼行數:22,代碼來源:Value.php

示例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);
 }
開發者ID:intermundiasolutions,項目名稱:CjwPublishToolsBundle,代碼行數:101,代碼來源:FormBuilderService.php


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