@param NodeTranslation $nodeTranslation
@param BaseUser        $userToExclude
@param bool            $isPublicNodeVersion

@return array
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;
            },
            []
        );
    }
399704
public function findSiteCandidatesForCloning(NodeInterface $node, $userId)
    {
        /*
         * The right and only working query for this.
         *
            SELECT DISTINCT(sa.site_id)
            FROM ucms_site_access sa
            JOIN ucms_site_node sn ON sn.site_id = sa.site_id
            WHERE
                sa.uid = 13 -- current user
                AND sn.
                AND sa.role = 1 -- webmaster
                AND sa.site_id <> 2 -- node current site
                AND NOT EXISTS (
                    SELECT 1
                    FROM node en
                    WHERE
                        en.site_id = sa.site_id
                        AND (
                            en.parent_nid = 6 -- node we are looking for
                            OR nid = 6
                        )
                )
            ;
          */

        $sq = $this
            ->db
            ->select('node', 'en')
            ->where('en.site_id = sa.site_id')
            ->where('en.parent_nid = :nid1 OR nid = :nid2', [':nid1' => $node->id(), ':nid2' => $node->id()])
        ;

        $sq->addExpression('1');

        $q = $this
            ->db
            ->select('ucms_site_access', 'sa')
            ->fields('sa', ['site_id'])
            ->condition('sa.uid', $userId)
            ->condition('sa.role', Access::ROLE_WEBMASTER)
        ;

        $q->join('ucms_site_node', 'sn', 'sn.site_id = sa.site_id');
        $q->condition('sn.nid', $node->id());

        // The node might not be attached to any site if it is a global content
        if ($node->site_id) {
            $q->condition('sa.site_id', $node->site_id, '<>');
        }

        $idList = $q
            ->notExists($sq)
            ->addTag('ucms_site_access')
            ->execute()
            ->fetchCol()
        ;

        return $this->manager->getStorage()->loadAll($idList);
    }
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;
    }
1214514
public function expandCustomerTransferWithProductListIds(CustomerTransfer $customerTransfer): CustomerTransfer
    {
        if ($this->hasCustomerTransferProductLists($customerTransfer)) {
            return $customerTransfer;
        }

        $companyUserTransfer = $customerTransfer->getCompanyUserTransfer();

        if ($companyUserTransfer === null || $companyUserTransfer->getCompany() === null) {
            return $customerTransfer;
        }

        $productListCollectionTransfer = $this->productListReader->getProductListCollectionByIdCompanyId(
            $companyUserTransfer->getCompany()
        );

        $this->addProductListsToCustomerTransfer($customerTransfer, $productListCollectionTransfer);

        return $customerTransfer;
    }
871473
protected function getEntityVersionLocksByLockableEntity(LockableEntity $entity, User $userToExclude = null)
    {
        /** @var EntityVersionLockRepository $objectRepository */
        $objectRepository = $this->objectManager->getRepository('KunstmaanAdminListBundle:EntityVersionLock');

        return $objectRepository->getLocksForLockableEntity($entity, $this->threshold, $userToExclude);
    }
