Creates tree structure for Content

@param \Netgen\Bundle\InformationCollectionBundle\API\Value\InformationCollection\Content $content
@param bool $isRoot

@return array
968261
protected function getCollections(Content $content, $isRoot = false)
    {
        $languages = $this->getConfigResolver()->getParameter('languages');

        $query = new Query([
            'contentId' => $content->content->id,
            'limit' => Query::COUNT_QUERY,
        ]);

        $count = $this->service->getCollections($query);

        return array(
            'id' => $content->content->id,
            'parent' => $isRoot ? '#' : '0',
            'text' => $content->contentType->getName($languages[0]) . ' (' . strval($count->count) . ')',
            'children' => false,
            'a_attr' => array(
                'href' => $this->router->generate('netgen_information_collection.route.admin.collection_list', ['contentId' => $content->content->id]),
                'rel' => $content->content->id,
            ),
            'state' => array(
                'opened' => $isRoot,
            ),
            'data' => array(
                'context_menu' => array(
                    array(
                        'name' => 'export',
                        'url' => $this->router->generate('netgen_information_collection.route.admin.export', ['contentId' => $content->content->id]),
                        'text' => $this->translator->trans('netgen_information_collection_admin_export_export', [], 'netgen_information_collection_admin'),
                    ),
                ),
            ),
        );
    }
1168780
public function after($content)
    {
        $content = self::create($content);
        $newnodes = array();
        foreach ($this as $i => $node) {
            /** @var \DOMNode $node */
            $refnode = $node->nextSibling;
            foreach ($content as $newnode) {
                /** @var \DOMNode $newnode */
                $newnode = static::importNewnode($newnode, $node, $i);
                if ($refnode === null) {
                    $node->parentNode->appendChild($newnode);
                } else {
                    $node->parentNode->insertBefore($newnode, $refnode);
                }
                $newnodes[] = $newnode;
            }
        }
        $content->clear();
        $content->add($newnodes);
        return $this;
    }
30812
public function setReadonlyRootfs(bool $readonlyRootfs)
    {
        $this->readonlyRootfs = $readonlyRootfs;

        $this->hostConfig = array_merge($this->hostConfig, ['ReadonlyRootfs' => $readonlyRootfs]);

        return $this;
    }
985466
protected function buildSolrHierarchyFromIdRootline(array $idRootline)
    {
        $hierarchy = [];

        $depth = 0;
        $currentPath = array_shift($idRootline);
        if (is_null($currentPath)) {
            return $hierarchy;
        }

        foreach ($idRootline as $uid) {
            $hierarchy[] = $depth . '-' . $currentPath . '/';

            $depth++;
            $currentPath .= '/' . $uid;
        }
        $hierarchy[] = $depth . '-' . $currentPath . '/';

        return $hierarchy;
    }
651141
public static function getRootDir($bundlepath = false)
    {
        $dir = dirname(static::getCont()->getParameter('kernel.root_dir'));

        if ($bundlepath) {
            $n = get_called_class();
            $n = substr($n, 0, -strlen(strrchr($n, '\\')));
            $n = substr($n, 0, -strlen(strrchr($n, '\\')));
            $n = str_replace('\\', '/', $n);
            $dir .= "/src/$n";
        }

        return $dir;
    }
548482
protected function getInheritedProperties($type, array $schema, $isRoot = true)
    {
        if (!isset($schema['types'][$type])) {
            throw new \Exception('Unknown type '.$type);
        }

        $typeSchema = $schema['types'][$type];
        $properties = [];
        if (!$isRoot) {
            foreach ($typeSchema['specific_properties'] as $property) {
                if (!isset($schema['properties'][$property])) {
                    continue;
                }

                $properties[$property] = $property;
            }
        }

        if ($typeSchema['ancestors']) {
            $properties = array_merge(
                $properties,
                $this->getInheritedProperties(end($typeSchema['ancestors']), $schema, false)
            );
        }

        ksort($properties);

        return $properties;
    }
301679
public static function createRoot(UrlGeneratorInterface $urlGenerator, $basePath)
    {
        $root = new static('root', $basePath);
        $root->urlGenerator = $urlGenerator;

        return $root;
    }
482854
protected function buildContentItem(ContentFile $contentFile)
    {
        $data = [
            'uri'         => $contentFile->getUri(),
            'title'       => $contentFile->getTitle(),
            'date'        => $contentFile->getDate(),
            'type'        => $contentFile->getType(),
            'content'     => $contentFile->getContent(),
            'template'    => $contentFile->getTemplate(),
            'description' => $contentFile->getDescription(),
            'seoTitle'    => $contentFile->getSeoTitle(),
            'excerpt'     => $contentFile->getExcerpt(),
            'isIndex'     => $contentFile->isIndex(),
        ];

        $contentItem = ContentItem::fromArray($data);

        foreach ($contentFile->getMetadata() as $k => $v) {
            $contentItem->setMeta($k, $v);
        }

        foreach ($contentFile->getTerms() as $term) {
            $contentItem->addTerm($term);
        }

        return $contentItem;
    }
