@param NodeTranslation $parentNode The parent node
@param string          $slug       The slug

@return NodeTranslation
497473
public function getNodeBySlug(NodeTranslation $parentNode, $slug)
    {
        return $this->em->getRepository('KunstmaanNodeBundle:NodeTranslation')
            ->getNodeTranslationForSlug($slug, $parentNode);
    }
1021420
public static function findBySlug($slug, $locale = null)
    {
        /** @var \Dimsav\Translatable\Translatable $model */
        $model = (new static);

        /** @var SluggableTrait $translationModel */
        $translationModel = $model->getTranslationModelName();
        $parentKey        = $model->getRelationKey();

        $translationInstance = $translationModel::findBySlug($slug, $locale);

        if (empty($translationInstance)) return null;

        return static::find($translationInstance->{$parentKey});
    }
312163
public function getNodeTranslationByNodeId($nodeId, $lang)
    {
        $repo = $this->em->getRepository('KunstmaanNodeBundle:NodeTranslation');

        return $repo->getNodeTranslationByNodeIdQueryBuilder($nodeId, $lang);
    }
288495
public static function register( $slug, $object, $parent = null ) {

		$caller = get_called_class();
		// get the current instance
		if ( empty( $object['type'] ) || ! uix()->is_callable( 'control\\' . $object['type'] ) ) {
			$object['type'] = 'text';
		}

		$caller = $caller . '\\' . $object['type'];

		return new $caller( $slug, $object, $parent );

	}
