Add the "Other content" & similar menu/sub menus.

@param MenuEntry $contentRoot
@param Bag       $contentType
519559
private function addGroupedMenu(MenuEntry $contentRoot, Bag $contentType)
    {
        $key = $contentType->get('show_in_menu') ?: 'other';

        $label = $key === 'other' ? Trans::__('general.phrase.other-content') : ucwords($key);

        $contentRoot->add(
            MenuEntry::create(strtolower($key))
                ->setLabel($label)
                ->setIcon('fa:th-list')
                ->setGroup(true)
                ->setPermission('dashboard')
        );
    }
217149
private function addACLEntry($role, $resourceType, $folderPath, $allowRulesMask, $denyRulesMask)
    {

        if (!strlen($folderPath)) {
            $folderPath = '/';
        }
        else {
            if (substr($folderPath,0,1) != '/') {
                $folderPath = '/' . $folderPath;
            }

            if (substr($folderPath,-1,1) != '/') {
                $folderPath .= '/';
            }
        }

        $_entryKey = $role . "#@#" . $resourceType;

        if (array_key_exists($folderPath,$this->_aclEntries)) {
            if (array_key_exists($_entryKey, $this->_aclEntries[$folderPath])) {
                $_rulesMasks = $this->_aclEntries[$folderPath][$_entryKey];
                foreach ($_rulesMasks[0] as $key => $value) {
                    $allowRulesMask[$key] |= $value;
                }
                foreach ($_rulesMasks[1] as $key => $value) {
                    $denyRulesMask[$key] |= $value;
                }
            }
        }
        else {
            $this->_aclEntries[$folderPath] = array();
        }

        $this->_aclEntries[$folderPath][$_entryKey] = array($allowRulesMask, $denyRulesMask);
    }
121330
public void addClassContentTree(Content contentTree, Content classContentTree) {
        if (configuration.allowTag(HtmlTag.MAIN)) {
            mainTree.addContent(classContentTree);
            contentTree.addContent(mainTree);
        } else {
            contentTree.addContent(classContentTree);
        }
    }
1208992
public function createEditForm(ContentNode $contentNode, Node $rootNode = null)
    {

        $templateVars = array(
            'action' => $this->get('router')->generate('mm_cmf_content_node_update', array(
                'id' => $contentNode->getId()
            ))
        );

        if ($rootNode)
            $templateVars['root_node'] = $rootNode;

        return $this->createForm(
            ContentNodeType::class,
            $contentNode,
            $templateVars
        );
    }
1121568
public function setContentType($contentType, $charset = null)
    {
        if ($charset === null) {
            $this->setHeader('Content-Type', $contentType);
        } else {
            $this->setHeader('Content-Type', $contentType . '; charset=' . $charset);
        }

        return $this;
    }
200042
public function contentType(string $content_type, string $charset = '')
    {
        $header = new ContentType($content_type);

        if (!empty($charset)) {
            $header->setCharset($charset);
        }

        $this->addHeader($header);
    }
503575
function addEntry( $contentClassAttributeID, $contentClassID = false )
    {
        if ( !isset( $contentClassAttributeID ) )
        {
            return;
        }
        if ( !$contentClassID )
        {
            $contentClassAttribute = eZContentClassAttribute::fetch( $contentClassAttributeID );
            $contentClassID = $contentClassAttribute->attribute( 'contentclass_id' );
        }
        // Checking if $contentClassAttributeID and $contentClassID already exist (in Entries)
        foreach ( $this->Entries as $entrie )
        {
            if ( $entrie->attribute( 'contentclass_attribute_id' ) == $contentClassAttributeID and
                 $entrie->attribute( 'contentclass_id' ) == $contentClassID )
                return;
        }
        $waitUntilDateValue = eZWaitUntilDateValue::create( $this->WorkflowEventID, $this->WorkflowEventVersion, $contentClassAttributeID, $contentClassID );
        $waitUntilDateValue->store();
        $this->Entries = eZWaitUntilDateValue::fetchAllElements( $this->WorkflowEventID, $this->WorkflowEventVersion );
    }
