@param IContentHolder $holder
@param string $contentType

@return IHttpData
170009
public function createDataForContentType(IContentHolder $holder, $contentType) {
        $parts = $this->parseContentType($contentType);

        foreach ($parts as $part) {
            $class = array_get($this->getMappings(), $part);

            if ($class !== null) {
                break;
            }
        }

        if ($class === null) {
            $class = $this->getDefaultDataClass();
        }

        return new $class($holder);
    }
914338
public static function setContentType($contentType, $encoding = null) {
		$value = $contentType;
		if (isset ( $encoding ))
			$value .= ' ;charset=' . $encoding;
		self::header ( 'Content-Type', $value );
	}
102142
public Response andContentType(String contentType) {
        Objects.requireNonNull(contentType, Required.CONTENT_TYPE.toString());
        this.contentType = contentType;
        this.headers.put(Header.CONTENT_TYPE.toHttpString(), contentType);

        return this;
    }
1279266
public function updateContentTypeGroup(
        ContentTypeGroupUpdateData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: sprintf('update-content-type-group-%d', $data->getContentTypeGroup()->id);

        return $this->formFactory->createNamed($name, ContentTypeGroupUpdateType::class, $data);
    }
1248539
private function addContentType(MenuEntry $contentRoot, $contentTypeKey, Bag $contentType)
    {
        $icon = $contentType->get('singleton') ? $contentType->get('icon_one') : $contentType->get('icon_many');

        // Named ContentType root
        $contentTypeEntry = $contentRoot->add(
            MenuEntry::create($contentTypeKey)
                ->setRoute('overview', ['contenttypeslug' => $contentTypeKey])
                ->setLabel($contentType->get('name'))
                ->setIcon($icon)
                ->setPermission('contenttype:' . $contentTypeKey)
        );
        // View
        $contentTypeEntry->add(
            MenuEntry::create('view')
                ->setRoute('overview', ['contenttypeslug' => $contentTypeKey])
                ->setLabel(Trans::__('contenttypes.generic.view', ['%contenttypes%' => $contentType->get('name')]))
                ->setIcon($contentType->get('icon_many', 'fa:files-o'))
                ->setPermission('contenttype:' . $contentTypeKey)
        );
        // New
        $contentTypeEntry->add(
            MenuEntry::create('new')
                ->setRoute('editcontent', ['contenttypeslug' => $contentTypeKey])
                ->setLabel(Trans::__('contenttypes.generic.new', ['%contenttype%' => $contentType->get('singular_name')]))
                ->setIcon('fa:plus')
                ->setPermission('contenttype:' . $contentTypeKey . ':create')
        );
    }
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);
        }
    }
124000
public function getContent(?string $contentType = null, ?string $contentKey = null): Core\ViewResource
    {
        return new Core\ViewResource($this->_getContent(@$this->content[$contentType][$contentKey]));
    }
1277073
private function prepareFields(ApiContentType $contentType, $fields = null)
    {
        if ($fields !== null) {
            if (strpos($fields, ',') !== false) {
                return explode(',', $fields);
            }

            return array($fields);
        }

        $fields = array();
        $contentFields = $contentType->getFieldDefinitions();

        foreach ($contentFields as $field) {
            $fields[] = $field->identifier;
        }

        return $fields;
    }
1035899
protected function getConfigForContentType(ContentType $contentType)
    {
        if ($this->hasConfigForContentType($contentType)) {
            return $this->config['override_by_type'][$contentType->identifier];
        }

        return [];
    }
371741
public function deleteContentTypeDraft($contentTypeId)
    {
        $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);
        $this->contentTypeService->deleteContentType($contentTypeDraft);

        return new Values\NoContent();
    }
35867
public function createContentTypeDraft($contentTypeId, Request $request)
    {
        $contentType = $this->contentTypeService->loadContentType($contentTypeId);

        try {
            $contentTypeDraft = $this->contentTypeService->createContentTypeDraft(
                $contentType
            );
        } catch (BadStateException $e) {
            throw new ForbiddenException($e->getMessage());
        }

        $contentTypeUpdateStruct = $this->inputDispatcher->parse(
            new Message(
                array(
                    'Content-Type' => $request->headers->get('Content-Type'),
                ),
                $request->getContent()
            )
        );

        try {
            $this->contentTypeService->updateContentTypeDraft(
                $contentTypeDraft,
                $contentTypeUpdateStruct
            );
        } catch (InvalidArgumentException $e) {
            throw new ForbiddenException($e->getMessage());
        }

        return new Values\CreatedContentType(
            array(
                'contentType' => new Values\RestContentType(
                    // Reload the content type draft to get the updated values
                    $this->contentTypeService->loadContentTypeDraft(
                        $contentTypeDraft->id
                    )
                ),
            )
        );
    }
571835
public function encode(array $data, string $contentType): string
    {
        if (isset($this->encoderTypes[$contentType])) {
            return $this->encoderTypes[$contentType]->encode($data);
        }

        throw SerializerLogicException::createMissingContentType($contentType);
    }
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];
    }
500628
public function deletePayload($data = null, $contentType = "text/plain")
    {
        $this->addRequestHeader("Content-Type", $contentType);
        return $this->delete($data);
    }
1351530
public function get(UrlContract $url, $contentType = null)
    {
        $headers = $this->buildHeaders($contentType);
        $response = $this->con($url)->send('GET', $headers);
        return $this->configure($response, $contentType);
    }
1308710
private function getAuthor(ApiContent $contentValue, ApiContentType $contentType)
    {
        $author = $contentValue->getFieldValue(
            $this->value->getConfiguredFieldIdentifier('author', $contentType)
        );

        if (null === $author) {
            try {
                $ownerId = empty($contentValue->contentInfo->ownerId) ? $this->defaultAuthorId : $contentValue->contentInfo->ownerId;
                $userContentInfo = $this->contentService->loadContentInfo($ownerId);
                $author = $userContentInfo->name;
            } catch (UnauthorizedException $e) {
                $author = '';
            }
        }

        return (string) $author;
    }
1354484
private function detachContentTypeGroupsByIdentifiers(ContentType $contentType, array $contentTypeGroupsIdentifiers)
    {
        $contentTypeGroups = $this->loadContentTypeGroupsByIdentifiers($contentTypeGroupsIdentifiers);
        foreach ($contentTypeGroups as $contentTypeGroup) {
            $this->contentTypeService->unassignContentTypeGroup($contentType, $contentTypeGroup);
        }
    }