Get locks that are passed the threshold.

@param NodeTranslation $nodeTranslation
@param int             $threshold

@return mixed
356641
public function getExpiredLocks(NodeTranslation $nodeTranslation, $threshold)
    {
        $qb = $this->createQueryBuilder('nvl')
            ->select('nvl')
            ->where('nvl.nodeTranslation = :nt')
            ->andWhere('nvl.createdAt < :date')
            ->setParameter('nt', $nodeTranslation)
            ->setParameter('date', new \DateTime(sprintf('-%s seconds', $threshold)));

        return $qb->getQuery()->getResult();
    }
1227969
public function getTranslations(
        array $domains = [],
        array $languages = [],
        callable $filter = null
    ) : array {
        $translations = array_filter(
            $this->translations,
            function (Translation $translation) {
                return $translation->getValue() != '';
            }
        );

        if (is_callable($filter)) {
            $translations = array_filter(
                $translations,
                $filter
            );
        }

        return $translations;
    }
643677
public function unPublish(NodeTranslation $nodeTranslation)
    {
        if (false === $this->authorizationChecker->isGranted(PermissionMap::PERMISSION_UNPUBLISH, $nodeTranslation->getNode())) {
            throw new AccessDeniedException();
        }

        $node = $nodeTranslation->getNode();
        $nodeVersion = $nodeTranslation->getPublicNodeVersion();
        $page = $nodeVersion->getRef($this->em);

        $this->eventDispatcher->dispatch(
            Events::PRE_UNPUBLISH,
            new NodeEvent($node, $nodeTranslation, $nodeVersion, $page)
        );
        $nodeTranslation->setOnline(false);
        $this->em->persist($nodeTranslation);
        $this->em->flush();

        // Remove scheduled task
        $this->unSchedulePublish($nodeTranslation);

        $this->eventDispatcher->dispatch(
            Events::POST_UNPUBLISH,
            new NodeEvent($node, $nodeTranslation, $nodeVersion, $page)
        );
    }
695727
protected function getNumUnvisitedChildren(Node $node) {
    $cacheSection = $this->getRequestValue('cacheSection');
    $exportedOids = $this->cache->get($cacheSection, self::CACHE_KEY_EXPORTED_OIDS);

    $childOIDs = [];
    $mapper = $node->getMapper();
    $relations = $mapper->getRelations('child');
    foreach ($relations as $relation) {
      if ($relation->getOtherNavigability()) {
        $childValue = $node->getValue($relation->getOtherRole());
        if ($childValue != null) {
          $children = $relation->isMultiValued() ? $childValue : [$childValue];
          foreach ($children as $child) {
            $childOIDs[] = $child->getOID();
          }
        }
      }
    }
    $numUnvisitedChildren = 0;
    foreach ($childOIDs as $childOid) {
      if (!in_array($childOid->__toString(), $exportedOids)) {
        $numUnvisitedChildren++;
      }
    }
    return $numUnvisitedChildren;
  }
559609
public String queryLock (NodeObject.Lock lock)
    {
        for (NodeObject nodeobj : getNodeObjects()) {
            if (nodeobj.locks.contains(lock)) {
                return nodeobj.nodeName;
            }
        }
        return null;
    }
1265745
public function createPageDraftFromOtherLanguage(Node $node, $sourceNodeTranslationId, $locale)
    {
        $user = $this->getAdminUser();

        $sourceNodeTranslation = $this->em->getRepository(NodeTranslation::class)->find($sourceNodeTranslationId);
        $sourceNodeVersion = $sourceNodeTranslation->getPublicNodeVersion();
        $sourcePage = $sourceNodeVersion->getRef($this->em);
        $targetPage = $this->cloneHelper->deepCloneAndSave($sourcePage);

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

        $this->eventDispatcher->dispatch(
            Events::RECOPY_PAGE_TRANSLATION,
            new RecopyPageTranslationNodeEvent(
                $node,
                $nodeTranslation,
                $nodeVersion,
                $targetPage,
                $sourceNodeTranslation,
                $sourceNodeVersion,
                $sourcePage,
                $sourceNodeTranslation->getLang()
            )
        );

        return $nodeTranslation;
    }
