Completed
Push — master ( 83cb67...d32f9d )
by
unknown
20:24
created

AdditionalResourceService::getObjectManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
 * It is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License, either version 2
8
 * of the License, or any later version.
9
 *
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
 * The TYPO3 project - inspiring people to share!
14
 */
15
16
namespace TYPO3\CMS\Workspaces\Service;
17
18
use TYPO3\CMS\Core\SingletonInterface;
19
use TYPO3\CMS\Core\Utility\GeneralUtility;
20
use TYPO3\CMS\Core\Utility\PathUtility;
21
22
/**
23
 * Service for additional columns in GridPanel
24
 */
25
class AdditionalResourceService implements SingletonInterface
26
{
27
    /**
28
     * @var array
29
     */
30
    protected $javaScriptResources = [];
31
32
    /**
33
     * @var array
34
     */
35
    protected $stylesheetResources = [];
36
37
    /**
38
     * @var array
39
     */
40
    protected $localizationResources = [];
41
42
    /**
43
     * @return AdditionalResourceService
44
     */
45
    public static function getInstance()
46
    {
47
        return GeneralUtility::makeInstance(AdditionalResourceService::class);
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
48
    }
49
50
    /**
51
     * @param string $name
52
     * @param string $resourcePath
53
     */
54
    public function addJavaScriptResource($name, $resourcePath)
55
    {
56
        $this->javaScriptResources[$name] = $this->resolvePath($resourcePath);
57
    }
58
59
    /**
60
     * @param string $name
61
     * @param string $resourcePath
62
     */
63
    public function addStylesheetResource($name, $resourcePath)
64
    {
65
        $this->stylesheetResources[$name] = $this->resolvePath($resourcePath);
66
    }
67
68
    /**
69
     * @param string $resourcePath
70
     */
71
    public function addLocalizationResource($resourcePath)
72
    {
73
        $absoluteResourcePath = GeneralUtility::getFileAbsFileName($resourcePath);
74
        $this->localizationResources[$absoluteResourcePath] = $absoluteResourcePath;
75
    }
76
77
    /**
78
     * @return array
79
     */
80
    public function getJavaScriptResources()
81
    {
82
        return $this->javaScriptResources;
83
    }
84
85
    /**
86
     * @return array
87
     */
88
    public function getStyleSheetResources()
89
    {
90
        return $this->stylesheetResources;
91
    }
92
93
    /**
94
     * @return array
95
     */
96
    public function getLocalizationResources()
97
    {
98
        return $this->localizationResources;
99
    }
100
101
    /**
102
     * Resolve path
103
     *
104
     * @param string $resourcePath
105
     * @return string|null
106
     */
107
    protected function resolvePath($resourcePath)
108
    {
109
        $absoluteFilePath = GeneralUtility::getFileAbsFileName($resourcePath);
110
        $absolutePath = PathUtility::dirname($absoluteFilePath);
111
        $fileName = PathUtility::basename($absoluteFilePath);
112
113
        return PathUtility::getRelativePathTo($absolutePath) . $fileName;
114
    }
115
}
116