766617
public function create(CreateStruct $createStruct, array $parentNode)
    {
        $location = new Location();
        /** @var $query \eZ\Publish\Core\Persistence\Database\InsertQuery */
        $query = $this->handler->createInsertQuery();
        $query
            ->insertInto($this->handler->quoteTable('ezcontentobject_tree'))
            ->set(
                $this->handler->quoteColumn('contentobject_id'),
                $query->bindValue($location->contentId = $createStruct->contentId, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('contentobject_is_published'),
                $query->bindValue(1, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('contentobject_version'),
                $query->bindValue($createStruct->contentVersion, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('depth'),
                $query->bindValue($location->depth = $parentNode['depth'] + 1, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('is_hidden'),
                $query->bindValue($location->hidden = $createStruct->hidden, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('is_invisible'),
                $query->bindValue($location->invisible = $createStruct->invisible, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('modified_subnode'),
                $query->bindValue(time(), null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('node_id'),
                $this->handler->getAutoIncrementValue('ezcontentobject_tree', 'node_id')
            )->set(
                $this->handler->quoteColumn('parent_node_id'),
                $query->bindValue($location->parentId = $parentNode['node_id'], null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('path_identification_string'),
                $query->bindValue($location->pathIdentificationString = $createStruct->pathIdentificationString, null, \PDO::PARAM_STR)
            )->set(
                $this->handler->quoteColumn('path_string'),
                $query->bindValue('dummy') // Set later
            )->set(
                $this->handler->quoteColumn('priority'),
                $query->bindValue($location->priority = $createStruct->priority, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('remote_id'),
                $query->bindValue($location->remoteId = $createStruct->remoteId, null, \PDO::PARAM_STR)
            )->set(
                $this->handler->quoteColumn('sort_field'),
                $query->bindValue($location->sortField = $createStruct->sortField, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('sort_order'),
                $query->bindValue($location->sortOrder = $createStruct->sortOrder, null, \PDO::PARAM_INT)
            );
        $query->prepare()->execute();

        $location->id = $this->handler->lastInsertId($this->handler->getSequenceName('ezcontentobject_tree', 'node_id'));

        $mainLocationId = $createStruct->mainLocationId === true ? $location->id : $createStruct->mainLocationId;
        $location->pathString = $parentNode['path_string'] . $location->id . '/';
        /** @var $query \eZ\Publish\Core\Persistence\Database\UpdateQuery */
        $query = $this->handler->createUpdateQuery();
        $query
            ->update($this->handler->quoteTable('ezcontentobject_tree'))
            ->set(
                $this->handler->quoteColumn('path_string'),
                $query->bindValue($location->pathString)
            )
            ->set(
                $this->handler->quoteColumn('main_node_id'),
                $query->bindValue($mainLocationId, null, \PDO::PARAM_INT)
            )
            ->where(
                $query->expr->eq(
                    $this->handler->quoteColumn('node_id'),
                    $query->bindValue($location->id, null, \PDO::PARAM_INT)
                )
            );
        $query->prepare()->execute();

        return $location;
    }
233438
private function templateStatementList(ParentNode $node) {
    while ($this->current) {
      if ($this->currentType === T_OPEN_TAG) {
        return;
      }
      elseif ($this->currentType === T_INLINE_HTML) {
        $node->addChild($this->mustMatchToken(T_INLINE_HTML));
      }
      elseif ($this->currentType === T_OPEN_TAG_WITH_ECHO) {
        $node->addChild($this->echoTagStatement());
      }
      else {
        throw new ParserException(
          $this->filename,
          $this->iterator->getLineNumber(),
          $this->iterator->getColumnNumber(),
          'expected PHP opening tag, but got ' . $this->iterator->current()->getText());
      }
    }
  }
699364
public static function nodesTreeList($parentId = 0, $level = 0, $shiftPrefix = '. ')
    {
        if (!isset(static::$_nodesTreeList[$parentId][$level][$shiftPrefix])) {
            $tree = [];
            $list = [];

            $parentNode = static::node($parentId);
            if (!empty($parentNode)) {
                $grandParentId = $parentNode['parent_id'];
                $grandParentNode = static::node($grandParentId);
                $nodePath = (empty($grandParentNode->nodePath)
                             ? '' : $grandParentNode->nodePath . '/'
                         ) . $parentNode['slug'];
                $list[$parentId] = str_repeat($shiftPrefix, $level) . $nodePath;
                $tree[$parentId] = str_repeat($shiftPrefix, $level) . $parentNode['slug'];
                static::saveNodePath($parentId, $nodePath);
            }

            $children = static::nodeChildren($parentId);
            foreach ($children as $child) {
                static::$_nodes[$child['id']] = $child;
                $list += static::nodesTreeList($child->id, $level+1, $shiftPrefix);
                $tree += static::nodesTree($child->id, $level+1, $shiftPrefix);
            }
            static::$_nodesTree[$parentId][$level][$shiftPrefix] = $tree;
            static::$_nodesTreeList[$parentId][$level][$shiftPrefix] = $list;
        }    
        return static::$_nodesTreeList[$parentId][$level][$shiftPrefix];
    }
254028
protected final void setParentNode(final DiffNode parentNode)
	{
		if (this.parentNode != null && this.parentNode != parentNode)
		{
			throw new IllegalStateException("The parent of a node cannot be changed, once it's set.");
		}
		this.parentNode = parentNode;
	}
1125326
public function setParent(Node $parent)
    {
        $this->relations['parent'] = $parent;
        $parent->addChild($this);
        return $this;
    }
316130
protected function createFolder( $parentNode, $target )
    {
        // Grab settings from the ini file:
        $webdavINI = eZINI::instance( self::WEBDAV_INI_FILE );
        $folderClassID = $webdavINI->variable( 'FolderSettings', 'FolderClass' );
        $languageCode = eZContentObject::defaultLanguage();

        $contentObject = eZContentObject::createWithNodeAssignment( $parentNode, $folderClassID, $languageCode );
        if ( $contentObject )
        {
            $db = eZDB::instance();
            $db->begin();
            $version = $contentObject->version( 1 );
            $version->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
            $version->store();

            $contentObjectID = $contentObject->attribute( 'id' );
            $contentObjectAttributes = $version->contentObjectAttributes();

            // @todo @as avoid using [0] (could be another index in some classes)
            $contentObjectAttributes[0]->setAttribute( 'data_text', basename( $target ) );
            $contentObjectAttributes[0]->store();
            $db->commit();

            $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
                                                                                         'version' => 1 ) );
            return true; // @as self::OK_CREATED;
        }
        else
        {
            return false; // @as self::FAILED_FORBIDDEN;
        }
    }
78411
protected function buildCmsNodeRef($slugKey = 'OriginalSlug')
    {
        if (empty($this->params['Element']))
            throw new Exception('Element parameter is required');

        $nodeElement = $this->ElementService->getBySlug($this->params['Element']);

        if (!is_null($slugKey) && $this->Request->getParameter($slugKey) != '') {
            $slug = $this->Request->getParameter($slugKey);

            $this->nodeRef = new NodeRef($nodeElement, $slug);
        } else {
            $this->nodeRef = new NodeRef($nodeElement);
        }


        return $this->nodeRef;
    }
204144
public function createEmptyPage(Node $node, $locale)
    {
        $user = $this->getAdminUser();

        $refEntityName = $node->getRefEntityName();
        $targetPage = $this->createNewPage($refEntityName);

        /* @var NodeTranslation $nodeTranslation */
        $nodeTranslation = $this->em->getRepository(NodeTranslation::class)->createNodeTranslationFor($targetPage, $locale, $node, $user);
        $nodeVersion = $nodeTranslation->getPublicNodeVersion();

        $this->eventDispatcher->dispatch(
            Events::ADD_EMPTY_PAGE_TRANSLATION,
            new NodeEvent($node, $nodeTranslation, $nodeVersion, $targetPage)
        );

        return $nodeTranslation;
    }
686872
public function setParent(InnerNode $parent)
    {
        // check integrity
        if ($this->isDescendant($parent->id())) {
            throw new CircularException('Can not add descendant "'.$parent->id().'" as my parent.');
        }

        return parent::setParent($parent);
    }
207649
public function getMaxChildrenWeight(Node $parentNode = null, $lang = null)
    {
        $maxWeight = $this->getNodeTranslationsQueryBuilder($lang)
            ->select('max(nt.weight)')
            ->andWhere('n.parent = :parentNode')
            ->setParameter('parentNode', $parentNode)
            ->getQuery()
            ->getSingleScalarResult();

        return (int) $maxWeight;
    }
1327038
public function getOnlineChildrenQueryBuilder(Node $parent, $lang = null)
    {
        return $this->getChildrenQueryBuilder($parent, $lang)
            ->andWhere('nt.online = true');
    }
679300
public function createPage(
        $refEntityType,
        $pageTitle,
        $locale,
        Node $parentNode = null)
    {
        $user = $this->getAdminUser();

        $newPage = $this->createNewPage($refEntityType, $pageTitle);
        if (null !== $parentNode) {
            $parentNodeTranslation = $parentNode->getNodeTranslation($locale, true);
            $parentNodeVersion = $parentNodeTranslation->getPublicNodeVersion();
            $parentPage = $parentNodeVersion->getRef($this->em);
            $newPage->setParent($parentPage);
        }

        /* @var Node $nodeNewPage */
        $nodeNewPage = $this->em->getRepository('KunstmaanNodeBundle:Node')->createNodeFor($newPage, $locale, $user);
        $nodeTranslation = $nodeNewPage->getNodeTranslation($locale, true);
        if (null !== $parentNode) {
            $weight = $this->em->getRepository('KunstmaanNodeBundle:NodeTranslation')->getMaxChildrenWeight(
                    $parentNode,
                    $locale
                ) + 1;
            $nodeTranslation->setWeight($weight);
        }

        if ($newPage->isStructureNode()) {
            $nodeTranslation->setSlug('');
        }

        $this->em->persist($nodeTranslation);
        $this->em->flush();

        $nodeVersion = $nodeTranslation->getPublicNodeVersion();

        $this->eventDispatcher->dispatch(
            Events::ADD_NODE,
            new NodeEvent(
                $nodeNewPage, $nodeTranslation, $nodeVersion, $newPage
            )
        );

        return $nodeTranslation;
    }
99430
public function getAllParents(Node $node = null, $lang = null)
    {
        if (is_null($node)) {
            return array();
        }

        $qb = $this->createQueryBuilder('node');

        // Directly hydrate the nodeTranslation and nodeVersion
        $qb->select('node', 't', 'v')
            ->innerJoin('node.nodeTranslations', 't')
            ->leftJoin(
                't.publicNodeVersion',
                'v',
                'WITH',
                't.publicNodeVersion = v.id'
            )
            ->where('node.deleted = 0');

        if ($lang) {
            $qb->andWhere('t.lang = :lang')
                ->setParameter('lang', $lang);
        }

        $qb->andWhere(
            $qb->expr()->andX(
                $qb->expr()->lte('node.lft', $node->getLeft()),
                $qb->expr()->gte('node.rgt', $node->getRight())
            )
        );

        $qb->addOrderBy('node.lft', 'ASC');

        return $qb->getQuery()->getResult();
    }