Returns the node translation for a given slug

@param NodeTranslation|null $parentNode The parentNode
@param string               $slugPart   The slug part

@return NodeTranslation|null
482229
private function getNodeTranslationForSlugPart(
        NodeTranslation $parentNode = null,
        $slugPart = ''
    ) {
        $qb = $this->createQueryBuilder('t')
            ->select('t', 'v', 'n')
            ->innerJoin('t.node', 'n', 'WITH', 't.node = n.id')
            ->leftJoin(
                't.publicNodeVersion',
                'v',
                'WITH',
                't.publicNodeVersion = v.id'
            )
            ->where('n.deleted != 1')
            ->setFirstResult(0)
            ->setMaxResults(1);

        if ($parentNode !== null) {
            $qb->andWhere('t.slug = :slug')
                ->andWhere('n.parent = :parent')
                ->setParameter('slug', $slugPart)
                ->setParameter('parent', $parentNode->getNode()->getId());
        } else {
            /* if parent is null we should look for slugs that have no parent */
            $qb->andWhere('n.parent IS NULL');
            if (empty($slugPart)) {
                $qb->andWhere('t.slug is NULL');
            } else {
                $qb->andWhere('t.slug = :slug');
                $qb->setParameter('slug', $slugPart);
            }
        }

        return $qb->getQuery()->getOneOrNullResult();
    }
35759
protected function getNodeTranslation($matchResult)
    {
        // The route matches, now check if it actually exists (needed for proper chain router chaining!)
        $nodeTranslationRepo = $this->getNodeTranslationRepository();

        /* @var NodeTranslation $nodeTranslation */
        $nodeTranslation = $nodeTranslationRepo->getNodeTranslationForUrl(
            $matchResult['url'],
            $matchResult['_locale']
        );

        return $nodeTranslation;
    }
993895
public function initializeNode($parentId, $language, $siteId, $order = 0)
    {
        /** @var NodeInterface $node */
        $node = new $this->nodeClass();
        $node->setSiteId($siteId);
        $node->setLanguage($language);
        $node->setMaxAge(NodeInterface::MAX_AGE);
        $node->setParentId($parentId);
        $node->setOrder($order);
        $node->setVersion($this->uniqueIdGenerator->generateUniqueId());
        $node->setCreatedBy($this->tokenStorage->getToken()->getUser()->getUsername());

        $parentNode = $this->nodeRepository->findInLastVersion($parentId, $language, $siteId);
        $status = $this->statusRepository->findOneByInitial();
        $node->setStatus($status);
        $nodeType = NodeInterface::TYPE_DEFAULT;
        if ($parentNode instanceof NodeInterface) {
            $nodeType = $parentNode->getNodeType();
            $node->setPath($parentNode->getPath());
        } else {
            $node->setNodeId(NodeInterface::ROOT_NODE_ID);
        }
        $node->setNodeType($nodeType);

        return $node;
    }
906992
public function getTree($lang = "", $postTypeID)
    {
        $orderBy = (isset($_GET['order'])) ? $orderBy = $_GET['order'] : 'order';
        $orderType = (isset($_GET['type'])) ? $orderType = $_GET['type'] : 'ASC';
        $parentList = Category::where('postTypeID', $postTypeID)->where('parentID', null)
            ->orWhere('parentID', 0)
            ->orderBy($orderBy, $orderType)
            ->paginate(Category::$rowsPerPage);

        $category = new Category();

        // get all categories of the selected post type
        $category->categoryList = Category::where('postTypeID', $postTypeID)
            ->orderBy($orderBy, $orderType)
            ->select("categoryID", "title", "slug")
            ->get();
        
        // make the parent child format tree
        $treeList = collect($category->makeChildrenTree($category->categoryList));

        // get only categories selected for this page (pagination)
        $tmp = [];
        foreach($parentList->items() as $item){
            $getCategory = $treeList->where('categoryID', $item->categoryID)->first();
            if($getCategory) {
                $tmp[] = $getCategory;
            }
        }

        $parentList->setCollection(collect($tmp));
        return Language::filterRows($parentList);
    }
194556
private function parseComplexDollarTemplateStringExpression($parentNode) {
        $var = $this->parseSimpleVariable($parentNode);
        $token = $this->getCurrentToken();
        if ($token->kind === TokenKind::OpenBracketToken) {
            return $this->parseTemplateStringSubscriptExpression($var);
        }
        return $var;
    }
168188
public function getUsersWithNodeVersionLock(NodeTranslation $nodeTranslation, $isPublicNodeVersion, BaseUser $userToExclude = null)
    {
        return  array_reduce(
            $this->getNodeVersionLocksByNodeTranslation($nodeTranslation, $isPublicNodeVersion, $userToExclude),
            function ($return, NodeVersionLock $item) {
                $return[] = $item->getOwner();

                return $return;
            },
            []
        );
    }
756261
protected function getNodeTranslation($matchResult)
    {
        $key = $matchResult['_controller'].$matchResult['url'].$matchResult['_locale'].$matchResult['_route'];
        if (!isset($this->cachedNodeTranslations[$key])) {
            $rootNode = $this->domainConfiguration->getRootNode();

            // Lookup node translation
            $nodeTranslationRepo = $this->getNodeTranslationRepository();

            /* @var NodeTranslation $nodeTranslation */
            $nodeTranslation = $nodeTranslationRepo->getNodeTranslationForUrl(
                $matchResult['url'],
                $matchResult['_locale'],
                false,
                null,
                $rootNode
            );
            $this->cachedNodeTranslations[$key] = $nodeTranslation;
        }

        return $this->cachedNodeTranslations[$key];
    }
1126457
public function translate($slug = false, $params = [], $language = null)
    {
        return $this->trans($slug, $params, null, $language);
    }
