@param string               $language
@param ContentTypeInterface $contentType

@return array
482083
protected function getMappingContentType($language, ContentTypeInterface $contentType)
    {
        $mapping = array(
            'name' => 'name',
            'status_label' => 'status.labels.' . $language,
            'linked_to_site' => 'linkedToSite',
            'created_at' => 'createdAt',
            'created_by' => 'createdBy',
            'updated_at' => 'updatedAt',
            'updated_by' => 'updatedBy',
        );
        foreach ($contentType->getDefaultListable() as $column => $isListable) {
            if (!$isListable) {
                unset($mapping[$column]);
            }
        }
        foreach ($contentType->getFields() as $field) {
            $mapping['fields.' . $field->getFieldId() . '.string_value'] = 'attributes.' . $field->getFieldId() . '.stringValue';
        }

        return $mapping;
    }
90473
public function setContentType($contentType)
    {
        $this->contentType = $contentType;

        $this->setHeader('Content-Type', $contentType . '; charset=' . $this->getCharset());

        return $this;
    }
71274
private function getContentTypeGroupsNumbers(array $contentTypeGroups): array
    {
        $contentTypeGroupsNumbers = array_column($contentTypeGroups, 'id');

        return array_combine($contentTypeGroupsNumbers, array_fill_keys($contentTypeGroupsNumbers, false));
    }
51126
public function loadFromContentType(ContentType $contentType): self
    {
        $languages = [];
        foreach ($contentType->languageCodes as $languageCode) {
            $languages[] = $this->languageService->loadLanguage($languageCode);
        }

        $this->data = array_map(
            function (Language $language) use ($contentType) {
                return $this->valueFactory->createLanguageFromContentType($language, $contentType);
            },
            $languages
        );

        return $this;
    }
39327
private function internalLoadContent(array $contentIds, int $version = null, array $translations = null): array
    {
        $queryBuilder = $this->connection->createQueryBuilder();
        $expr = $queryBuilder->expr();
        $queryBuilder
            ->select(
                'c.id AS ezcontentobject_id',
                'c.contentclass_id AS ezcontentobject_contentclass_id',
                'c.section_id AS ezcontentobject_section_id',
                'c.owner_id AS ezcontentobject_owner_id',
                'c.remote_id AS ezcontentobject_remote_id',
                'c.current_version AS ezcontentobject_current_version',
                'c.initial_language_id AS ezcontentobject_initial_language_id',
                'c.modified AS ezcontentobject_modified',
                'c.published AS ezcontentobject_published',
                'c.status AS ezcontentobject_status',
                'c.name AS ezcontentobject_name',
                'c.language_mask AS ezcontentobject_language_mask',
                'c.is_hidden AS ezcontentobject_is_hidden',
                'v.id AS ezcontentobject_version_id',
                'v.version AS ezcontentobject_version_version',
                'v.modified AS ezcontentobject_version_modified',
                'v.creator_id AS ezcontentobject_version_creator_id',
                'v.created AS ezcontentobject_version_created',
                'v.status AS ezcontentobject_version_status',
                'v.language_mask AS ezcontentobject_version_language_mask',
                'v.initial_language_id AS ezcontentobject_version_initial_language_id',
                'a.id AS ezcontentobject_attribute_id',
                'a.contentclassattribute_id AS ezcontentobject_attribute_contentclassattribute_id',
                'a.data_type_string AS ezcontentobject_attribute_data_type_string',
                'a.language_code AS ezcontentobject_attribute_language_code',
                'a.language_id AS ezcontentobject_attribute_language_id',
                'a.data_float AS ezcontentobject_attribute_data_float',
                'a.data_int AS ezcontentobject_attribute_data_int',
                'a.data_text AS ezcontentobject_attribute_data_text',
                'a.sort_key_int AS ezcontentobject_attribute_sort_key_int',
                'a.sort_key_string AS ezcontentobject_attribute_sort_key_string',
                't.main_node_id AS ezcontentobject_tree_main_node_id'
            )
            ->from('ezcontentobject', 'c')
            ->innerJoin(
                'c',
                'ezcontentobject_version',
                'v',
                $expr->andX(
                    $expr->eq('c.id', 'v.contentobject_id'),
                    $expr->eq('v.version', $version ?? 'c.current_version')
                )
            )
            ->innerJoin(
                'v',
                'ezcontentobject_attribute',
                'a',
                $expr->andX(
                    $expr->eq('v.contentobject_id', 'a.contentobject_id'),
                    $expr->eq('v.version', 'a.version')
                )
            )
            ->leftJoin(
                'c',
                'ezcontentobject_tree',
                't',
                $expr->andX(
                    $expr->eq('c.id', 't.contentobject_id'),
                    $expr->eq('t.node_id', 't.main_node_id')
                )
            );

        $queryBuilder->where(
            $expr->in(
                'c.id',
                $queryBuilder->createNamedParameter($contentIds, Connection::PARAM_INT_ARRAY)
            )
        );

        if (!empty($translations)) {
            $queryBuilder->andWhere(
                $expr->in(
                    'a.language_code',
                    $queryBuilder->createNamedParameter($translations, Connection::PARAM_STR_ARRAY)
                )
            );
        }

        return $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE);
    }