932293
public function replaceRootContentSet(ContentSet $contentToReplace, ContentSet $newContentSet, $checkContentsLinkToParent = true)
    {
        $checkContentsLinkToParent = (true === $checkContentsLinkToParent);
        $contentIsLinked = true === $checkContentsLinkToParent ? $this->isLinkedToHisParentBy($contentToReplace) : true;

        if (true === $contentIsLinked) {
            if (null !== $this->getContentSet()) {
                $this->getContentSet()->replaceChildBy($contentToReplace, $newContentSet);
            }
        }

        return $newContentSet;
    }
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);
    }
582166
public static function addTextNode(\DOMNode $rootNode, $text, $escapeChars = false)
    {
        if (!empty($text) || is_numeric($text)) {
            $owner = XmlUtil::getOwnerDocument($rootNode);
            if ($escapeChars) {
                $nodeworkingText = $owner->createCDATASection($text);
            } else {
                $nodeworkingText = $owner->createTextNode($text);
            }
            $rootNode->appendChild($nodeworkingText);
        }
    }
772011
public function setDocumentRoot($documentRoot)
    {
        if ($documentRoot) {
            $this->documentRoot = $documentRoot;
        } else {
            $this->documentRoot = $this->getDefaultDocRoot();
        }
    }
878217
public function setContentType($contentType = null)
    {
        if ($contentType === null) {
            $contentType = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : null;
        }

        $this->contentType = $contentType;
    }
928392
public void addRootMenuItem(ContextMenuItemState rootItem, CmsContextMenuConnector connector) {

        CmsContextMenuItemWidget itemWidget = createEmptyItemWidget(
            rootItem.getId(),
            rootItem.getCaption(),
            rootItem.getDescription(),
            connector);
        itemWidget.setEnabled(rootItem.isEnabled());
        itemWidget.setSeparatorVisible(rootItem.isSeparator());

        setStyleNames(itemWidget, rootItem.getStyles());

        m_menuOverlay.addMenuItem(itemWidget);

        for (ContextMenuItemState childState : rootItem.getChildren()) {
            createSubMenu(itemWidget, childState, connector);
        }
    }
964668
private function validateContentTypes(Bag $importData)
    {
        $contentTypeNames = $this->contentTypes->keys()->toArray();
        $importData->filter(function ($k, $v) use ($contentTypeNames) {
            if (!in_array($k, $contentTypeNames)) {
                throw new RuntimeException(sprintf('ContentType "%s" is not configured.', $k));
            }
        });
    }
864528
public function createSimpleEditForm(ContentNode $contentNode, Node $rootNode = null)
    {
        $contentNodeClassName = get_class($contentNode);

        $contentNodeParser = $this->get('mm_cmf_content.content_parser');

        $simpleFormData = $contentNodeParser->getSimpleForm($contentNodeClassName);
        //set FormType
        if (isset($simpleFormData['type']) && class_exists($simpleFormData['type'])) {
            $simpleFormType = $simpleFormData['type'];
        } else
            $simpleFormType = ContentNodeType::class;


        //get fields to hide
        $hiddenFields = $contentNodeParser->getHiddenFields($contentNodeClassName);

        $templateVars = array(
            'hiddenFields' => $hiddenFields,
            'action' => $this->get('router')->generate('mm_cmf_content_node_simple_update', array(
                'id' => $contentNode->getId()
            ))
        );

        if ($rootNode)
            $templateVars['root_node'] = $rootNode;

        return $this->createForm(
            $simpleFormType,
            $contentNode,
            $templateVars
        );
    }
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;
        }
    }
125399
public function setContentType(string $contentType): void
    {
        $this->contentType = $contentType;
        // TODO: This can be removed after the full changes are done for next major.
        $this->headers->set('Content-Type', $contentType, true);
    }