Setup a templatefields field if needed.

@param string $contentKey
@param string $className
350702
public function setTemplatefields($contentKey, $className)
    {
        if (!isset($this->contenttypes[$contentKey]['templatefields'])) {
            return;
        }

        $config = $this->contenttypes[$contentKey]['templatefields'];

        foreach ($config as &$template) {
            foreach ($template['fields'] as &$field) {
                $this->postProcessField($field);
            }
        }
        $mapping = [
            'fieldname' => 'templatefields',
            'type'      => 'json',
            'fieldtype' => $this->typemap['templatefields'],
            'config'    => $config,
        ];

        $this->metadata[$className]['fields']['templatefields'] = $mapping;
    }
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;
        }
    }
518865
private void addAllClassesFrameTag(Content contentTree) {
        HtmlTree frame = HtmlTree.IFRAME(DocPaths.ALLCLASSES_FRAME.getPath(),
                "packageFrame", configuration.getText("doclet.All_classes_and_interfaces"));
        HtmlTree leftBottom = HtmlTree.DIV(HtmlStyle.leftBottom, frame);
        contentTree.addContent(leftBottom);
    }
1028410
public void buildFieldSerializationOverview(TypeElement typeElement, Content classContentTree) {
        if (utils.definesSerializableFields(typeElement)) {
            VariableElement ve = utils.serializableFields(typeElement).first();
            // Check to see if there are inline comments, tags or deprecation
            // information to be printed.
            if (fieldWriter.shouldPrintOverview(ve)) {
                Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
                Content fieldsOverviewContentTree = fieldWriter.getFieldsContentHeader(true);
                fieldWriter.addMemberDeprecatedInfo(ve, fieldsOverviewContentTree);
                if (!configuration.nocomment) {
                    fieldWriter.addMemberDescription(ve, fieldsOverviewContentTree);
                    fieldWriter.addMemberTags(ve, fieldsOverviewContentTree);
                }
                serializableFieldsTree.addContent(fieldsOverviewContentTree);
                classContentTree.addContent(fieldWriter.getSerializableFields(
                        configuration.getText("doclet.Serialized_Form_class"),
                        serializableFieldsTree));
            }
        }
    }
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;
    }
675917
private void addAllClassesFrameTag(Content contentTree) {
        HtmlTree frame = HtmlTree.FRAME(DocPaths.ALLCLASSES_FRAME.getPath(),
                "packageFrame", configuration.getText("doclet.All_classes_and_interfaces"));
        contentTree.addContent(frame);
    }
35196
public function addTemplateVariablesFor($template, array $contentVariables)
    {
        if (!array_key_exists($template, $this->paramArrays)) {
            $this->paramArrays[$template] = $this->getParamArrayFor($template);
        }

        // add vars for main template
        $contentVariables = array_merge($this->paramArrays[$template], $contentVariables);

        // add the template-variables to the contentItem-params-arrays
        if (array_key_exists(self::CONTENT_ITEMS, $contentVariables)) {
            foreach ($contentVariables[self::CONTENT_ITEMS] as $key => $contentItem) {
                // get the key (=> template)
                reset($contentItem);
                $itemTemplate = key($contentItem);

                // get the params
                $itemParams = $contentItem[$itemTemplate];

                // add params for this template
                $contentItem[$itemTemplate] = $this->addTemplateVariablesFor($itemTemplate, $itemParams);

                // store back into the main array
                $contentVariables[self::CONTENT_ITEMS][$key] = $contentItem;
            }
        }

        return $contentVariables;
    }
770493
protected final void addContentPart(List<ContentPart<?>> contentList,String key,String value)
    {
        if((key!=null)&&(value!=null)&&(value.length()>0))
        {
            if(this.shouldAddContentPart(key))
            {
                contentList.add(new ContentPart<String>(key,value,ContentPartType.STRING));
            }
        }
    }
183176
protected void addClassInfo(TypeElement te, Content contentTree) {
        contentTree.addContent(contents.getContent("doclet.in",
                utils.getTypeElementName(te, false),
                getPackageLink(utils.containingPackage(te),
                    utils.getPackageName(utils.containingPackage(te)))
                ));
    }
707575
private function setTemplateFieldName(string $templateFieldName): self
    {
        $this->updatePropertyValue(
            TemplateFieldNameFieldInterface::PROP_TEMPLATE_FIELD_NAME,
            $templateFieldName
        );

        return $this;
    }
189011
public function setFileRaw( string$key, string$contentType, string$content, string$fileName=null ):self
	{
		$this->files[$key]= [
			'fileName'=> $fileName??md5($content),
			'contentType'=> $contentType,
			'content'=> $content,
		];

		return $this;
	}
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;
    }
714514
protected function setFieldKey()
    {
        if (! $this->fieldValue || ! $this->rootValue) {
            return;
        }

        $cacheFieldKey = $this->fieldValue
            ->getParent()
            ->getCacheKey();

        if ($cacheFieldKey) {
            $this->fieldKey = data_get($this->rootValue, $cacheFieldKey);
        }
    }
915707
function initializeClassAttribute( $classAttribute )
    {
        if ( $classAttribute->attribute( self::DEFAULT_ZONE_LAYOUT_FIELD ) === null )
            $classAttribute->setAttribute( self::DEFAULT_ZONE_LAYOUT_FIELD, '' );

        $classAttribute->store();
    }
856832
public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) {
        if (classDoc.definesSerializableFields()) {
            FieldDoc serialPersistentField = classDoc.serializableFields()[0];
            // Check to see if there are inline comments, tags or deprecation
            // information to be printed.
            if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
                Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
                Content fieldsOverviewContentTree = fieldWriter.getFieldsContentHeader(true);
                fieldWriter.addMemberDeprecatedInfo(serialPersistentField,
                        fieldsOverviewContentTree);
                if (!configuration.nocomment) {
                    fieldWriter.addMemberDescription(serialPersistentField,
                            fieldsOverviewContentTree);
                    fieldWriter.addMemberTags(serialPersistentField,
                            fieldsOverviewContentTree);
                }
                serializableFieldsTree.addContent(fieldsOverviewContentTree);
                classContentTree.addContent(fieldWriter.getSerializableFields(
                        configuration.getText("doclet.Serialized_Form_class"),
                        serializableFieldsTree));
            }
        }
    }
582138
public function cacheFile($cacheKey, $fileContents) {

        // Get directory and filename
        list($directory, $filename) = $this->getDirectoryAndFilenameFromKey($cacheKey);

        // Make the cache directory
        if (!file_exists($directory)) mkdir($directory, 0777, true);

        // Save the file
        file_put_contents($directory . "/" . $filename, $fileContents);

    }
255551
public void buildClassDoc(XMLNode node, Content contentTree) throws Exception {
         String key;
         if (isInterface) {
             key =  "doclet.Interface";
         } else if (isEnum) {
             key = "doclet.Enum";
         } else {
             key =  "doclet.Class";
         }
         contentTree = writer.getHeader(configuration.getText(key) + " " +
                 classDoc.name());
         Content classContentTree = writer.getClassContentHeader();
         buildChildren(node, classContentTree);
         writer.addClassContentTree(contentTree, classContentTree);
         writer.addFooter(contentTree);
         writer.printDocument(contentTree);
         writer.close();
         copyDocFiles();
     }