620912
private function getContentTranslationSubdocuments(Content $content, $languageCode)
    {
        if ($this->contentTranslationSubdocumentMapper->accept($content, $languageCode)) {
            return $this->contentTranslationSubdocumentMapper->mapDocuments($content, $languageCode);
        }

        return [];
    }
46500
public function getChildren(Content $content, Language $language)
    {
        return $content->children()
            ->with(self::$loadRelations)
            ->where('published_at', '<=', Carbon::now())
            ->whereHas('routes', function ($query) use ($language) {
                $query->where('routes.is_active', true)
                    ->where('language_code', $language->code);
            })
            ->orderBy('is_promoted', 'DESC')
            ->orderBy('is_sticky', 'DESC')
            ->orderBy('weight', 'ASC')
            ->orderBy('published_at', 'DESC')
            ->paginate(option('general', 'default_page_size', 20));
    }
1029570
private function getNamesForAllLanguages(array $contentInfo)
    {
        $nameDataArray = $this->contentGateway->loadVersionedNameData([
            [
                'id' => $contentInfo['id'],
                'version' => $contentInfo['current_version'],
            ],
        ]);

        $namesForAllLanguages = [];
        foreach ($nameDataArray as $nameData) {
            $namesForAllLanguages[$nameData['ezcontentobject_name_content_translation']]
                = $nameData['ezcontentobject_name_name'];
        }

        return $namesForAllLanguages;
    }
601183
private function processContentType($contentType)
    {
        foreach (explode(';', $contentType) as $type) {
            $type = strtolower(trim($type));
            if (isset($this->supported_formats[$type])) {
                return $this->supported_formats[$type];
            }
        }

        return false;
    }
1321294
public function removeContentTypeTranslation(int $contentTypeId, string $languageCode): Type
    {
        $type = $this->load($contentTypeId, Type::STATUS_DRAFT);

        unset($type->name[$languageCode]);
        unset($type->description[$languageCode]);

        foreach ($type->fieldDefinitions as $fieldDefinition) {
            $this->contentTypeGateway->removeFieldDefinitionTranslation(
                $fieldDefinition->id,
                $languageCode,
                Type::STATUS_DRAFT
            );

            //Refresh FieldDefinition object after removing translation data.
            $fieldDefinition = $this->getFieldDefinition(
                $fieldDefinition->id,
                Type::STATUS_DRAFT
            );
            unset($fieldDefinition->name[$languageCode]);
            unset($fieldDefinition->description[$languageCode]);
            $storageFieldDefinition = new StorageFieldDefinition();
            $this->mapper->toStorageFieldDefinition($fieldDefinition, $storageFieldDefinition);
            $this->contentTypeGateway->updateFieldDefinition(
                $contentTypeId,
                Type::STATUS_DRAFT,
                $fieldDefinition,
                $storageFieldDefinition
            );
        }

        $updateStruct = $this->mapper->createUpdateStructFromType($type);

        return $this->update($type->id, Type::STATUS_DRAFT, $updateStruct);
    }
