@param string          $siteId
@param DocumentManager $dm

@return array
@throws \Doctrine\ODM\MongoDB\MongoDBException
177588
protected function getNodeIdsInSite($siteId, DocumentManager $dm)
    {
        $qb = $dm->createQueryBuilder(Node::class)->hydrate(false);
        $qb->field('deleted')->equals(false)
            ->field('siteId')->equals($siteId)
            ->distinct('nodeId');

        return $qb->getQuery()->execute()->toArray();
    }
959557
public function getDataBySiteIdAndEnv($siteId, $siteEnv) 
	{
	    $select = $this->tableGateway->getSql()->select();
	    
	    $select->columns(array('*'));
	    
	    $select->where(array("sdom_site_id" => $siteId, 'sdom_env' => $siteEnv));
	    $resultSet = $this->tableGateway->selectWith($select);
	    
	    return $resultSet;
	}
657089
public function addDocumentIds(\AgentSIB\Diadoc\Api\Proto\DocumentId $value)
    {
        if ($this->DocumentIds === null) {
            $this->DocumentIds = new \Protobuf\MessageCollection();
        }

        $this->DocumentIds->add($value);
    }
1356998
public function generate($document, ClassMetadata $class, DocumentManagerInterface $dm, $parent = null)
    {
        if (null === $parent) {
            $parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null;
        }

        $id = $class->getFieldValue($document, $class->identifier);
        if (empty($id) && null === $parent) {
            throw IdException::noIdNoParent($document, $class->parentMapping);
        }

        if (empty($parent)) {
            return $id;
        }

        try {
            $parentNode = $dm->getNodeForDocument($parent);
            $existingNames = (array) $parentNode->getNodeNames();
        } catch (RepositoryException $e) {
            // this typically happens while cascading persisting documents
            $existingNames = [];
        }
        $name = NodeHelper::generateAutoNodeName(
            $existingNames,
            $dm->getPhpcrSession()->getWorkspace()->getNamespaceRegistry()->getNamespaces(),
            '',
            ''
        );

        return $this->buildName($document, $class, $dm, $parent, $name);
    }
1077506
private function managePublishDocument(&$params, &$dmsLoader, &$manageCategory, &$arrMessages, &$blnShowStart, $documentId)
  {
    $params->loadRootCategory = true; // get complete path to root, for checking inherited access rights
    $params->loadAccessRights = true;
    $params->loadDocuments = false;
    $category = $dmsLoader->loadCategory($manageCategory, $params);
    
    if (!$category->isPublishableForCurrentMember())
    {
      $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['manage_document_not_allowed'];
      $blnShowStart = true;
    }
    else
    {
      $document = $dmsLoader->loadDocument($documentId, $params);
      
      if ($document != null)
      {
        if (!$document->isPublished())
        {
          $document->lasteditMemberId = $this->Member->id;
          $document->lasteditDate = time();
          $document->published = true;
          
          $dmsWriter = \DmsWriter::getInstance();
          $document = $dmsWriter->updateDocument($document);
          $arrMessages['successes'][] = $GLOBALS['TL_LANG']['DMS']['SUCCESS']['document_successfully_published'];
        }
        else
        {
          $arrMessages['infos'][] = $GLOBALS['TL_LANG']['DMS']['INFO']['document_already_published'];
        }
      }
      else
      {
        $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['manage_document_not_found'];
      }
      $this->manageSelectDocument($params, $dmsLoader, $manageCategory, $arrMessages, $blnShowStart);
    }
  }
1082862
public function loadDocument($documentId, \DmsLoaderParams $params)
  {
    $objDocument = $this->Database->prepare("SELECT d.*, CONCAT(m1.firstname, ' ', m1.lastname) AS upload_member_name, CONCAT(m2.firstname, ' ', m2.lastname) AS lastedit_member_name "
                        . "FROM tl_dms_documents d "
                        . "LEFT JOIN tl_member m1 ON m1.id = d.upload_member "
                        . "LEFT JOIN tl_member m2 ON m2.id = d.lastedit_member "
                        . "WHERE d.id = ?")
                    ->limit(1)
                    ->execute($documentId);
    
    $document = null;
    if ($objDocument->numRows)
    {
      $document = $this->buildDocument($objDocument);
      if ($params->loadCategory)
      {
        $document->category = $this->loadCategory($document->categoryId, $params);
      }
    }

    return $document;
  }
836331
public function getDataBySiteIdAndPageId($siteId, $pageId)
	{
	    $select = $this->tableGateway->getSql()->select();
	     
	    $select->columns(array('*'));
	     
	    $select->where(array("s404_site_id" => $siteId, 's404_page_id' => $pageId));
	    $resultSet = $this->tableGateway->selectWith($select);
	     
	    return $resultSet;
	}
941457
public function getDocumentPersister($documentName)
    {
        if (!isset($this->persisters[$documentName])) {
            $pb                              = $this->getPersistenceBuilder();
            $this->persisters[$documentName] = new Persister\DocumentPersister(
                $pb,
                $this->dm,
                $this,
                $this->hydratorFactory,
                $this->dm->getClassMetadata($documentName)
            );
        }

        return $this->persisters[$documentName];
    }
1160004
public static function setApplicationDocumentManager(Application $application, ?string $dmName)
    {
        /** @var $registry ManagerRegistry */
        $registry = $application->getKernel()->getContainer()->get('doctrine_phpcr');
        $documentManager = $registry->getManager($dmName);

        $helperSet = $application->getHelperSet();
        $helperSet->set(new DocumentManagerHelper(null, $documentManager));
    }