168309
public function getTranslations(
        array $domains = [],
        array $languages = [],
        callable $filter = null
    ) : array {
        return $this
            ->translationCollection
            ->getTranslations(
                $domains,
                $languages,
                $filter
            );
    }
918467
public function setTranslatable(TranslatableInterface $translatable = null)
    {
        if ($this->translatable == $translatable) {
            return $this;
        }
    
        $old = $this->translatable;
        $this->translatable = $translatable;
    
        if ($old !== null) {
            $old->removeTranslation($this);
        }
    
        if ($translatable !== null) {
            $translatable->addTranslation($this);
        }
    
        return $this;
    }
1356917
public function __getTranslatableExtension(Record $record, $key)
    {
        /**
         * Check that translatable field exists in database.
         */
        if (!$this->getRepository()->getCache()->tableHasField(
            $this->getTable() . $this->getTranslatableTableSuffix(),
            $key
        )
        ) {
            return null;
        }

        if (!$record->relationExists('_translations')) {
            /**
             * Fetch translations.
             */
            $record->withTranslations();
        }

        /**
         * Translations were fetched by join.
         */
        foreach ($record->getRelation('_translations') as $translation) {
            if ($translation->keyExists($key)) {
                return $translation->{$key};
            }
        }
    }
1133676
private function getNodeTranslationMap()
    {
        if (is_null($this->nodeTranslationMap)) {
            $sql = 'SELECT id, url, lang FROM kuma_node_translations';
            $stmt = $this->em->getConnection()->prepare($sql);
            $stmt->execute();
            $this->nodeTranslationMap = $stmt->fetchAll();
        }

        return $this->nodeTranslationMap;
    }
300761
public function getNodeTranslationForSlug(
        $slug,
        NodeTranslation $parentNode = null
    ) {
        if (empty($slug)) {
            return $this->getNodeTranslationForSlugPart(null, $slug);
        }

        $slugParts = explode('/', $slug);
        $result = $parentNode;
        foreach ($slugParts as $slugPart) {
            $result = $this->getNodeTranslationForSlugPart($result, $slugPart);
        }

        return $result;
    }
284661
public function joinFallbackTranslation(callable $callable = null)
    {
        if ($this->translatableLang->langId() == 'en') {
            return $this;
        }

        $selects = [];
        $translaTable = $this->getTable() . $this->translatableTableSuffix;
        $fields = $this->getRepository()->getCache()->getTableFields($translaTable);
        $translatableKey = '`' . $translaTable . '`.`id`';
        foreach ($fields as $field) {
            if (in_array($field, ['id', $this->translatableLanguageField])) {
                continue;
            }

            $translatableField = '`' . $translaTable . '`.`' . $field . '`';
            $fallbackField = '`' . $translaTable . '_f`.`' . $field . '`';
            $selects[] = 'IF(' . $translatableKey . ', ' . $translatableField . ', ' . $fallbackField . ') AS `' .
                $field . '`';
        }

        $relation = $this->join($this->translationsFallback($callable));

        $relation->getQuery()->addSelect($selects);

        return $relation;
    }
1107840
public function getNodeTranslationsQueryBuilder($lang = null)
    {
        $queryBuilder = $this->createQueryBuilder('nt')
            ->select('nt,n,v')
            ->innerJoin('nt.node', 'n')
            ->leftJoin(
                'nt.publicNodeVersion',
                'v',
                'WITH',
                'nt.publicNodeVersion = v.id'
            )
            ->where('n.deleted = false')
            ->orderBy('nt.weight')
            ->addOrderBy('nt.weight');

        if (!empty($lang)) {
            $queryBuilder
                ->andWhere('nt.lang = :lang')
                ->setParameter('lang', $lang);
        }

        return $queryBuilder;
    }
