/** * Get field type information * * Returns an array in the form: * * <code> * array( * "content-type-identifier" => array( * "field-definition-identifier" => "field-type-identifier", * … * ), * … * ) * </code> * * @return array */ protected function getFieldMap() { $fieldTypes = []; foreach ($this->contentTypeHandler->loadAllGroups() as $group) { foreach ($this->contentTypeHandler->loadContentTypes($group->id) as $contentType) { foreach ($contentType->fieldDefinitions as $fieldDefinition) { if (!$fieldDefinition->isSearchable) { continue; } $fieldTypes[$contentType->identifier][$fieldDefinition->identifier] = $fieldDefinition->fieldType; } } } return $fieldTypes; }
/** * Get field type information for sort clause * * TODO: handle custom field * TODO: caching (see above) * * @param string $contentTypeIdentifier * @param string $fieldDefinitionIdentifier * @param string $languageCode * * @return array */ public function getSortFieldTypes($contentTypeIdentifier, $fieldDefinitionIdentifier, $languageCode) { $types = array(); foreach ($this->contentTypeHandler->loadAllGroups() as $group) { foreach ($this->contentTypeHandler->loadContentTypes($group->id) as $contentType) { if ($contentType->identifier !== $contentTypeIdentifier) { continue; } foreach ($contentType->fieldDefinitions as $fieldDefinition) { if ($fieldDefinition->identifier !== $fieldDefinitionIdentifier) { continue; } // TODO: find a better way to handle non-translatable fields? if ($languageCode === null || $fieldDefinition->isTranslatable) { $fieldType = $this->fieldRegistry->getType($fieldDefinition->fieldType); foreach ($fieldType->getIndexDefinition() as $name => $type) { $types[$type->type] = $this->nameGenerator->getTypedName($this->nameGenerator->getName($name, $fieldDefinition->identifier, $contentType->identifier), $type); } } break 3; } } } return $types; }
/** * Get Content Type objects which belong to the given content type group * * @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup * * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType[] Which have status DEFINED */ public function loadContentTypes(APIContentTypeGroup $contentTypeGroup) { $spiContentTypes = $this->contentTypeHandler->loadContentTypes($contentTypeGroup->id, SPIContentType::STATUS_DEFINED); $contentTypes = array(); foreach ($spiContentTypes as $spiContentType) { $contentTypes[] = $this->buildContentTypeDomainObject($spiContentType); } return $contentTypes; }
/** * Get Content Type objects which belong to the given content type group. * * @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup * * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType[] Which have status DEFINED */ public function loadContentTypes(APIContentTypeGroup $contentTypeGroup) { $spiContentTypes = $this->contentTypeHandler->loadContentTypes($contentTypeGroup->id, SPIContentType::STATUS_DEFINED); $contentTypes = array(); foreach ($spiContentTypes as $spiContentType) { $contentTypes[] = $this->contentTypeDomainMapper->buildContentTypeDomainObject($spiContentType, array_map(function ($id) { return $this->contentTypeHandler->loadGroup($id); }, $spiContentType->groupIds)); } return $contentTypes; }
/** * Get field type information * * Returns an array in the form: * * <code> * array( * "field-identifier" => array( * "solr_field_name", * … * ), * … * ) * </code> * * @param \eZ\Publish\API\Repository\Values\Content\Query\CustomFieldInterface $criterion * * @return array */ public function getFieldTypes(CustomFieldInterface $criterion) { // @TODO: temp fixed by disabling caching, see https://jira.ez.no/browse/EZP-22834 $this->fieldTypes = array(); foreach ($this->contentTypeHandler->loadAllGroups() as $group) { foreach ($this->contentTypeHandler->loadContentTypes($group->id) as $contentType) { foreach ($contentType->fieldDefinitions as $fieldDefinition) { if (!$fieldDefinition->isSearchable) { continue; } if ($customField = $criterion->getCustomField($contentType->identifier, $fieldDefinition->identifier)) { $this->fieldTypes[$fieldDefinition->identifier]["custom"][] = $customField; continue; } $fieldType = $this->fieldRegistry->getType($fieldDefinition->fieldType); foreach ($fieldType->getIndexDefinition() as $name => $type) { $this->fieldTypes[$fieldDefinition->identifier][$type->type][] = $this->nameGenerator->getTypedName($this->nameGenerator->getName($name, $fieldDefinition->identifier, $contentType->identifier), $type); } } } } return $this->fieldTypes; }
/** * @param mixed $groupId * @param int $status * @return Type[] */ public function loadContentTypes($groupId, $status = 0) { return $this->innerHandler->loadContentTypes($groupId, $status); }