500169
protected function getBoundaryAndChildStreams(ParentHeaderPart $part)
    {
        $boundary = $part->getHeaderParameter('Content-Type', 'boundary');
        if ($boundary === null) {
            return array_map(
                function ($child) {
                    return $child->getStream();
                },
                $part->getChildParts()
            );
        }
        $streams = [];
        foreach ($part->getChildParts() as $i => $child) {
            if ($i !== 0 || $part->hasContent()) {
                $streams[] = Psr7\stream_for("\r\n");
            }
            $streams[] = Psr7\stream_for("--$boundary\r\n");
            $streams[] = $child->getStream();
        }
        $streams[] = Psr7\stream_for("\r\n--$boundary--\r\n");
        
        return $streams;
    }
293138
protected function completeRoutePattern($parentId = null, $suffix = null, $language)
    {
        if (is_null($parentId) || '-' == $parentId || '' == $parentId) {
            return $suffix;
        }
        $siteId = $this->contextManager->getSiteId();
        $parent = $this->nodeRepository->findOnePublished($parentId, $language, $siteId);

        if ($parent instanceof NodeInterface) {
            return str_replace('//', '/', $this->completeRoutePattern($parent->getParentId(), $parent->getRoutePattern() . '/' . $suffix, $language));
        }

        return $suffix;
    }
357904
public function getNodeTranslationFor(HasNodeInterface $hasNode)
    {
        /* @var NodeVersion $nodeVersion */
        $nodeVersion = $this->getEntityManager()
            ->getRepository('KunstmaanNodeBundle:NodeVersion')
            ->getNodeVersionFor($hasNode);

        if (!is_null($nodeVersion)) {
            return $nodeVersion->getNodeTranslation();
        }

        return null;
    }
222980
public function getComments(LocaleEntity $locale, TranslatableEntity $translatable, TranslatableCommentEntity $parentComment = null)
    {
        $repo = $this->app->make(TranslatableCommentRepository::class);
        if ($parentComment === null) {
            $qb = $repo->createQueryBuilder('c');
            $qb
                ->where('c.translatable = :translatable')
                ->andWhere('c.parentComment is null')
                ->andWhere($qb->expr()->orX(
                    'c.locale = :locale',
                    'c.locale is null'
                ))
                ->orderBy('c.postedOn', 'ASC')
                ->setParameter('translatable', $translatable)
                ->setParameter('locale', $locale)
                ;
            $comments = $qb->getQuery()->getResult();
        } else {
            $comments = $repo->findBy(
                ['parentComment' => $parentComment],
                ['postedOn' => 'ASC']
            );
        }
        $result = [];
        $uh = $this->app->make(UserService::class);
        $dh = $this->app->make('helper/date');
        $me = new \User();
        $myID = $me->isRegistered() ? (int) $me->getUserID() : null;
        foreach ($comments as $comment) {
            $result[] = [
                'id' => $comment->getID(),
                'date' => $dh->formatPrettyDateTime($comment->getPostedOn(), true, true),
                'mine' => $myID && $myID === $comment->getPostedBy(),
                'by' => $uh->format($comment->getPostedBy()),
                'text' => $comment->getText(),
                'comments' => $this->getComments($locale, $translatable, $comment),
                'isGlobal' => $comment->getLocale() === null,
            ];
        }

        return $result;
    }
232635
public static function get_block_parent( \DOMNode $node ) {
		$parent = $node->parentNode;
		if ( ! $parent instanceof \DOMElement ) {
			return null;
		}

		while ( ! self::is_block_tag( $parent ) && $parent->parentNode instanceof \DOMElement ) {
			/**
			 * The parent is sure to be a \DOMElement.
			 *
			 * @var \DOMElement
			 */
			$parent = $parent->parentNode;
		}

		return $parent;
	}
296616
private function hasOfflineParents(NodeTranslation $nodeTranslation)
    {
        $lang = $nodeTranslation->getLang();
        $node = $nodeTranslation->getNode();
        if (null !== $this->em) {
            $em = $this->em;
        } else {
            $lang = $nodeTranslation->getLang();
            foreach ($nodeTranslation->getNode()->getParents() as $node) {
                $nodeNT = $node->getNodeTranslation($lang, true);
                if ($nodeNT && !$nodeNT->isOnline()) {
                    return true;
                }
            }
            return false;
        }

        foreach ($node->getParents() as $parent) {
            $parentNodeTranslation = $parent->getNodeTranslation($lang, true);
            if (null === $parentNodeTranslation) {
                continue;
            }
            $parentRef = $parentNodeTranslation->getRef($em);
            // Continue looping unless we find an offline page that is not a StructureNode
            if ($parentRef instanceof StructureNode || $parentNodeTranslation->isOnline()) {
                continue;
            }

            return true;
        }

        return false;
    }
888557
public function parseElement(Node $parent, \DOMElement $element)
    {
        if (AtomPub::NS === $element->namespaceURI) {
            switch ($element->localName) {
                case 'collection':
                    // Node name already checked
                    return new Collection($parent, $element);
                case 'workspace':
                    // Node name already checked
                    return new Workspace($parent, $element);
            }
        }

        return null;
    }
1327038
public function getOnlineChildrenQueryBuilder(Node $parent, $lang = null)
    {
        return $this->getChildrenQueryBuilder($parent, $lang)
            ->andWhere('nt.online = true');
    }
290334
public function parseElement(Node $parent, \DOMElement $element)
    {
        if (Atom::NS !== $element->namespaceURI) {
            return null;
        }

        $name = 'atom:' . $element->localName;
        if (array_key_exists($name, $this->elementMap)) {
            $class = $this->elementMap[$name];

            return new $class($parent, $element);
        }

        return null;
    }