718386
public function makeRoot($newRoot)
    {
        if($this->isRoot())
        {
            return;
        }

        if(!$this->hasManyRoots())
        {
            throw new \BadMethodCallException(sprintf('%s::%s is only supported on multiple root trees', __CLASS__, __METHOD__));
        }

        $em = $this->getManager()->getEntityManager();
        $lftField = $this->getLeftFieldName();
        $rgtField = $this->getRightFieldName();
        $rootField = $this->getRootFieldName();

        $oldRgt = $this->getRightValue();
        $oldLft = $this->getLeftValue();
        $oldRoot = $this->getRootValue();

        // beginTransaction
        $em->getConnection()->beginTransaction();
        try
        {
            // Update descendants lft/rgt/root values
           $diff = 1 - $oldLft;
            $qb = $em->createQueryBuilder()
                ->update(get_class($this->getNode()), 'n')
                ->set("n.$lftField", "n.$lftField + ?1")
                ->setParameter(1, $diff)
                ->set("n.$rgtField", "n.$rgtField + ?2")
                ->setParameter(2, $diff)
                ->set("n.$rootField", "?3")
                ->setParameter(3, $newRoot)
                ->where("n.$lftField > ?4")
                ->setParameter(4, $oldLft)
                ->andWhere("n.$rgtField < ?5")
                ->setParameter(5, $oldRgt)
                ->andWhere("n.$rootField = ?6")
                ->setParameter(6, $oldRoot);
            $qb->getQuery()->execute();
            $this->getManager()->updateValues($oldLft, $oldRgt, $diff, $oldRoot, $newRoot);

            // Close gap in old tree
            $first = $oldRgt + 1;
            $delta = $oldLft - $oldRgt - 1;
            $this->shiftRLRange($first, 0, $delta, $oldRoot);

            // Set new lft/rgt/root values for root node
            $this->setLeftValue(1);
            $this->setRightValue($oldRgt - $oldLft + 1);
            $this->setRootValue($newRoot);
            $em->persist($this->getNode());

            $em->flush();
            $em->getConnection()->commit();
        }
        catch (\Exception $e)
        {
            // @codeCoverageIgnoreStart
            $em->close();
            $em->getConnection()->rollback();
            throw $e;
            // @codeCoverageIgnoreEnd
        }
        // endTransaction
    }
1215732
protected function createTree(&$keyParts, TreeNode $rootNode) : TreeNode
    {
        if (!count($keyParts)) {
            return $rootNode;
        }

        $newKey  = array_shift($keyParts);
        $newNode = new self($rootNode, $newKey, null, $rootNode->getKeyDelimiter());
        $rootNode->addChild($newNode);

        return $this->createTree($keyParts, $newNode);
    }
275310
protected function lexObjectField(bool $isConst): ObjectFieldNode
    {
        $start = $this->lexer->getToken();

        /**
         * @param bool $isConst
         * @return NodeInterface|TypeNodeInterface|ValueNodeInterface
         */
        $parseValue = function (bool $isConst): NodeInterface {
            $this->expect(TokenKindEnum::COLON);
            return $this->lexValue($isConst);
        };

        return new ObjectFieldNode(
            $this->lexName(),
            $parseValue($isConst),
            $this->createLocation($start)
        );
    }
263983
public function editNodeContent( $nodePath, $content )
	{
		$node	= $this->getNode( $nodePath );
		if( $node->setContent( $content ) )
			return (bool) $this->write();
		return FALSE;
	}
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
        );
    }
1286060
public function getDrupalApps($projectRoot)
    {
        return array_filter(
            LocalApplication::getApplications($projectRoot, $this->config),
            function (LocalApplication $app) {
                return Drupal::isDrupal($app->getRoot());
            }
        );
    }
1080259
protected function setupRootNode()
    {
        $builder = new TreeBuilder();
        $this->rootNode = $builder->root($this->getBundleName());

        return $this;
    }
206715
protected function newChild($name, $content = null)
	{
		$class = get_class($this);
		return new $class($name, $content, $this->getRoot(), $this->getAncestor(), $this);
	}
598939
public function treeNode($treeId)
    {
        $tree = $this->contentTreeManager->findByTreeId($treeId);
        if (!$tree) {
            return null;
        }
        $request = $this->requestStack->getCurrentRequest();
        $tree->setLanguage($request->getLocale());
        $treeNode = $tree->get($treeId);

        return new ContentTreeContext($treeNode);
    }