Passed
Pull Request — master (#168)
by
unknown
20:44
created

ElasticsearchMapper::getElasticsearchJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 17
nc 1
nop 1
dl 0
loc 39
rs 9.7
c 0
b 0
f 0
1
<?php
2
namespace EWW\Dpf\Services\ElasticSearch;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
class ElasticsearchMapper
18
{
19
20
    /**
21
     * [$documentRepository description]
22
     * @var \EWW\Dpf\Domain\Repository\DocumentRepository
23
     * @inject
24
     */
25
    protected $documentRepository = null;
26
27
    /**
28
     * clientConfigurationManager
29
     * 
30
     * @var \EWW\Dpf\Configuration\ClientConfigurationManager 
31
     * @inject
32
     */
33
    protected $clientConfigurationManager;
34
35
36
    /**
37
     * document2json
38
     * @param  Document $document [description]
0 ignored issues
show
Bug introduced by
The type EWW\Dpf\Services\ElasticSearch\Document was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
39
     * @return json           Elasticsearch json format
0 ignored issues
show
Bug introduced by
The type EWW\Dpf\Services\ElasticSearch\json was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
40
     */
41
    public function getElasticsearchJson($document)
42
    {
43
        // document 2 json
44
        //$fedoraHost = $this->clientConfigurationManager->getFedoraHost();
45
46
        // load xslt from fedora
47
        //$xsltDoc = 'http://' . $fedoraHost . '/fedora/objects/qucosa:XSLT/datastreams/METS-MODS-XML2JSON/content';
48
49
        $xsltDoc = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:dpf/Resources/Private/mets-mods-xml2json.xsl');
50
51
        // xslt
52
        $xsl = new \DOMDocument;
53
54
        $xsl->load($xsltDoc);
55
56
        $exporter = new \EWW\Dpf\Services\MetsExporter();
57
        $fileData = $document->getFileData();
58
        $exporter->setFileData($fileData);
59
60
        // slub:info
61
        $exporter->setSlubInfo($document->getSlubInfoData());
62
63
        $exporter->setMods($document->getXmlData());
64
65
        $exporter->setObjId($document->getObjectIdentifier());
66
67
        $exporter->buildMets();
68
        $metsXml = $exporter->getMetsData();
69
70
        $xml = new \DOMDocument;
71
        $xml->loadXML($metsXml);
72
73
        // xslt processing
74
        $proc = new \XSLTProcessor;
75
        $proc->importStyleSheet($xsl); // XSL Document importieren
76
77
        $json = $proc->transformToXML($xml);
78
79
        return $json;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $json returns the type string which is incompatible with the documented return type EWW\Dpf\Services\ElasticSearch\json.
Loading history...
80
    }
81
82
}
83