@param ContentTypeInterface $contentType

@return array
162922
protected function extractKeywordsFromContentType(ContentTypeInterface $contentType)
    {
        $keywordIds = array();
        $fields = $contentType->getFields();

        foreach ($fields as $field) {
            $fieldOptions = $field->getOptions();
            foreach ($fieldOptions as $option) {
                if ($this->isKeywordsConditionAttribute($option->getValue())) {
                    $keywordIds = array_merge(
                        $keywordIds,
                        $this->extractKeywordIdsFromConditionAttribute($option->getValue())
                    );
                }
            }
        }

        return $keywordIds;
    }
511426
private function selectContentTypeHeader($contentType)
    {
        if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) {
            return 'application/json';
        } elseif (preg_grep("/application\/json/i", $contentType)) {
            return 'application/json';
        } else {
            return implode(',', $contentType);
        }
    }
90441
public function hasFieldType(ContentType $contentType, string $fieldTypeIdentifier): bool
    {
        foreach ($contentType->getFieldDefinitions() as $fieldDefinition) {
            if ($fieldDefinition->fieldTypeIdentifier === $fieldTypeIdentifier) {
                return true;
            }
        }

        return false;
    }
564040
public function getChangedFields(array $contentType)
    {
        $changedFields = [];

        if (empty($this->diff)) {
            return $changedFields;
        }

        // Get the ContentType that we're dealing with
        $fields = $contentType['fields'];

        $hash = [
            'html'        => 'fieldText',
            'markdown'    => 'fieldText',
            'textarea'    => 'fieldText',
            'filelist'    => 'fieldList',
            'imagelist'   => 'fieldList',
            'geolocation' => 'fieldGeolocation',
            'image'       => 'fieldImage',
            'embed'       => 'fieldVideo',
            'select'      => 'fieldSelect',
            'video'       => 'fieldVideo',
        ];

        foreach ($this->diff as $key => $value) {
            if (!isset($fields[$key])) {
                continue;
            }

            $type = $fields[$key]['type'];
            $changedFields[$key] = [
                'type'   => $type,
                'label'  => empty($fields[$key]['label']) ? $key : $fields[$key]['label'],
                'before' => [
                    'raw'    => $value[0],
                    'render' => $value[0],
                ],
                'after'  => [
                    'raw'    => $value[1],
                    'render' => $value[1],
                ],
            ];

            /** @var string $type */
            $type = $fields[$key]['type'];
            if (isset($hash[$type])) {
                $func = $hash[$type];
                $changedFields[$key] = array_merge($changedFields[$key], $this->{$func}($key, $value, $fields));
            }
        }

        return $changedFields;
    }
712448
public function setContentType(string $contentType): SetContentTypeHandlerInterface
    {
        $this->contentType = $this->normalizeContentType($contentType);
        return $this;
    }
610058
static public function contentTypeToSuffix($contentType)
    {
        $types = self::byContentType();
        return isset($types[$contentType]) ? $types[$contentType]['suffix'] : null;
    }
1223519
public function loadContentType($contentTypeId)
    {
        $contentType = $this->contentTypeService->loadContentType($contentTypeId, Language::ALL);

        return new Values\RestContentType(
            $contentType,
            $contentType->getFieldDefinitions()
        );
    }
118150
public function getContentTypeDefinition($contentTypeName)
    {
        if ($this->getConfiguration()->hasContentType($contentTypeName))
        {
            $cacheKey = '[cmdl][content][' . $contentTypeName . ']';
            if ($this->repository)
            {
                $cacheKey = '[' . $this->repository->getName() . ']' . $cacheKey;
            }

            if ($this->cmdlCachingCheckLastModifiedDate)
            {
                $cacheKey .= '[' . $this->getCMDLLastModifiedDate($contentTypeName) . ']';
            }

            if ($this->getCMDLCache()->contains($cacheKey))
            {
                return unserialize($this->getCMDLCache()->fetch($cacheKey));
            }

            $cmdl = $this->getCMDLForContentType($contentTypeName);

            if ($cmdl)
            {

                $parser = $this->getParser();

                $definition = $parser->parseCMDLString($cmdl, $contentTypeName);

                if ($definition)
                {
                    $this->contentTypeDefinitions[$contentTypeName]['definition'] = $definition;
                    $this->getCMDLCache()->save($cacheKey, serialize($definition), (int)$this->cmdlCaching);

                    return $definition;
                }
            }

        }

        throw new AnyContentClientException ('Unknown content type ' . $contentTypeName);
    }