373030
public function encode($content, $contentType)
    {
        $converter = $this->getConverter($contentType);

        return $converter->encode($content);
    }
246618
public function getContentIdsByContentTypeId($contentTypeId)
    {
        $query = $this->dbHandler->createSelectQuery();
        $query
            ->select($this->dbHandler->quoteColumn('id'))
            ->from($this->dbHandler->quoteTable('ezcontentobject'))
            ->where(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('contentclass_id'),
                    $query->bindValue($contentTypeId, null, PDO::PARAM_INT)
                )
            );

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchAll(PDO::FETCH_COLUMN);
    }
609809
public function create(
        $contentTypes,
        $limit,
        $titleWords,
        $timeRange,
        $language = LanguageInterface::LANGCODE_NOT_SPECIFIED
    ) {
        $nodes = [];
        $bundles = $this->drupalApi->getBundles();
        for ($i = 0; $i < $limit; $i++) {
            try {
                $contentType = $contentTypes[array_rand($contentTypes)];
                $node = $this->entityTypeManager->getStorage('node')->create(
                    [
                        'nid' => null,
                        'type' => $contentType,
                        'created' => REQUEST_TIME - mt_rand(0, $timeRange),
                        'uid' => $this->getUserID(),
                        'title' => $this->getRandom()->sentences(mt_rand(1, $titleWords), true),
                        'revision' => mt_rand(0, 1),
                        'status' => true,
                        'promote' => mt_rand(0, 1),
                        'langcode' => $language
                    ]
                );

                $this->generateFieldSampleData($node);
                $node->save();
                $nodes['success'][] = [
                    'nid' => $node->id(),
                    'node_type' => $bundles[$contentType],
                    'title' => $node->getTitle(),
                    'created' => $this->dateFormatter->format(
                        $node->getCreatedTime(),
                        'custom',
                        'Y-m-d h:i:s'
                    )
                ];
            } catch (\Exception $error) {
                $nodes['error'][] = $error->getMessage();
            }
        }

        return $nodes;
    }
1011059
private function getImageFieldIdentifier($contentId, $language, $related = false)
    {
        $content = $this->contentService->loadContent($contentId);
        $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);

        $fieldDefinitions = $this->getFieldDefinitionList();
        $fieldNames = array_flip($fieldDefinitions);

        if (in_array('ezimage', $fieldDefinitions)) {
            return $fieldNames['ezimage'];
        } elseif (in_array('ezobjectrelation', $fieldDefinitions) && !$related) {
            $field = $content->getFieldValue($fieldNames['ezobjectrelation'], $language);

            if (!empty($field->destinationContentId)) {
                return $this->getImageFieldIdentifier($field->destinationContentId, $language, true);
            }
        } else {
            return $this->getConfiguredFieldIdentifier('image', $contentType);
        }
    }
1324329
public function decode(string $data, string $contentType): array
    {
        return $this->decoder->decode($data, $contentType);
    }
828024
private function attachContentTypeGroupsByIdentifiers(ContentType $contentType, array $contentTypeGroupsIdentifiers)
    {
        $contentTypeGroups = $this->loadContentTypeGroupsByIdentifiers($contentTypeGroupsIdentifiers);
        foreach ($contentTypeGroups as $contentTypeGroup) {
            $this->contentTypeService->assignContentTypeGroup($contentType, $contentTypeGroup);
        }
    }
624713
public function getContentTypeFields($contenttypeslug)
    {
        $contenttype = $this->getContentType($contenttypeslug);

        if (empty($contenttype['fields'])) {
            return [];
        } else {
            return array_keys($contenttype['fields']);
        }
    }