RelationService::getDatabaseConnection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Relation handler
4
 *
5
 * @author  Tim Lochmüller
6
 */
7
8
namespace HDNET\Tagger\Service;
9
10
use HDNET\Autoloader\SingletonInterface;
11
use HDNET\Tagger\Domain\Model\Tag;
12
use TYPO3\CMS\Core\Database\DatabaseConnection;
13
14
/**
15
 * Relation handler
16
 */
17
class RelationService implements SingletonInterface
18
{
19
20
    /**
21
     * Get usage by Tag
22
     *
23
     * @param Tag $tag
24
     *
25
     * @return array|NULL
26
     */
27
    public function getUsageByTag(Tag $tag)
28
    {
29
        return $this->getDatabaseConnection()
30
            ->exec_SELECTgetRows(
31
                'tablenames AS tableName,uid_foreign AS foreignUid',
32
                'tx_tagger_tag_mm',
33
                'uid_local=' . $tag->getUid()
34
            );
35
    }
36
37
    /**
38
     * Get related items by relation
39
     *
40
     * @param string $tableName
41
     * @param int $id
42
     */
43
    public function getRelatedItemsByRelation($tableName, $id)
44
    {
45
        //
46
47
    }
48
49
    /**
50
     * get database abstraction object
51
     *
52
     * @return DatabaseConnection
53
     */
54
    protected function getDatabaseConnection()
55
    {
56
        return $GLOBALS['TYPO3_DB'];
57
    }
58
}
59