bundles/Devkitchen/DocumentIndexingBundle/src/DataExtractorService/DataExtractorService.php line 46

Open in your IDE?
  1. <?php
  2.     /**
  3.      * project: Pimcore - Schutzverband Nuernberg Rostbratwuerste
  4.      * User: erikb
  5.      * Year: 2022
  6.      */
  7.     namespace Devkitchen\DocumentIndexingBundle\DataExtractorService;
  8.     use Devkitchen\DocumentIndexingBundle\DataExtractorService\DocumentTypeHandler\DocumentTypeHandlerInterface;
  9.     use Pimcore\Model\Document;
  10.     use Pimcore\Model\Document\Page;
  11.     class DataExtractorService {
  12.         private Page $document;
  13.         private DocumentTypeHandlerFactory $documentTypeHandlerFactory;
  14.         private DocumentTypeHandlerInterface $documentTypeHandler;
  15.         public function __construct(DocumentTypeHandlerFactory $documentTypeHandlerFactory) {
  16.             $this->documentTypeHandlerFactory $documentTypeHandlerFactory;
  17.         }
  18.         /**
  19.          * @param Document $document
  20.          *
  21.          * @return DocumentTypeHandlerInterface|null
  22.          * @throws \Exception
  23.          */
  24.         public function createDocument $document ): DocumentTypeHandlerInterface null {
  25.             try {
  26.                 $this->documentTypeHandler $this->documentTypeHandlerFactory->create$document );
  27.                 return $this->documentTypeHandler;
  28.             }
  29.             catch (\InvalidArgumentException $exception) {
  30.                 throw new \Exception$exception->getMessage() );
  31.             }
  32.             return null;
  33.         }
  34.         public function getId(): int {
  35.             return $this->documentTypeHandler->getId();
  36.         }
  37.         public function getLanguage() : string {
  38.             return $this->documentTypeHandler->getLanguage();
  39.         }
  40.         public function getElasticIndex() : string {
  41.             return $this->documentTypeHandler::getIndexName();
  42.         }
  43.         public function getElasticSearchData() : array {
  44.             return $this->documentTypeHandler->getData();
  45.         }
  46.     }