911504
public function getSiteDetails($siteId)
    {
        if ($this->connector->getURL() === null) {
            return 'Cannot find site URL from configuration.';
        }
        $url = $this->connector->getURL().self::VERSION.$siteId;
        $params = [];
        $response = $this->connector->connecting($url, $params, 'GET');

        return $response;
    }
606982
public function findAllowedSites($siteId)
    {
        $qb = $this->createQueryBuilder();
        $qb->field('allowedSites')->in(array($siteId));

        return $qb->getQuery()->execute();
    }
1054391
public function getActiveSiteTheme($siteId)
    {
        $qb = $this->getEntityManager()->createQueryBuilder();
        /** @var $query \Doctrine\ORM\Query */

        $query = $qb->select('e, t')
            ->from($this->_entity, 'e')
            ->innerJoin('e.themeId', 't')
            ->where('e.siteId = :id')
            ->andWhere('e.isActive = 1')
            ->setMaxResults(1)
            ->setParameter('id', $siteId)
            ->getQuery();

        /** @var $result \PageBuilder\Entity\Join\SiteTheme */
        $result = $query->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT);
        if ($result) {
            return $result->getThemeId();
        } else {
            return $result;
        }
    }
403594
public function getPerimeterConfiguration($siteId)
    {
        $treeNodes = $this->nodeRepository->findTreeNode(
            $siteId,
            $this->contextManager->getSiteContributionLanguage(),
            NodeInterface::ROOT_PARENT_ID
        );

        return $this->getTreePerimeterConfiguration($treeNodes);
    }
164946
public function findUsageReferenceInOtherSite($siteId, $entities)
    {
        $usedOtherSite = array();
        $supportedEntities = array(BlockInterface::ENTITY_TYPE, ContentInterface::ENTITY_TYPE);
        /** @var UseTrackableInterface $entity */
        foreach ($entities as $entity) {
            $references = $entity->getUseReferences();
            $entityReferences = array(
                'entity' => $entity,
                'references' => array()
            );
            if (!empty($references)) {
                foreach ($references as $type => $reference) {
                    if (in_array($type, $supportedEntities)) {
                        $referenceIds = array_keys($reference);
                        $repo = $this->getRepositoryByType($type);
                        foreach ($referenceIds as $referenceId) {
                            $referenceEntity = $repo->findById($referenceId);
                            if (
                                $siteId !== $referenceEntity->getSiteId()
                            ) {
                                $entityReferences['references'][$type][$referenceEntity->getId()] = $referenceEntity;
                            }
                        }
                    }
                }
                $usedOtherSite[] = $entityReferences;
            }
        }

        return $usedOtherSite;
    }
1277345
public function getActiveTheme($siteId)
    {
        $manager = $this->getEntityManager();
        $query   = $manager
            ->createQueryBuilder()
            ->select('t,s')
            ->from($this->_entity, 't')
            ->innerJoin('t.siteThemes', 's')
            ->where('s.siteId = :id')
            ->andWhere('s.isActive = 1')
            ->setParameter(':id', $siteId)
            ->setMaxResults(1)
            ->getQuery();

        try {
            return $query->getSingleResult(AbstractQuery::HYDRATE_OBJECT);
        } catch (NoResultException $e) {
            return false;
        } catch (NonUniqueResultException $e) {
            return false;
        }
    }
275350
public function getRedirectEntityList($siteId)
    {
        try {
            $result = $this->getRedirectQuery($siteId)->getResult();
        } catch (NoResultException $e) {
            $result = [];
        }

        return $result;
    }
416
private function manageDeleteDocument(&$params, &$dmsLoader, &$manageCategory, &$arrMessages, &$blnShowStart, $documentId)
  {
    $params->loadRootCategory = true; // get complete path to root, for checking inherited access rights
    $params->loadAccessRights = true;
    $params->loadDocuments = false;
    $category = $dmsLoader->loadCategory($manageCategory, $params);
    
    if (!$category->isDeletableForCurrentMember())
    {
      $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['manage_document_not_allowed'];
      $blnShowStart = true;
    }
    else
    {
      $document = $dmsLoader->loadDocument($documentId, $params);
      
      if ($document != null)
      {
        // delete the document in the database
        $dmsWriter = \DmsWriter::getInstance();
        
        if ($dmsWriter->deleteDocument($document))
        {
          $arrMessages['successes'][] = $GLOBALS['TL_LANG']['DMS']['SUCCESS']['document_successfully_deleted'];
          
          // delete the file
          $filePath = \DmsConfig::getDocumentFilePath($document->getFileNameVersioned());
          if (file_exists(TL_ROOT . '/' . $filePath))
          {
            unlink($filePath);
            \Dbafs::deleteResource($filePath);
            
            $arrMessages['successes'][] = $GLOBALS['TL_LANG']['DMS']['SUCCESS']['document_file_successfully_deleted'];
          }
          else
          {
            $arrMessages['infos'][] = $GLOBALS['TL_LANG']['DMS']['INFO']['document_delete_file_not_exists'];
          }
        }
        else
        {
          $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['delete_document_failed'];
        }
      }
      else
      {
        $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['manage_document_not_found'];
      }
      $this->manageSelectDocument($params, $dmsLoader, $manageCategory, $arrMessages, $blnShowStart);
    }
  }