900536
public function enterNode(NodeInterface $node): VisitorResult
    {
        $schema = $this->typeInfo->getSchema();

        if ($node instanceof SelectionSetNode) {
            $namedType = getNamedType($this->typeInfo->getType());
            $this->typeInfo->pushParentType($namedType instanceof CompositeTypeInterface ? $namedType : null);
        } elseif ($node instanceof FieldNode) {
            $parentType      = $this->typeInfo->getParentType();
            $fieldDefinition = null;
            $fieldType       = null;
            if (null !== $parentType) {
                $fieldDefinition = $this->typeInfo->resolveFieldDefinition($schema, $parentType, $node);
                if (null !== $fieldDefinition) {
                    $fieldType = $fieldDefinition->getType();
                }
            }
            $this->typeInfo->pushFieldDefinition($fieldDefinition);
            $this->typeInfo->pushType(isOutputType($fieldType) ? $fieldType : null);
        } elseif ($node instanceof DirectiveNode) {
            $this->typeInfo->setDirective($schema->getDirective($node->getNameValue()));
        } elseif ($node instanceof OperationDefinitionNode) {
            $type      = null;
            $operation = $node->getOperation();
            if ($operation === 'query') {
                $type = $schema->getQueryType();
            } elseif ($operation === 'mutation') {
                $type = $schema->getMutationType();
            } elseif ($operation === 'subscription') {
                $type = $schema->getSubscriptionType();
            }
            $this->typeInfo->pushType($type instanceof ObjectType ? $type : null);
        } elseif ($node instanceof InlineFragmentNode || $node instanceof FragmentDefinitionNode) {
            $typeCondition = $node->getTypeCondition();
            $outputType    = null !== $typeCondition
                ? TypeASTConverter::convert($schema, $typeCondition)
                : getNamedType($this->typeInfo->getType());
            $this->typeInfo->pushType(isOutputType($outputType) ? $outputType : null);
        } elseif ($node instanceof VariableDefinitionNode) {
            $inputType = TypeASTConverter::convert($schema, $node->getType());
            /** @noinspection PhpParamsInspection */
            $this->typeInfo->pushInputType(isInputType($inputType) ? $inputType : null);
        } elseif ($node instanceof ArgumentNode) {
            $argumentType       = null;
            $argumentDefinition = null;
            $fieldOrDirective   = $this->typeInfo->getDirective() ?: $this->typeInfo->getFieldDefinition();
            if (null !== $fieldOrDirective) {
                $argumentDefinition = find(
                    $fieldOrDirective->getArguments(),
                    function (Argument $argument) use ($node) {
                        return $argument->getName() === $node->getNameValue();
                    }
                );
                if (null !== $argumentDefinition) {
                    $argumentType = $argumentDefinition->getType();
                }
            }
            $this->typeInfo->setArgument($argumentDefinition);
            $this->typeInfo->pushInputType(isInputType($argumentType) ? $argumentType : null);
        } elseif ($node instanceof ListValueNode) {
            $listType = getNullableType($this->typeInfo->getInputType());
            $itemType = $listType instanceof ListType ? $listType->getOfType() : $listType;
            $this->typeInfo->pushInputType(isInputType($itemType) ? $itemType : null);
        } elseif ($node instanceof ObjectFieldNode) {
            $objectType     = getNamedType($this->typeInfo->getInputType());
            $inputFieldType = null;
            if ($objectType instanceof InputObjectType) {
                $fields     = $objectType->getFields();
                $inputField = $fields[$node->getNameValue()] ?? null;
                if (null !== $inputField) {
                    $inputFieldType = $inputField->getType();
                }
            }
            /** @noinspection PhpParamsInspection */
            $this->typeInfo->pushInputType(isInputType($inputFieldType) ? $inputFieldType : null);
        } elseif ($node instanceof EnumValueNode) {
            $enumType  = getNamedType($this->typeInfo->getInputType());
            $enumValue = null;
            if ($enumType instanceof EnumType) {
                $enumValue = $enumType->getValue($node->getValue());
            }
            $this->typeInfo->setEnumValue($enumValue);
        }

        return $this->visitor->enterNode($node);
    }
571339
public function getChildren(
        ResourceNode $node,
        array $roles,
        $user,
        $withLastOpenDate = false,
        $canAdministrate = false
    ) {
        return $this->resourceNodeRepo->findChildren($node, $roles, $user, $withLastOpenDate, $canAdministrate);
    }
771832
public function expandCustomerTransferWithProductListIds(CustomerTransfer $customerTransfer): CustomerTransfer
    {
        $customerTransfer->setCustomerProductListCollection(new CustomerProductListCollectionTransfer());

        $productListCollectionTransfer = $this->productListReader->getProductListCollectionByIdCustomerId(
            $customerTransfer
        );

        $this->addProductListsToCustomerTransfer($customerTransfer, $productListCollectionTransfer);

        return $customerTransfer;
    }
1001451
public function getTranslatedList($user_id, $status = true)
    {
        $conditions = array(
            'status' => $status,
            'user_id' => $user_id
        );

        $addresses = array();
        foreach ((array) $this->getList($conditions) as $address_id => $address) {
            $addresses[$address_id] = $this->getTranslated($address, true);
        }

        return $addresses;
    }
1069401
static function processNodeTransformation( $useComments, $php, $tpl, &$node, &$resourceData, &$newNode )
    {
        $newNode = eZTemplateCompiler::processNodeTransformationRoot( $useComments, $php, $tpl, $node, $resourceData );
    }
1093473
public function copyPageFromOtherLanguage(Node $node, $sourceLocale, $locale)
    {
        $user = $this->getAdminUser();

        $sourceNodeTranslation = $node->getNodeTranslation($sourceLocale, true);
        $sourceNodeVersion = $sourceNodeTranslation->getPublicNodeVersion();
        $sourcePage = $sourceNodeVersion->getRef($this->em);
        $targetPage = $this->cloneHelper->deepCloneAndSave($sourcePage);

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

        $this->eventDispatcher->dispatch(
            Events::COPY_PAGE_TRANSLATION,
            new CopyPageTranslationNodeEvent(
                $node,
                $nodeTranslation,
                $nodeVersion,
                $targetPage,
                $sourceNodeTranslation,
                $sourceNodeVersion,
                $sourcePage,
                $sourceLocale
            )
        );

        return $nodeTranslation;
    }
