Create a single ContentType entity.

@param Entity\Content $contentEntity
3042
private function fillEntity(Entity\Content $contentEntity)
    {
        $contentType = $this->repository->getEntityManager()->getContentType($contentEntity->getContenttype());

        foreach ($contentType['fields'] as $field => $values) {
            $this->setFieldValue($contentEntity, $contentType, $field, $values);
        }

        // After we initially filled the content object, we get the title to set the slug.
        $slug = Slugify::create()->slugify($contentEntity->getTitle());
        $contentEntity->set('slug', $slug);

        // Add taxonomy
        $this->setTaxonomyCollection($contentEntity, $contentType);

        // Save it
        $this->repository->save($contentEntity);

        $taxonomies = null;
        /** @var Entity\Taxonomy $taxonomy */
        foreach ($contentEntity->getTaxonomy()->toArray() as $taxonomy) {
            $type = $taxonomy->getTaxonomytype();
            $taxonomies[$type][] = $taxonomy->getName();
        }

        $this->createSummary[] = [
            'title'    => $contentEntity->getTitle(),
            'taxonomy' => $taxonomies,
        ];
    }
471190
protected function createResponse($content, $contentType)
    {
        $resp = new HttpResponse();

        $resp->setStatusCode(200)
             ->setContent($content);
        $resp->getHeaders()->addHeaders(array(
            'Content-Length'    => strlen($content),
            'Content-Type'      => $contentType
        ));
        return $resp;
    }
929948
public function setContentType($contentType)
    {
        $allowedValues = $this->getContentTypeAllowableValues();
        if (!is_null($contentType) && !in_array($contentType, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'contentType', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['contentType'] = $contentType;

        return $this;
    }
532999
private function createContentTypeGroupByIdentifier($contentTypeGroupIdentifier)
    {
        $contentTypeGroupCreateStruct = new ContentTypeGroupCreateStruct();
        $contentTypeGroupCreateStruct->identifier = $contentTypeGroupIdentifier;

        return $this->contentTypeService->createContentTypeGroup($contentTypeGroupCreateStruct);
    }
839019
private function doGetCollectionByContent($contentType, $contentUid)
    {
        $content = null;
        $classname = AbstractClassContent::getClassnameByContentType($contentType);
        $em = $this->getApplication()->getEntityManager();

        try {
            $content = $em->find($classname, $contentUid);
        } catch (ClassNotFoundException $e) {
            throw new NotFoundHttpException("No classcontent found with provided type (:$contentType)");
        }

        if (null === $content) {
            throw new NotFoundHttpException("No `$classname` exists with uid `$contentUid`");
        }

        $pages = $em->getRepository("BackBee\ClassContent\AbstractClassContent")->findPagesByContent($content);

        $response = $this->createResponse($this->formatCollection($pages));
        if (0 < count($pages)) {
            $response->headers->set('Content-Range', '0-'.(count($pages) - 1).'/'.count($pages));
        }

        return $response;
    }
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;
    }
397007
@XmlElementDecl(namespace = "urn:oasis:names:tc:xacml:3.0:core:schema:wd-17", name = "Content")
    public JAXBElement<ContentType> createContent(ContentType value) {
        return new JAXBElement<ContentType>(_Content_QNAME, ContentType.class, null, value);
    }
1276385
public static Action contentType(final String contentType) {
        return new Action(r -> {
            r.setContentType(contentType);
            return r;
        });
    }
1091876
private function resolveContentEditData(
        Content $content,
        string $languageCode,
        ContentType $contentType
    ): ContentUpdateData {
        $contentUpdateMapper = new ContentUpdateMapper();

        return $contentUpdateMapper->mapToFormData($content, [
            'languageCode' => $languageCode,
            'contentType' => $contentType,
        ]);
    }
652661
protected function createContentTypeForm(Request $request, $option, ContentTypeInterface $contentType)
    {
        $method = "POST";
        if ("PATCH" === $request->getMethod()) {
            $option["validation_groups"] = false;
            $method = "PATCH";
        }
        $option["method"] = $method;

        return $this->createForm('oo_content_type', $contentType, $option);
    }
134911
public function setContentType(string $contentType, string $charset = null)
    {
        $this->setHeader('Content-Type', $contentType . ($charset ? "; charset=$charset" : ''));

        return $this;
    }
861399
public function createMapping($contentType)
    {
        $index = $this->client->getIndex($this->indexName);
        $type = $index->getType(self::INDEX_TYPE . $contentType->getContentTypeId());

        $mappingProperties = array(
            'id' => array('type' => 'string', 'include_in_all' => true),
            'elementId' => array('type' => 'string', 'include_in_all' => true),
            'contentId' => array('type' => 'string', 'include_in_all' => true),
            'name' => array('type' => 'string', 'include_in_all' => true),
            'siteId' => array('type' => 'string', 'include_in_all' => true),
            'linkedToSite' => array('type' => 'boolean', 'include_in_all' => false),
            'language' => array('type' => 'string', 'include_in_all' => true),
            'contentType' => array('type' => 'string', 'include_in_all' => true),
            'keywords' => array('type' => 'string', 'include_in_all' => true),
            'updatedAt' => array('type' => 'long', 'include_in_all' => false),
        );

        /** @var FieldTypeInterface $field */
        foreach ($contentType->getFields() as $field) {
            if ($field->isSearchable()) {
                $mappingProperties['attribute_' . $field->getFieldId()] = array('type' => $this->formMapper->map($field->getType()), 'include_in_all' => false);
                $mappingProperties['attribute_' . $field->getFieldId() . '_stringValue'] = array('type' => 'string', 'include_in_all' => true);
            }
        }

        $mapping = $this->mappingFactory->create($type);
        $mapping->setProperties($mappingProperties);
        $mapping->send();
    }
876466
public function createDraftFromVersion($contentId, $versionNumber)
    {
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
        $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
        $contentDraft = $this->repository->getContentService()->createContentDraft(
            $contentInfo,
            $this->repository->getContentService()->loadVersionInfo($contentInfo, $versionNumber)
        );

        return new Values\CreatedVersion(
            array(
                'version' => new Values\Version(
                    $contentDraft,
                    $contentType,
                    $this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo())
                ),
            )
        );
    }
