Document/Index/ArticleIndexer.php
protected function findOrCreateViewDocument(ArticleDocument $document, $locale, $localizationState)
    {
        $articleId = $this->getViewDocumentId($document->getUuid(), $locale);
        /** @var ArticleViewDocumentInterface $article */
        $article = $this->manager->find($this->documentFactory->getClass('article'), $articleId);

        if ($article) {
            // Only index ghosts when the article isn't a ghost himself.
            if (LocalizationState::GHOST === $localizationState
                && LocalizationState::GHOST !== $article->getLocalizationState()->state
            ) {
                return null;
            }

            return $article;
        }

        $article = $this->documentFactory->create('article');
        $article->setId($articleId);
        $article->setUuid($document->getUuid());
        $article->setLocale($locale);

        return $article;
    }
protected function findOrCreateViewDocument(ArticleDocument $document, $locale, $localizationState)
    {
        $articleId = $this->getViewDocumentId($document->getUuid(), $locale);
        /** @var ArticleViewDocumentInterface $article */
        $article = $this->manager->find($this->documentFactory->getClass('article'), $articleId);

        if ($article) {
            // Only index ghosts when the article isn't a ghost himself.
            if (LocalizationState::GHOST === $localizationState
                && LocalizationState::GHOST !== $article->getLocalizationState()->state
            ) {
                return null;
            }

            return $article;
        }

        $article = $this->documentFactory->create('article');
        $article->setId($articleId);
        $article->setUuid($document->getUuid());
        $article->setLocale($locale);

        return $article;
    }
protected function findOrCreateViewDocument ( ArticleDocument $ document , $ locale , $ localizationState ) { $ articleId = $ this -> getViewDocumentId ( $ document -> getUuid ( ) , $ locale ) ; /** @var ArticleViewDocumentInterface $article */ $ article = $ this -> manager -> find ( $ this -> documentFactory -> getClass ( 'article' ) , $ articleId ) ; if ( $ article ) { // Only index ghosts when the article isn't a ghost himself. if ( LocalizationState :: GHOST === $ localizationState && LocalizationState :: GHOST !== $ article -> getLocalizationState ( ) -> state ) { return null ; } return $ article ; } $ article = $ this -> documentFactory -> create ( 'article' ) ; $ article -> setId ( $ articleId ) ; $ article -> setUuid ( $ document -> getUuid ( ) ) ; $ article -> setLocale ( $ locale ) ; return $ article ; }
Returns view-document from index or create a new one.

@param ArticleDocument $document
@param string $locale
@param string $localizationState

@return ArticleViewDocumentInterface
Returns view - document from index or create a new one .