13385
static function processNodeTransformationNodes( $tpl, &$node, &$nodes, &$privateData )
    {
        $useComments = $privateData['use-comments'];
        $php =& $privateData['php-creator'];
        $resourceData =& $privateData['resource-data'];
        return eZTemplateCompiler::processNodeTransformationChildren( $useComments, $php, $tpl, $node, $nodes, $resourceData );
    }
23716
public function getNodeTranslations($includeOffline = false)
    {
        return $this->nodeTranslations
            ->filter(function (NodeTranslation $entry) use ($includeOffline) {
                if ($includeOffline || $entry->isOnline()) {
                    return true;
                }

                return false;
            }
            );
    }
814423
public function isNodeVersionLocked(BaseUser $user, NodeTranslation $nodeTranslation, $isPublicNodeVersion)
    {
        if ($this->container->getParameter('kunstmaan_node.lock_enabled')) {
            $this->removeExpiredLocks($nodeTranslation);
            $this->createNodeVersionLock($user, $nodeTranslation, $isPublicNodeVersion); // refresh lock
            $locks = $this->getNodeVersionLocksByNodeTranslation($nodeTranslation, $isPublicNodeVersion, $user);

            return count($locks) ? true : false;
        }

        return false;
    }
1336560
protected function createNodeVersionLock(BaseUser $user, NodeTranslation $nodeTranslation, $isPublicVersion)
    {
        $lock = $this->objectManager->getRepository('KunstmaanNodeBundle:NodeVersionLock')->findOneBy([
            'owner' => $user->getUsername(),
            'nodeTranslation' => $nodeTranslation,
            'publicVersion' => $isPublicVersion,
        ]);
        if (!$lock) {
            $lock = new NodeVersionLock();
        }
        $lock->setOwner($user->getUsername());
        $lock->setNodeTranslation($nodeTranslation);
        $lock->setPublicVersion($isPublicVersion);
        $lock->setCreatedAt(new \DateTime());

        $this->objectManager->persist($lock);
        $this->objectManager->flush();
    }
45881
public function hasTranslation($language_id = null, $checkIsPublished = true)
    {
        /** @var \DevGroup\Multilingual\Multilingual $multilingual */
        $multilingual = Yii::$app->multilingual;
        if ($language_id === null) {
            $language_id = $multilingual->language_id;
        }
        /** @var ActiveRecord $owner */
        $owner = $this->owner;

        if ($language_id === $multilingual->language_id) {
            // we were asked for default language
            /** @var ActiveRecord $translation */
            $translation = $owner->{$this->defaultTranslationRelation};
            if ($translation === null) {
                return false;
            }

            if ($checkIsPublished === true) {
                return $this->checkIsPublished($translation);
            }
        }

        /* @var ActiveRecord $translation */
        foreach ($owner->{$this->translationRelation} as $translation) {
            if ($translation->getAttribute('language_id') === $language_id) {
                if ($checkIsPublished === true) {
                    return $this->checkIsPublished($translation);
                } else {
                    return true;
                }
            }
        }
        return false;
    }
616423
public function saveExtension(
        $uuid,
        $data,
        $extensionName,
        $webspaceKey,
        $locale,
        $userId
    ) {
        $document = $this->loadDocument(
            $uuid,
            $locale,
            [
                'exclude_ghost' => true,
            ]
        );

        if (null === $document) {
            throw new TranslatedNodeNotFoundException($uuid, $locale);
        }

        if (!$document instanceof ExtensionBehavior) {
            throw new \RuntimeException(
                sprintf(
                    'Document of class "%s" must implement the ExtensionableBehavior if it is to be extended',
                    get_class($document)
                )
            );
        }

        // save data of extensions
        $extension = $this->extensionManager->getExtension($document->getStructureType(), $extensionName);
        $node = $this->inspector->getNode($document);

        $extension->save($node, $data, $webspaceKey, $locale);
        $extensionData = $extension->load($node, $webspaceKey, $locale);

        $document->setExtension($extension->getName(), $extensionData);

        $this->documentManager->flush();

        $structure = $this->documentToStructure($document);

        $event = new ContentNodeEvent($node, $structure);
        $this->eventDispatcher->dispatch(ContentEvents::NODE_POST_SAVE, $event);

        return $structure;
    }