852809
public function addCompatibleContentType($contentType)
    {
        if (!\in_array($contentType, $this->compatibleContentTypes, true)) {
            $this->compatibleContentTypes[] = $contentType;
        }
    }
1316101
private function setTaxonomyCollection(Entity\Content $contentEntity, $contentType)
    {
        if (empty($contentType['taxonomy'])) {
            return;
        }
        /** @var Collection\Taxonomy $taxonomies */
        $taxonomies = $this->repository->getEntityManager()->createCollection(Entity\Taxonomy::class);

        foreach ($contentType['taxonomy'] as $key => $taxonomy) {
            $taxEntity = null;

            if (isset($this->taxConfig[$taxonomy]['options'])) {
                $options = $this->taxConfig[$taxonomy]['options'];
                $key = array_rand($options);

                $taxEntity = $this->getTaxonomyEntity($contentEntity, $taxonomy);
                $taxEntity->setSlug($key);
                $taxEntity->setName($options[$key]);
                $taxEntity->setSortorder(rand(1, 1000));

                $taxonomies->add($taxEntity);
            }

            if ($this->taxConfig[$taxonomy]['behaves_like'] === 'tags') {
                $tags = $this->getRandomTags(5);
                foreach ($tags as $tag) {
                    $taxEntity = $this->getTaxonomyEntity($contentEntity, $taxonomy);
                    $taxEntity->setSlug($tag);
                    $taxEntity->setName($tag);

                    $taxonomies->add($taxEntity);
                }
            }
        }

        $contentEntity->setTaxonomy($taxonomies);
    }
171231
public function addToContentType($fieldName, ContentType $contentType)
    {
        try {
            $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentType->id);
        } catch (NotFoundException $e) {
            $contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType);
        }

        $typeUpdate = $this->contentTypeService->newContentTypeUpdateStruct();
        $typeUpdate->modificationDate = new DateTime();

        $knowLanguage = array_keys($contentType->getDescriptions());

        if (!in_array($contentType->mainLanguageCode, $knowLanguage)) {
            $knowLanguage[] = $contentType->mainLanguageCode;
        }

        $fieldCreateStruct = $this->contentTypeService->newFieldDefinitionCreateStruct(
            $fieldName,
            'novaseometas'
        );

        $fieldCreateStruct->names = array_fill_keys($knowLanguage, $this->metaFieldName);
        $fieldCreateStruct->descriptions = array_fill_keys($knowLanguage, $this->metaFieldDescription);
        $fieldCreateStruct->fieldGroup = $this->metaFieldGroup;
        $fieldCreateStruct->position = 100;
        $fieldCreateStruct->isTranslatable = true;
        $fieldCreateStruct->isRequired = false;
        $fieldCreateStruct->isSearchable = false;
        $fieldCreateStruct->isInfoCollector = false;

        try {
            $this->contentTypeService->updateContentTypeDraft($contentTypeDraft, $typeUpdate);

            if ($contentTypeDraft->getFieldDefinition($fieldName) == null) {
                $this->contentTypeService->addFieldDefinition($contentTypeDraft, $fieldCreateStruct);
            }

            $this->contentTypeService->publishContentTypeDraft($contentTypeDraft);

            return true;
        } catch (Exception $e) {
            $this->errorMessage = $e->getMessage();

            return false;
        }
    }
1126717
public function createByTypeAction($id, Request $request)
    {
        $contentType = $this->contentTypeManager->getContentTypeById($id);

        if ($contentType === null) {
            throw EntityNotFoundException::fromClassNameAndIdentifier(
                $this->configurationManager->getEntityClass('content_type'),
                [$id]
            );
        }

        $contentEntityClass = $this->configurationManager->getEntityClass('content');
        $content = new $contentEntityClass;
        $content->setContentType($contentType);

        $form = $this->createForm(ContentType::class, $content, [
            'action' => $this->generateUrl('sherlockode_acb_content_create_by_type', ['id' => $contentType->getId()]),
            'contentType' => $content->getContentType(),
        ]);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->om->persist($content);
            $this->om->flush();

            return $this->redirectToRoute('sherlockode_acb_content_edit', ['id' => $content->getId()]);
        }

        return $this->render('@SherlockodeAdvancedContent/Content/edit_content.html.twig', [
            'form' => $form->createView(),
            'is_ajax' => $request->isXmlHttpRequest(),
        ]);
    }