当前位置: 首页>>代码示例>>PHP>>正文


PHP Content::getFields方法代码示例

本文整理汇总了PHP中eZ\Publish\API\Repository\Values\Content\Content::getFields方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::getFields方法的具体用法?PHP Content::getFields怎么用?PHP Content::getFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZ\Publish\API\Repository\Values\Content\Content的用法示例。


在下文中一共展示了Content::getFields方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findFieldInContent

 /**
  * Finds the field with id $fieldId in $content.
  *
  * @param int $fieldId
  * @param Content $content
  *
  * @return Field
  */
 protected function findFieldInContent($fieldId, Content $content)
 {
     foreach ($content->getFields() as $field) {
         if ($field->id == $fieldId) {
             return $field;
         }
     }
     throw new InvalidArgumentException("Field with id {$fieldId} not found in Content with id {$content->id}");
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:17,代码来源:DownloadRedirectionController.php

示例2: castContent

 public function castContent(Content $content, array $a, Stub $stub, $isNested, $filter = 0)
 {
     $info = $content->contentInfo;
     $a = [Caster::PREFIX_VIRTUAL . 'id' => $info->id, Caster::PREFIX_VIRTUAL . 'name' => $info->name] + $a;
     if (!$filter & Caster::EXCLUDE_VERBOSE) {
         $groupedFields = [];
         foreach ($content->getFields() as $field) {
             $groupedFields[$field->languageCode][$field->fieldDefIdentifier] = $field->value;
         }
         $a += [Caster::PREFIX_VIRTUAL . 'names' => $content->versionInfo->getNames(), Caster::PREFIX_VIRTUAL . 'contentInfo' => $info, Caster::PREFIX_VIRTUAL . 'fields' => $groupedFields];
     }
     return $a;
 }
开发者ID:lolautruche,项目名称:ezsh,代码行数:13,代码来源:EzCaster.php

示例3: getFields

 /**
  * This method returns the complete fields collection
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Field[]
  */
 public function getFields()
 {
     return $this->content->getFields();
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:9,代码来源:UserStub.php

示例4: assertCopyContentValues

 /**
  * Asserts that $copiedContent is valid copy of $originalContent.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $originalContent
  * @param \eZ\Publish\API\Repository\Values\Content\Content $copiedContent
  */
 protected function assertCopyContentValues(APIContent $originalContent, APIContent $copiedContent)
 {
     $this->assertNotEquals($originalContent->id, $copiedContent->id, 'Id of content copy is equal to id od original content');
     $this->assertSameClassPropertiesCorrect(array('contentTypeId', 'sectionId', 'published', 'ownerId', 'alwaysAvailable', 'mainLanguageCode'), $originalContent->contentInfo, $copiedContent->contentInfo);
     $this->assertNotEquals($originalContent->contentInfo->id, $copiedContent->contentInfo->id);
     $this->assertNotEquals($originalContent->contentInfo->remoteId, $copiedContent->contentInfo->remoteId);
     $this->assertSameClassPropertiesCorrect(array('versionNo', 'names', 'creatorId', 'initialLanguageCode', 'languageCodes'), $originalContent->versionInfo, $copiedContent->versionInfo);
     $this->assertNotEquals($originalContent->versionInfo->id, $copiedContent->versionInfo->id);
     $originalFields = $originalContent->getFields();
     $copiedFields = $copiedContent->getFields();
     $this->assertCount(count($originalFields), $copiedFields, 'Count of fields copied does not match the count of original fields');
     foreach ($originalFields as $fieldIndex => $originalField) {
         $this->assertSameClassPropertiesCorrect(array('fieldDefIdentifier', 'value', 'languageCode'), $originalField, $copiedFields[$fieldIndex]);
         $this->assertNotEquals($originalField->id, $copiedFields[$fieldIndex]->id);
     }
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:22,代码来源:ContentBase.php

示例5: assertFieldIds

 protected function assertFieldIds(Content $content1, Content $content2)
 {
     $fields1 = $this->mapFields($content1->getFields());
     $fields2 = $this->mapFields($content2->getFields());
     foreach ($fields1 as $fieldDefinitionIdentifier => $languageFieldIds) {
         foreach ($languageFieldIds as $languageCode => $fieldId) {
             $this->assertEquals($fields2[$fieldDefinitionIdentifier][$languageCode], $fieldId);
         }
     }
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:10,代码来源:NonRedundantFieldSetTest.php

示例6: testUpdateContentSetsExpectedFields

 /**
  * Test for the updateContent() method.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  *
  * @return void
  * @see \eZ\Publish\API\Repository\ContentService::updateContent()
  * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent
  */
 public function testUpdateContentSetsExpectedFields($content)
 {
     $actual = $this->normalizeFields($content->getFields());
     $expected = array(new Field(array('id' => 0, 'value' => true, 'languageCode' => 'eng-GB', 'fieldDefIdentifier' => 'description')), new Field(array('id' => 0, 'value' => true, 'languageCode' => 'eng-US', 'fieldDefIdentifier' => 'description')), new Field(array('id' => 0, 'value' => true, 'languageCode' => 'eng-GB', 'fieldDefIdentifier' => 'name')), new Field(array('id' => 0, 'value' => true, 'languageCode' => 'eng-US', 'fieldDefIdentifier' => 'name')));
     $this->assertEquals($expected, $actual);
 }
开发者ID:Jenkosama,项目名称:ezpublish-kernel,代码行数:15,代码来源:ContentServiceTest.php

示例7: assertCopyContentValues

 /**
  * Asserts that $copiedContent is valid copy of $originalContent
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $originalContent
  * @param \eZ\Publish\API\Repository\Values\Content\Content $copiedContent
  */
 protected function assertCopyContentValues(APIContent $originalContent, APIContent $copiedContent)
 {
     $this->assertNotEquals($originalContent->id, $copiedContent->id, "Id of content copy is equal to id od original content");
     $this->assertSameClassPropertiesCorrect(array("contentTypeId", "sectionId", "published", "ownerId", "alwaysAvailable", "mainLanguageCode"), $originalContent->contentInfo, $copiedContent->contentInfo);
     $this->assertNotEquals($originalContent->contentInfo->id, $copiedContent->contentInfo->id);
     $this->assertNotEquals($originalContent->contentInfo->remoteId, $copiedContent->contentInfo->remoteId);
     $this->assertSameClassPropertiesCorrect(array("versionNo", "names", "creatorId", "initialLanguageCode", "languageCodes"), $originalContent->versionInfo, $copiedContent->versionInfo);
     $this->assertNotEquals($originalContent->versionInfo->id, $copiedContent->versionInfo->id);
     $originalFields = $originalContent->getFields();
     $copiedFields = $copiedContent->getFields();
     $this->assertCount(count($originalFields), $copiedFields, "Count of fields copied does not match the count of original fields");
     foreach ($originalFields as $fieldIndex => $originalField) {
         $this->assertSameClassPropertiesCorrect(array("fieldDefIdentifier", "value", "languageCode"), $originalField, $copiedFields[$fieldIndex]);
         $this->assertNotEquals($originalField->id, $copiedFields[$fieldIndex]->id);
     }
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:22,代码来源:ContentBase.php

示例8: filterFieldsByLanguages

 /**
  * Creates a filtered version of <b>$content</b> when the given <b>$languages</b>
  * is not <b>NULL</b> and not empty. The returned Content instance will only
  * contain fields for the given language codes.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param string[] $languageCodes
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Content
  */
 private function filterFieldsByLanguages(Content $content, array $languageCodes = null)
 {
     $contentType = $this->repository->getContentTypeService()->loadContentType($content->contentTypeId);
     $fieldDefinitions = $contentType->getFieldDefinitions();
     foreach ($content->getFields() as $field) {
         foreach ($fieldDefinitions as $fieldDefinition) {
             if ($fieldDefinition->identifier === $field->fieldDefIdentifier) {
                 // @todo: Refactor out of here for clarity!
                 $this->pseudoExternalStorage->handleLoad($fieldDefinition, $field, $content);
             }
         }
     }
     if (empty($languageCodes)) {
         return $content;
     }
     $fields = array();
     foreach ($content->getFields() as $field) {
         if (false === $contentType->getFieldDefinition($field->fieldDefIdentifier)->isTranslatable) {
             $fields[] = $field;
         } else {
             if (in_array($field->languageCode, $languageCodes)) {
                 $fields[] = $field;
             }
         }
     }
     return $this->copyContentObject($content, array('fields' => $fields));
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:37,代码来源:ContentServiceStub.php


注:本文中的eZ\Publish\API\Repository\Values\Content\Content::getFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。