org_openpsa_documents_interface   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 32
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve_object_link() 0 7 3
A _on_reindex() 0 17 1
1
<?php
2
/**
3
 * @package org.openpsa.documents
4
 * @author Nemein Oy http://www.nemein.com/
5
 * @copyright Nemein Oy http://www.nemein.com/
6
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
7
 */
8
9
use midcom\datamanager\datamanager;
10
11
/**
12
 * OpenPSA document management system
13
 *
14
 * @package org.openpsa.documents
15
 */
16
class org_openpsa_documents_interface extends midcom_baseclasses_components_interface
17
implements midcom_services_permalinks_resolver
18
{
19
    /**
20
     * Prepare the indexer client
21
     */
22
    public function _on_reindex($topic, midcom_helper_configuration $config, midcom_services_indexer $indexer)
23
    {
24
        $qb_documents = org_openpsa_documents_document_dba::new_query_builder();
25
        $qb_documents->add_constraint('topic', '=', $topic->id);
26
        $qb_documents->add_constraint('nextVersion', '=', 0);
27
        $dm_documents = datamanager::from_schemadb($config->get('schemadb_document'));
0 ignored issues
show
Bug introduced by
It seems like $config->get('schemadb_document') can also be of type false; however, parameter $path of midcom\datamanager\datamanager::from_schemadb() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        $dm_documents = datamanager::from_schemadb(/** @scrutinizer ignore-type */ $config->get('schemadb_document'));
Loading history...
28
29
        $qb_directories = org_openpsa_documents_directory::new_query_builder();
30
        $qb_directories->add_constraint('up', '=', $topic->id);
31
        $qb_directories->add_constraint('component', '=', $this->_component);
32
        $dm_directories = datamanager::from_schemadb($config->get('schemadb_directory'));
33
34
        $indexer = new org_openpsa_documents_midcom_indexer($topic, $indexer);
35
        $indexer->add_query('documents', $qb_documents, $dm_documents);
36
        $indexer->add_query('directories', $qb_directories, $dm_directories);
37
38
        return $indexer;
39
    }
40
41
    public function resolve_object_link(midcom_db_topic $topic, midcom_core_dbaobject $object) : ?string
42
    {
43
        if (   $object instanceof org_openpsa_documents_document_dba
44
            && $object->topic == $topic->id) {
45
            return "document/{$object->guid}/";
46
        }
47
        return null;
48
    }
49
}
50