806468
public function commonGivenMaleList(int $threshold = 1, int $maxtoshow = 10): string
    {
        return $this->commonGivenQuery('M', 'list', false, $threshold, $maxtoshow);
    }
834764
public function getTranslations(LocaleEntity $locale, TranslatableEntity $translatable)
    {
        $numPlurals = $locale->getPluralCount();

        $result = [
            'current' => null,
            'others' => [],
        ];
        $translations = $this->app->make(TranslationRepository::class)->findBy(['translatable' => $translatable, 'locale' => $locale], ['createdOn' => 'DESC']);
        $dh = $this->app->make('helper/date');
        $uh = $this->app->make(UserService::class);
        foreach ($translations as $translation) {
            /* @var \CommunityTranslation\Entity\Translation $translation */
            $texts = [];
            switch (($translatable->getPlural() === '') ? 1 : $numPlurals) {
                case 6:
                    $texts[] = $translation->getText5();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 5:
                    $texts[] = $translation->getText4();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 4:
                    $texts[] = $translation->getText3();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 3:
                    $texts[] = $translation->getText2();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 2:
                    $texts[] = $translation->getText1();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 1:
                default:
                    $texts[] = $translation->getText0();
                    break;
            }
            $item = [
                'id' => $translation->getID(),
                'createdOn' => $dh->formatPrettyDateTime($translation->getCreatedOn(), false, true),
                'createdBy' => $uh->format($translation->getCreatedBy()),
                'approved' => $translation->isApproved(),
                'translations' => array_reverse($texts),
            ];
            if ($translation->isCurrent()) {
                $item['currentSince'] = $dh->formatPrettyDateTime($translation->getCurrentSince(), false, true);
                $result['current'] = $item;
            } else {
                $result['others'][] = $item;
            }
        }

        return $result;
    }
684427
public function setThreshold($threshold)
    {

        // need to return << true
        if (is_array($threshold) === true) {
            $threshold = array_map('intval', array_splice($threshold, 0, 2));
        }

        else {
            $threshold = intval($threshold);
        }
        $this->validator->verify($threshold, [], 'threshold');

        return $this;
    }
343627
protected function getTotalCount(Criterion $criterion, array $languageFilter)
    {
        $query = $this->handler->createSelectQuery();
        $query
            ->select($query->alias($query->expr->count('*'), 'count'))
            ->from($this->handler->quoteTable('ezcontentobject_tree'))
            ->innerJoin(
                'ezcontentobject',
                'ezcontentobject_tree.contentobject_id',
                'ezcontentobject.id'
            )
            ->innerJoin(
                'ezcontentobject_version',
                'ezcontentobject.id',
                'ezcontentobject_version.contentobject_id'
            );

        $query->where(
            $this->criteriaConverter->convertCriteria($query, $criterion, $languageFilter),
            $query->expr->eq(
                'ezcontentobject.status',
                //ContentInfo::STATUS_PUBLISHED
                $query->bindValue(1, null, PDO::PARAM_INT)
            ),
            $query->expr->eq(
                'ezcontentobject_version.status',
                //VersionInfo::STATUS_PUBLISHED
                $query->bindValue(1, null, PDO::PARAM_INT)
            ),
            $query->expr->neq(
                $this->handler->quoteColumn('depth', 'ezcontentobject_tree'),
                $query->bindValue(0, null, PDO::PARAM_INT)
            )
        );

        // If not main-languages query
        if (!empty($languageFilter['languages'])) {
            $query->where(
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->handler->quoteColumn('language_mask', 'ezcontentobject'),
                        $query->bindValue(
                            $this->getLanguageMask($languageFilter),
                            null,
                            PDO::PARAM_INT
                        )
                    ),
                    $query->bindValue(0, null, PDO::PARAM_INT)
                )
            );
        }

        $statement = $query->prepare();
        $statement->execute();

        return (int)$statement->fetchColumn();
    }