90473
public function setContentType($contentType)
    {
        $this->contentType = $contentType;

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

        return $this;
    }
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;
    }
1289585
public function getConfig($contentType)
    {
        if (array_key_exists($contentType, $this->searchableTypes)) {
            return $this->searchableTypes[$contentType];
        }

        if ($this->canSearchInvisible() && array_key_exists($contentType, $this->invisibleTypes)) {
            return $this->invisibleTypes[$contentType];
        }

        return false;
    }
432428
public function decode($content, $contentType)
    {
        $converter = $this->getConverter($contentType);

        return $converter->decode($content);
    }
498553
public function setContentType($contentType = '')
    {
        $this->contentType = $contentType;
        $this->debug->debug(__FUNCTION__, 'setContentType: ', $this->contentType);
    }
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);
    }
662727
private function getTemplateFieldTemplates(ContentType $contentType, Content $content)
    {
        $templateFieldTemplates = [];
        $templateFieldsConfig = $this->config->get('theme/templatefields');

        if ($templateFieldsConfig) {
            $templateFieldTemplates = array_keys($templateFieldsConfig);
            // Special case for default template
            $toRepair = [];
            foreach ($contentType['fields'] as $name => $field) {
                if ($field['type'] === 'templateselect' && !empty($content->values[$name])) {
                    $toRepair[$name] = $content->values[$name];
                    $content->set($name, '');
                }
            }
            if ($content->hasTemplateFields()) {
                $templateFieldTemplates[] = '';
            }

            foreach ($toRepair as $name => $value) {
                $content->set($name, $value);
            }
        }

        return $templateFieldTemplates;
    }
665258
public function supports(string $contentType): bool
    {
        foreach (array_keys($this->types) as $pattern) {
            $pattern = str_replace(['*', '.', '/', '+'], ['(.*)', '.', '\/', '\+'], $pattern);
            if (preg_match("#^$pattern$#i", $contentType) > 0) {
                return true;
            }
        }
        return false;
    }
48623
public function getListingData(array $contenttype, $contentId, array $queryOptions)
    {
        // We have a content type, and possibly a content ID.
        $content = null;

        if ($contentId) {
            $content = $this->app['storage']->getContent($contenttype['slug'], ['id' => $contentId, 'hydrate' => false]);
            $queryOptions['contentid'] = $contentId;
        }

        // Getting a slice of data and the total count
        $logEntries = $this->changeRepository->getChangeLogByContentType($contenttype['slug'], $queryOptions);
        $itemCount = $this->changeRepository->countChangeLogByContentType($contenttype['slug'], $queryOptions);

        // The page title we're sending to the template depends on a few things:
        // If no contentid is given, we'll use the plural form of the content
        // type; otherwise, we'll derive it from the changelog or content item
        // itself.
        if ($contentId) {
            if ($content) {
                // content item is available: get the current title
                $title = $content->getTitle();
            } else {
                // content item does not exist (anymore).
                if (empty($logEntries)) {
                    // No item, no entries - phew. Content type name and ID
                    // will have to do.
                    $title = $contenttype['singular_name'] . ' #' . $contentId;
                } else {
                    // No item, but we can use the most recent title.
                    $title = $logEntries[0]['title'];
                }
            }
        } else {
            // We're displaying all changes for the entire content type,
            // so the plural name is most appropriate.
            $title = $contenttype['name'];
        }

        return ['content' => $content, 'title' => $title, 'entries' => $logEntries, 'count' => $itemCount];
    }