Completed
Push — master ( 5c161a...b70884 )
by Fabien
52:39
created
Classes/Language/LanguageService.php 1 patch
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -20,163 +20,163 @@
 block discarded – undo
20 20
  */
21 21
 class LanguageService implements SingletonInterface
22 22
 {
23
-    /**
24
-     * @var array
25
-     */
26
-    protected $languages;
27
-
28
-    /**
29
-     * @var array
30
-     */
31
-    protected $defaultIcon;
32
-
33
-    /**
34
-     * Store the localized records to boost up performance.
35
-     *
36
-     * @var array
37
-     */
38
-    protected $localizedRecordStorage;
39
-
40
-    /**
41
-     * Returns available language records.
42
-     * The method stores the records in the property to speed up the process as the method can be often called.
43
-     *
44
-     * @return array
45
-     */
46
-    public function getLanguages()
47
-    {
48
-        if ($this->languages === null) {
49
-            $this->languages = $this->getDataService()->getRecords('sys_language');
50
-        }
51
-        return $this->languages;
52
-    }
53
-
54
-    /**
55
-     * Returns a localized record according to a Content object and a language identifier.
56
-     * Notice! This method does not overlay anything but simply returns the raw localized record.
57
-     *
58
-     * @param Content $object
59
-     * @param int $language
60
-     * @return Content
61
-     */
62
-    public function getLocalizedContent(Content $object, $language)
63
-    {
64
-        // We want to cache data per Content object. Retrieve the Object hash.
65
-        $objectHash = spl_object_hash($object);
66
-
67
-        // Initialize the storage
68
-        if (empty($this->localizedRecordStorage[$objectHash])) {
69
-            $this->localizedRecordStorage[$objectHash] = [];
70
-        }
71
-
72
-        if (empty($this->localizedRecordStorage[$objectHash][$language])) {
73
-            $localizedRecord = $this->getDataService()->getRecord(
74
-                $object->getDataType(),
75
-                [
76
-                    Tca::table($object)->getLanguageParentField() => $object->getUid(), // e.g. l10n_parent
77
-                    Tca::table($object)->getLanguageField() => $language, // e.g. sys_language_uid
78
-                ]
79
-            );
80
-
81
-            if ($localizedRecord) {
82
-                $localizedContent = GeneralUtility::makeInstance(Content::class, $object->getDataType(), $localizedRecord);
83
-                $this->localizedRecordStorage[$objectHash][$language] = $localizedContent;
84
-            } else {
85
-                $this->localizedRecordStorage[$objectHash][$language] = []; // We want an array at least, even if empty.
86
-            }
87
-        }
88
-
89
-        return $this->localizedRecordStorage[$objectHash][$language];
90
-    }
91
-
92
-    /**
93
-     * Tell whether the given Content object has a localization.
94
-     *
95
-     * @param Content $object
96
-     * @param int $language
97
-     * @return string
98
-     */
99
-    public function hasLocalization(Content $object, $language)
100
-    {
101
-        $localizedRecord = $this->getLocalizedContent($object, $language);
102
-        return !empty($localizedRecord);
103
-    }
104
-
105
-    /**
106
-     * Returns a localized field according to a Content object and a language identifier.
107
-     * Notice! If there is not translation, simply returns an empty string.
108
-     *
109
-     * @param Content $object
110
-     * @param int $language
111
-     * @param string $fieldName
112
-     * @return string
113
-     */
114
-    public function getLocalizedFieldName(Content $object, $language, $fieldName)
115
-    {
116
-        $localizedRecord = $this->getLocalizedContent($object, $language);
117
-        return empty($localizedRecord) ? '' : $localizedRecord[$fieldName];
118
-    }
119
-
120
-    /**
121
-     * Returns the default language configured by TSConfig.
122
-     *
123
-     * @return array
124
-     */
125
-    public function getDefaultFlag()
126
-    {
127
-        if ($this->defaultIcon === null) {
128
-            $defaultFlag = ''; // default value
129
-
130
-            $tsConfig = BackendUtility::getPagesTSconfig(0, 'mod.SHARED');
131
-
132
-            // Fallback non sprite-configuration
133
-            if (($pos = strrpos($tsConfig['properties']['defaultLanguageFlag'], '.')) !== false) {
134
-                $defaultFlag = substr($tsConfig['properties']['defaultLanguageFlag'], 0, $pos);
135
-            }
136
-
137
-            $this->defaultIcon = $defaultFlag;
138
-        }
139
-
140
-        return $this->defaultIcon;
141
-    }
142
-
143
-    /**
144
-     * Returns whether the system includes language records.
145
-     *
146
-     * @return bool
147
-     */
148
-    public function hasLanguages()
149
-    {
150
-        $languages = $this->getLanguages();
151
-        return !empty($languages);
152
-    }
153
-
154
-    /**
155
-     * Tell whether the given language exists.
156
-     *
157
-     * @param int $language
158
-     * @return bool
159
-     */
160
-    public function languageExists($language)
161
-    {
162
-        $languages = $this->getLanguages();
163
-
164
-        $LanguageExists = false;
165
-        foreach ($languages as $_language) {
166
-            if ((int)$_language['uid'] === (int)$language) {
167
-                $LanguageExists = true;
168
-                break;
169
-            }
170
-        }
171
-
172
-        return $LanguageExists;
173
-    }
174
-
175
-    /**
176
-     * @return object|DataService
177
-     */
178
-    protected function getDataService(): DataService
179
-    {
180
-        return GeneralUtility::makeInstance(DataService::class);
181
-    }
23
+	/**
24
+	 * @var array
25
+	 */
26
+	protected $languages;
27
+
28
+	/**
29
+	 * @var array
30
+	 */
31
+	protected $defaultIcon;
32
+
33
+	/**
34
+	 * Store the localized records to boost up performance.
35
+	 *
36
+	 * @var array
37
+	 */
38
+	protected $localizedRecordStorage;
39
+
40
+	/**
41
+	 * Returns available language records.
42
+	 * The method stores the records in the property to speed up the process as the method can be often called.
43
+	 *
44
+	 * @return array
45
+	 */
46
+	public function getLanguages()
47
+	{
48
+		if ($this->languages === null) {
49
+			$this->languages = $this->getDataService()->getRecords('sys_language');
50
+		}
51
+		return $this->languages;
52
+	}
53
+
54
+	/**
55
+	 * Returns a localized record according to a Content object and a language identifier.
56
+	 * Notice! This method does not overlay anything but simply returns the raw localized record.
57
+	 *
58
+	 * @param Content $object
59
+	 * @param int $language
60
+	 * @return Content
61
+	 */
62
+	public function getLocalizedContent(Content $object, $language)
63
+	{
64
+		// We want to cache data per Content object. Retrieve the Object hash.
65
+		$objectHash = spl_object_hash($object);
66
+
67
+		// Initialize the storage
68
+		if (empty($this->localizedRecordStorage[$objectHash])) {
69
+			$this->localizedRecordStorage[$objectHash] = [];
70
+		}
71
+
72
+		if (empty($this->localizedRecordStorage[$objectHash][$language])) {
73
+			$localizedRecord = $this->getDataService()->getRecord(
74
+				$object->getDataType(),
75
+				[
76
+					Tca::table($object)->getLanguageParentField() => $object->getUid(), // e.g. l10n_parent
77
+					Tca::table($object)->getLanguageField() => $language, // e.g. sys_language_uid
78
+				]
79
+			);
80
+
81
+			if ($localizedRecord) {
82
+				$localizedContent = GeneralUtility::makeInstance(Content::class, $object->getDataType(), $localizedRecord);
83
+				$this->localizedRecordStorage[$objectHash][$language] = $localizedContent;
84
+			} else {
85
+				$this->localizedRecordStorage[$objectHash][$language] = []; // We want an array at least, even if empty.
86
+			}
87
+		}
88
+
89
+		return $this->localizedRecordStorage[$objectHash][$language];
90
+	}
91
+
92
+	/**
93
+	 * Tell whether the given Content object has a localization.
94
+	 *
95
+	 * @param Content $object
96
+	 * @param int $language
97
+	 * @return string
98
+	 */
99
+	public function hasLocalization(Content $object, $language)
100
+	{
101
+		$localizedRecord = $this->getLocalizedContent($object, $language);
102
+		return !empty($localizedRecord);
103
+	}
104
+
105
+	/**
106
+	 * Returns a localized field according to a Content object and a language identifier.
107
+	 * Notice! If there is not translation, simply returns an empty string.
108
+	 *
109
+	 * @param Content $object
110
+	 * @param int $language
111
+	 * @param string $fieldName
112
+	 * @return string
113
+	 */
114
+	public function getLocalizedFieldName(Content $object, $language, $fieldName)
115
+	{
116
+		$localizedRecord = $this->getLocalizedContent($object, $language);
117
+		return empty($localizedRecord) ? '' : $localizedRecord[$fieldName];
118
+	}
119
+
120
+	/**
121
+	 * Returns the default language configured by TSConfig.
122
+	 *
123
+	 * @return array
124
+	 */
125
+	public function getDefaultFlag()
126
+	{
127
+		if ($this->defaultIcon === null) {
128
+			$defaultFlag = ''; // default value
129
+
130
+			$tsConfig = BackendUtility::getPagesTSconfig(0, 'mod.SHARED');
131
+
132
+			// Fallback non sprite-configuration
133
+			if (($pos = strrpos($tsConfig['properties']['defaultLanguageFlag'], '.')) !== false) {
134
+				$defaultFlag = substr($tsConfig['properties']['defaultLanguageFlag'], 0, $pos);
135
+			}
136
+
137
+			$this->defaultIcon = $defaultFlag;
138
+		}
139
+
140
+		return $this->defaultIcon;
141
+	}
142
+
143
+	/**
144
+	 * Returns whether the system includes language records.
145
+	 *
146
+	 * @return bool
147
+	 */
148
+	public function hasLanguages()
149
+	{
150
+		$languages = $this->getLanguages();
151
+		return !empty($languages);
152
+	}
153
+
154
+	/**
155
+	 * Tell whether the given language exists.
156
+	 *
157
+	 * @param int $language
158
+	 * @return bool
159
+	 */
160
+	public function languageExists($language)
161
+	{
162
+		$languages = $this->getLanguages();
163
+
164
+		$LanguageExists = false;
165
+		foreach ($languages as $_language) {
166
+			if ((int)$_language['uid'] === (int)$language) {
167
+				$LanguageExists = true;
168
+				break;
169
+			}
170
+		}
171
+
172
+		return $LanguageExists;
173
+	}
174
+
175
+	/**
176
+	 * @return object|DataService
177
+	 */
178
+	protected function getDataService(): DataService
179
+	{
180
+		return GeneralUtility::makeInstance(DataService::class);
181
+	}
182 182
 }
Please login to merge, or discard this patch.
Classes/Language/LocalizationStatus.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  */
17 17
 class LocalizationStatus extends Enumeration
18 18
 {
19
-    public const LOCALIZED = 'localized';
20
-    public const NOT_YET_LOCALIZED = 'notYetLocalized';
21
-    public const EMPTY_VALUE = 'emptyValue';
19
+	public const LOCALIZED = 'localized';
20
+	public const NOT_YET_LOCALIZED = 'notYetLocalized';
21
+	public const EMPTY_VALUE = 'emptyValue';
22 22
 }
Please login to merge, or discard this patch.
Classes/Facet/PageFacet.php 1 patch
Indentation   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -22,162 +22,162 @@
 block discarded – undo
22 22
  */
23 23
 class PageFacet implements FacetInterface
24 24
 {
25
-    /**
26
-     * @var string
27
-     */
28
-    protected $name;
29
-
30
-    /**
31
-     * @var string
32
-     */
33
-    protected $label;
34
-
35
-    /**
36
-     * @var string
37
-     */
38
-    protected $dataType;
39
-
40
-    /**
41
-     * @var bool
42
-     */
43
-    protected $canModifyMatcher = false;
44
-
45
-    /**
46
-     * Constructor of a Generic Facet in Vidi.
47
-     *
48
-     * @param string $name
49
-     * @param string $label
50
-     */
51
-    public function __construct($name, $label = '')
52
-    {
53
-        $this->name = 'pid';
54
-        $this->label = $label;
55
-    }
56
-
57
-    /**
58
-     * @return string
59
-     */
60
-    public function getName(): string
61
-    {
62
-        return $this->name;
63
-    }
64
-
65
-    /**
66
-     * @return string
67
-     */
68
-    public function getLabel(): string
69
-    {
70
-        return $this->label;
71
-    }
72
-
73
-    /**
74
-     * @return array
75
-     */
76
-    public function getSuggestions(): array
77
-    {
78
-        $values = [];
79
-        foreach ($this->getStoragePages() as $page) {
80
-            $values[] = [
81
-                $page['uid'] => sprintf('%s (%s)', $page['title'], $page['uid'])
82
-            ];
83
-        }
84
-        return $values;
85
-    }
86
-
87
-    /**
88
-     * @return array
89
-     */
90
-    protected function getStoragePages(): array
91
-    {
92
-        /** @var QueryBuilder $query */
93
-        $query = $this->getQueryBuilder('pages');
94
-        $query->getRestrictions()->removeAll();
95
-        return $query->select('*')
96
-            ->from('pages')
97
-            ->where(
98
-                sprintf(
99
-                    'uid IN (SELECT DISTINCT(pid) FROM %s WHERE 1=1 %s)',
100
-                    $this->getModuleLoader()->getDataType(),
101
-                    BackendUtility::deleteClause(
102
-                        $this->getModuleLoader()->getDataType()
103
-                    )
104
-                ),
105
-                BackendUtility::deleteClause('pages', '')
106
-            )
107
-            ->execute()
108
-            ->fetchAllAssociative();
109
-    }
110
-
111
-    /**
112
-     * @param string $tableName
113
-     * @return object|QueryBuilder
114
-     */
115
-    protected function getQueryBuilder($tableName): QueryBuilder
116
-    {
117
-        /** @var ConnectionPool $connectionPool */
118
-        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
119
-        return $connectionPool->getQueryBuilderForTable($tableName);
120
-    }
121
-
122
-    /**
123
-     * @return LanguageService
124
-     */
125
-    protected function getLanguageService(): LanguageService
126
-    {
127
-        /** @var LanguageService $langService */
128
-        $langService = $GLOBALS['LANG'];
129
-        if (!$langService) {
130
-            $langService = GeneralUtility::makeInstance(LanguageService::class);
131
-            $langService->init('en');
132
-        }
133
-
134
-        return $langService;
135
-    }
136
-
137
-    /**
138
-     * @return bool
139
-     */
140
-    public function hasSuggestions(): bool
141
-    {
142
-        return true;
143
-    }
144
-
145
-    /**
146
-     * @param string $dataType
147
-     * @return $this
148
-     */
149
-    public function setDataType($dataType): self
150
-    {
151
-        $this->dataType = $dataType;
152
-        return $this;
153
-    }
154
-
155
-    /**
156
-     * @return bool
157
-     */
158
-    public function canModifyMatcher(): bool
159
-    {
160
-        return $this->canModifyMatcher;
161
-    }
162
-
163
-    /**
164
-     * @param Matcher $matcher
165
-     * @param $value
166
-     * @return Matcher
167
-     */
168
-    public function modifyMatcher(Matcher $matcher, $value): Matcher
169
-    {
170
-        return $matcher;
171
-    }
172
-
173
-    /**
174
-     * Get the Vidi Module Loader.
175
-     *
176
-     * @return ModuleLoader|object
177
-     * @throws \InvalidArgumentException
178
-     */
179
-    protected function getModuleLoader()
180
-    {
181
-        return GeneralUtility::makeInstance(ModuleLoader::class);
182
-    }
25
+	/**
26
+	 * @var string
27
+	 */
28
+	protected $name;
29
+
30
+	/**
31
+	 * @var string
32
+	 */
33
+	protected $label;
34
+
35
+	/**
36
+	 * @var string
37
+	 */
38
+	protected $dataType;
39
+
40
+	/**
41
+	 * @var bool
42
+	 */
43
+	protected $canModifyMatcher = false;
44
+
45
+	/**
46
+	 * Constructor of a Generic Facet in Vidi.
47
+	 *
48
+	 * @param string $name
49
+	 * @param string $label
50
+	 */
51
+	public function __construct($name, $label = '')
52
+	{
53
+		$this->name = 'pid';
54
+		$this->label = $label;
55
+	}
56
+
57
+	/**
58
+	 * @return string
59
+	 */
60
+	public function getName(): string
61
+	{
62
+		return $this->name;
63
+	}
64
+
65
+	/**
66
+	 * @return string
67
+	 */
68
+	public function getLabel(): string
69
+	{
70
+		return $this->label;
71
+	}
72
+
73
+	/**
74
+	 * @return array
75
+	 */
76
+	public function getSuggestions(): array
77
+	{
78
+		$values = [];
79
+		foreach ($this->getStoragePages() as $page) {
80
+			$values[] = [
81
+				$page['uid'] => sprintf('%s (%s)', $page['title'], $page['uid'])
82
+			];
83
+		}
84
+		return $values;
85
+	}
86
+
87
+	/**
88
+	 * @return array
89
+	 */
90
+	protected function getStoragePages(): array
91
+	{
92
+		/** @var QueryBuilder $query */
93
+		$query = $this->getQueryBuilder('pages');
94
+		$query->getRestrictions()->removeAll();
95
+		return $query->select('*')
96
+			->from('pages')
97
+			->where(
98
+				sprintf(
99
+					'uid IN (SELECT DISTINCT(pid) FROM %s WHERE 1=1 %s)',
100
+					$this->getModuleLoader()->getDataType(),
101
+					BackendUtility::deleteClause(
102
+						$this->getModuleLoader()->getDataType()
103
+					)
104
+				),
105
+				BackendUtility::deleteClause('pages', '')
106
+			)
107
+			->execute()
108
+			->fetchAllAssociative();
109
+	}
110
+
111
+	/**
112
+	 * @param string $tableName
113
+	 * @return object|QueryBuilder
114
+	 */
115
+	protected function getQueryBuilder($tableName): QueryBuilder
116
+	{
117
+		/** @var ConnectionPool $connectionPool */
118
+		$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
119
+		return $connectionPool->getQueryBuilderForTable($tableName);
120
+	}
121
+
122
+	/**
123
+	 * @return LanguageService
124
+	 */
125
+	protected function getLanguageService(): LanguageService
126
+	{
127
+		/** @var LanguageService $langService */
128
+		$langService = $GLOBALS['LANG'];
129
+		if (!$langService) {
130
+			$langService = GeneralUtility::makeInstance(LanguageService::class);
131
+			$langService->init('en');
132
+		}
133
+
134
+		return $langService;
135
+	}
136
+
137
+	/**
138
+	 * @return bool
139
+	 */
140
+	public function hasSuggestions(): bool
141
+	{
142
+		return true;
143
+	}
144
+
145
+	/**
146
+	 * @param string $dataType
147
+	 * @return $this
148
+	 */
149
+	public function setDataType($dataType): self
150
+	{
151
+		$this->dataType = $dataType;
152
+		return $this;
153
+	}
154
+
155
+	/**
156
+	 * @return bool
157
+	 */
158
+	public function canModifyMatcher(): bool
159
+	{
160
+		return $this->canModifyMatcher;
161
+	}
162
+
163
+	/**
164
+	 * @param Matcher $matcher
165
+	 * @param $value
166
+	 * @return Matcher
167
+	 */
168
+	public function modifyMatcher(Matcher $matcher, $value): Matcher
169
+	{
170
+		return $matcher;
171
+	}
172
+
173
+	/**
174
+	 * Get the Vidi Module Loader.
175
+	 *
176
+	 * @return ModuleLoader|object
177
+	 * @throws \InvalidArgumentException
178
+	 */
179
+	protected function getModuleLoader()
180
+	{
181
+		return GeneralUtility::makeInstance(ModuleLoader::class);
182
+	}
183 183
 }
Please login to merge, or discard this patch.
Classes/Facet/StandardFacet.php 1 patch
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -20,142 +20,142 @@
 block discarded – undo
20 20
  */
21 21
 class StandardFacet implements FacetInterface
22 22
 {
23
-    /**
24
-     * @var string
25
-     */
26
-    protected $name;
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    protected $label;
32
-
33
-    /**
34
-     * @var array
35
-     */
36
-    protected $suggestions = [];
37
-
38
-    /**
39
-     * @var string
40
-     */
41
-    protected $dataType;
42
-
43
-    /**
44
-     * @var bool
45
-     */
46
-    protected $canModifyMatcher = false;
47
-
48
-    /**
49
-     * Constructor of a Generic Facet in Vidi.
50
-     *
51
-     * @param string $name
52
-     * @param string $label
53
-     * @param array $suggestions
54
-     */
55
-    public function __construct($name, $label = '', array $suggestions = [])
56
-    {
57
-        $this->name = $name;
58
-        if (empty($label)) {
59
-            $label = $this->name;
60
-        }
61
-        $this->label = $label;
62
-        $this->suggestions = $suggestions;
63
-    }
64
-
65
-    /**
66
-     * @return string
67
-     */
68
-    public function getName(): string
69
-    {
70
-        return $this->name;
71
-    }
72
-
73
-    /**
74
-     * @return string
75
-     */
76
-    public function getLabel(): string
77
-    {
78
-        if ($this->label === $this->name) {
79
-            $label = Tca::table($this->dataType)->field($this->getName())->getLabel();
80
-        } else {
81
-            try {
82
-                $label = LocalizationUtility::translate($this->label, '');
83
-            } catch (\InvalidArgumentException $e) {
84
-            }
85
-            if (empty($label)) {
86
-                $label = $this->label;
87
-            }
88
-        }
89
-
90
-        return $label;
91
-    }
92
-
93
-    /**
94
-     * @return array
95
-     */
96
-    public function getSuggestions(): array
97
-    {
98
-        $values = [];
99
-        foreach ($this->suggestions as $key => $label) {
100
-            $localizedLabel = $this->getLanguageService()->sL($label);
101
-            if (!empty($localizedLabel)) {
102
-                $label = $localizedLabel;
103
-            }
104
-
105
-            $values[] = [$key => $label];
106
-        }
107
-
108
-        return $values;
109
-    }
110
-
111
-    /**
112
-     * @return LanguageService
113
-     */
114
-    protected function getLanguageService(): LanguageService
115
-    {
116
-        /** @var LanguageService $langService */
117
-        $langService = $GLOBALS['LANG'];
118
-        if (!$langService) {
119
-            $langService = GeneralUtility::makeInstance(LanguageService::class);
120
-            $langService->init('en');
121
-        }
122
-
123
-        return $langService;
124
-    }
125
-
126
-    /**
127
-     * @return bool
128
-     */
129
-    public function hasSuggestions(): bool
130
-    {
131
-        return !empty($this->suggestions);
132
-    }
133
-
134
-    /**
135
-     * @param string $dataType
136
-     * @return $this
137
-     */
138
-    public function setDataType($dataType): self
139
-    {
140
-        $this->dataType = $dataType;
141
-        return $this;
142
-    }
143
-
144
-    /**
145
-     * @return bool
146
-     */
147
-    public function canModifyMatcher(): bool
148
-    {
149
-        return $this->canModifyMatcher;
150
-    }
151
-
152
-    /**
153
-     * @param Matcher $matcher
154
-     * @param $value
155
-     * @return Matcher
156
-     */
157
-    public function modifyMatcher(Matcher $matcher, $value): Matcher
158
-    {
159
-        return $matcher;
160
-    }
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected $name;
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	protected $label;
32
+
33
+	/**
34
+	 * @var array
35
+	 */
36
+	protected $suggestions = [];
37
+
38
+	/**
39
+	 * @var string
40
+	 */
41
+	protected $dataType;
42
+
43
+	/**
44
+	 * @var bool
45
+	 */
46
+	protected $canModifyMatcher = false;
47
+
48
+	/**
49
+	 * Constructor of a Generic Facet in Vidi.
50
+	 *
51
+	 * @param string $name
52
+	 * @param string $label
53
+	 * @param array $suggestions
54
+	 */
55
+	public function __construct($name, $label = '', array $suggestions = [])
56
+	{
57
+		$this->name = $name;
58
+		if (empty($label)) {
59
+			$label = $this->name;
60
+		}
61
+		$this->label = $label;
62
+		$this->suggestions = $suggestions;
63
+	}
64
+
65
+	/**
66
+	 * @return string
67
+	 */
68
+	public function getName(): string
69
+	{
70
+		return $this->name;
71
+	}
72
+
73
+	/**
74
+	 * @return string
75
+	 */
76
+	public function getLabel(): string
77
+	{
78
+		if ($this->label === $this->name) {
79
+			$label = Tca::table($this->dataType)->field($this->getName())->getLabel();
80
+		} else {
81
+			try {
82
+				$label = LocalizationUtility::translate($this->label, '');
83
+			} catch (\InvalidArgumentException $e) {
84
+			}
85
+			if (empty($label)) {
86
+				$label = $this->label;
87
+			}
88
+		}
89
+
90
+		return $label;
91
+	}
92
+
93
+	/**
94
+	 * @return array
95
+	 */
96
+	public function getSuggestions(): array
97
+	{
98
+		$values = [];
99
+		foreach ($this->suggestions as $key => $label) {
100
+			$localizedLabel = $this->getLanguageService()->sL($label);
101
+			if (!empty($localizedLabel)) {
102
+				$label = $localizedLabel;
103
+			}
104
+
105
+			$values[] = [$key => $label];
106
+		}
107
+
108
+		return $values;
109
+	}
110
+
111
+	/**
112
+	 * @return LanguageService
113
+	 */
114
+	protected function getLanguageService(): LanguageService
115
+	{
116
+		/** @var LanguageService $langService */
117
+		$langService = $GLOBALS['LANG'];
118
+		if (!$langService) {
119
+			$langService = GeneralUtility::makeInstance(LanguageService::class);
120
+			$langService->init('en');
121
+		}
122
+
123
+		return $langService;
124
+	}
125
+
126
+	/**
127
+	 * @return bool
128
+	 */
129
+	public function hasSuggestions(): bool
130
+	{
131
+		return !empty($this->suggestions);
132
+	}
133
+
134
+	/**
135
+	 * @param string $dataType
136
+	 * @return $this
137
+	 */
138
+	public function setDataType($dataType): self
139
+	{
140
+		$this->dataType = $dataType;
141
+		return $this;
142
+	}
143
+
144
+	/**
145
+	 * @return bool
146
+	 */
147
+	public function canModifyMatcher(): bool
148
+	{
149
+		return $this->canModifyMatcher;
150
+	}
151
+
152
+	/**
153
+	 * @param Matcher $matcher
154
+	 * @param $value
155
+	 * @return Matcher
156
+	 */
157
+	public function modifyMatcher(Matcher $matcher, $value): Matcher
158
+	{
159
+		return $matcher;
160
+	}
161 161
 }
Please login to merge, or discard this patch.
Classes/Facet/CompositeFacet.php 1 patch
Indentation   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -20,162 +20,162 @@
 block discarded – undo
20 20
  */
21 21
 class CompositeFacet implements FacetInterface
22 22
 {
23
-    /**
24
-     * @var string
25
-     */
26
-    protected $name;
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    protected $label;
32
-
33
-    /**
34
-     * @var array
35
-     */
36
-    protected $suggestions = [
37
-        '0' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active.0',
38
-    ];
39
-
40
-    /**
41
-     * @var array
42
-     */
43
-    protected $configuration = [];
44
-
45
-    /**
46
-     * @var string
47
-     */
48
-    protected $dataType;
49
-
50
-    /**
51
-     * @var bool
52
-     */
53
-    protected $canModifyMatcher = true;
54
-
55
-    /**
56
-     * Constructor of a Generic Facet in Vidi.
57
-     *
58
-     * @param string $name
59
-     * @param string $label
60
-     * @param array $suggestions
61
-     * @param array $configuration
62
-     */
63
-    public function __construct($name, $label = '', array $suggestions = [], $configuration = [])
64
-    {
65
-        $this->name = $name;
66
-        if (empty($label)) {
67
-            $label = $this->name;
68
-        }
69
-        $this->label = $label;
70
-        if ($suggestions) {
71
-            $this->suggestions = $suggestions;
72
-        }
73
-        if ($configuration) {
74
-            $this->configuration = $configuration;
75
-        }
76
-    }
77
-
78
-    /**
79
-     * @return string
80
-     */
81
-    public function getName(): string
82
-    {
83
-        return $this->name;
84
-    }
85
-
86
-    /**
87
-     * @return string
88
-     */
89
-    public function getLabel(): string
90
-    {
91
-        if ($this->label === $this->name) {
92
-            $label = Tca::table($this->dataType)->field($this->getName())->getLabel();
93
-        } else {
94
-            try {
95
-                $label = LocalizationUtility::translate($this->label, '');
96
-            } catch (\InvalidArgumentException $e) {
97
-            }
98
-            if (empty($label)) {
99
-                $label = $this->label;
100
-            }
101
-        }
102
-
103
-        return $label;
104
-    }
105
-
106
-    /**
107
-     * @return array
108
-     */
109
-    public function getSuggestions(): array
110
-    {
111
-        $values = [];
112
-        foreach ($this->suggestions as $key => $label) {
113
-            $localizedLabel = $this->getLanguageService()->sL($label);
114
-            if (!empty($localizedLabel)) {
115
-                $label = $localizedLabel;
116
-            }
117
-
118
-            $values[] = [$key => $label];
119
-        }
120
-
121
-        return $values;
122
-    }
123
-
124
-    /**
125
-     * @return LanguageService
126
-     */
127
-    protected function getLanguageService(): LanguageService
128
-    {
129
-        /** @var LanguageService $langService */
130
-        $langService = $GLOBALS['LANG'];
131
-        if (!$langService) {
132
-            $langService = GeneralUtility::makeInstance(LanguageService::class);
133
-            $langService->init('en');
134
-        }
135
-
136
-        return $langService;
137
-    }
138
-
139
-    /**
140
-     * @return bool
141
-     */
142
-    public function hasSuggestions(): bool
143
-    {
144
-        return !empty($this->suggestions);
145
-    }
146
-
147
-    /**
148
-     * @param string $dataType
149
-     * @return $this
150
-     */
151
-    public function setDataType($dataType): self
152
-    {
153
-        $this->dataType = $dataType;
154
-        return $this;
155
-    }
156
-
157
-    /**
158
-     * @return bool
159
-     */
160
-    public function canModifyMatcher(): bool
161
-    {
162
-        return $this->canModifyMatcher;
163
-    }
164
-
165
-    /**
166
-     * @param Matcher $matcher
167
-     * @param $value
168
-     * @return Matcher
169
-     */
170
-    public function modifyMatcher(Matcher $matcher, $value): Matcher
171
-    {
172
-        foreach ($this->configuration as $fieldNameAndPath => $operand) {
173
-            if ($operand === '*') {
174
-                $matcher->notEquals($fieldNameAndPath, '');
175
-            } else {
176
-                $matcher->equals($fieldNameAndPath, $operand);
177
-            }
178
-        }
179
-        return $matcher;
180
-    }
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected $name;
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	protected $label;
32
+
33
+	/**
34
+	 * @var array
35
+	 */
36
+	protected $suggestions = [
37
+		'0' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active.0',
38
+	];
39
+
40
+	/**
41
+	 * @var array
42
+	 */
43
+	protected $configuration = [];
44
+
45
+	/**
46
+	 * @var string
47
+	 */
48
+	protected $dataType;
49
+
50
+	/**
51
+	 * @var bool
52
+	 */
53
+	protected $canModifyMatcher = true;
54
+
55
+	/**
56
+	 * Constructor of a Generic Facet in Vidi.
57
+	 *
58
+	 * @param string $name
59
+	 * @param string $label
60
+	 * @param array $suggestions
61
+	 * @param array $configuration
62
+	 */
63
+	public function __construct($name, $label = '', array $suggestions = [], $configuration = [])
64
+	{
65
+		$this->name = $name;
66
+		if (empty($label)) {
67
+			$label = $this->name;
68
+		}
69
+		$this->label = $label;
70
+		if ($suggestions) {
71
+			$this->suggestions = $suggestions;
72
+		}
73
+		if ($configuration) {
74
+			$this->configuration = $configuration;
75
+		}
76
+	}
77
+
78
+	/**
79
+	 * @return string
80
+	 */
81
+	public function getName(): string
82
+	{
83
+		return $this->name;
84
+	}
85
+
86
+	/**
87
+	 * @return string
88
+	 */
89
+	public function getLabel(): string
90
+	{
91
+		if ($this->label === $this->name) {
92
+			$label = Tca::table($this->dataType)->field($this->getName())->getLabel();
93
+		} else {
94
+			try {
95
+				$label = LocalizationUtility::translate($this->label, '');
96
+			} catch (\InvalidArgumentException $e) {
97
+			}
98
+			if (empty($label)) {
99
+				$label = $this->label;
100
+			}
101
+		}
102
+
103
+		return $label;
104
+	}
105
+
106
+	/**
107
+	 * @return array
108
+	 */
109
+	public function getSuggestions(): array
110
+	{
111
+		$values = [];
112
+		foreach ($this->suggestions as $key => $label) {
113
+			$localizedLabel = $this->getLanguageService()->sL($label);
114
+			if (!empty($localizedLabel)) {
115
+				$label = $localizedLabel;
116
+			}
117
+
118
+			$values[] = [$key => $label];
119
+		}
120
+
121
+		return $values;
122
+	}
123
+
124
+	/**
125
+	 * @return LanguageService
126
+	 */
127
+	protected function getLanguageService(): LanguageService
128
+	{
129
+		/** @var LanguageService $langService */
130
+		$langService = $GLOBALS['LANG'];
131
+		if (!$langService) {
132
+			$langService = GeneralUtility::makeInstance(LanguageService::class);
133
+			$langService->init('en');
134
+		}
135
+
136
+		return $langService;
137
+	}
138
+
139
+	/**
140
+	 * @return bool
141
+	 */
142
+	public function hasSuggestions(): bool
143
+	{
144
+		return !empty($this->suggestions);
145
+	}
146
+
147
+	/**
148
+	 * @param string $dataType
149
+	 * @return $this
150
+	 */
151
+	public function setDataType($dataType): self
152
+	{
153
+		$this->dataType = $dataType;
154
+		return $this;
155
+	}
156
+
157
+	/**
158
+	 * @return bool
159
+	 */
160
+	public function canModifyMatcher(): bool
161
+	{
162
+		return $this->canModifyMatcher;
163
+	}
164
+
165
+	/**
166
+	 * @param Matcher $matcher
167
+	 * @param $value
168
+	 * @return Matcher
169
+	 */
170
+	public function modifyMatcher(Matcher $matcher, $value): Matcher
171
+	{
172
+		foreach ($this->configuration as $fieldNameAndPath => $operand) {
173
+			if ($operand === '*') {
174
+				$matcher->notEquals($fieldNameAndPath, '');
175
+			} else {
176
+				$matcher->equals($fieldNameAndPath, $operand);
177
+			}
178
+		}
179
+		return $matcher;
180
+	}
181 181
 }
Please login to merge, or discard this patch.
Classes/Facet/FacetInterface.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -16,51 +16,51 @@
 block discarded – undo
16 16
  */
17 17
 interface FacetInterface
18 18
 {
19
-    /**
20
-     * Return the "key" of the facet.
21
-     *
22
-     * @return string
23
-     */
24
-    public function getName();
19
+	/**
20
+	 * Return the "key" of the facet.
21
+	 *
22
+	 * @return string
23
+	 */
24
+	public function getName();
25 25
 
26
-    /**
27
-     * Return the "label" of the facet.
28
-     *
29
-     * @return string
30
-     */
31
-    public function getLabel();
26
+	/**
27
+	 * Return the "label" of the facet.
28
+	 *
29
+	 * @return string
30
+	 */
31
+	public function getLabel();
32 32
 
33
-    /**
34
-     * Return possible "suggestions" of the facet.
35
-     *
36
-     * @return array
37
-     */
38
-    public function getSuggestions();
33
+	/**
34
+	 * Return possible "suggestions" of the facet.
35
+	 *
36
+	 * @return array
37
+	 */
38
+	public function getSuggestions();
39 39
 
40
-    /**
41
-     * Tell whether the Facet has suggestion or not.
42
-     *
43
-     * @return bool
44
-     */
45
-    public function hasSuggestions();
40
+	/**
41
+	 * Tell whether the Facet has suggestion or not.
42
+	 *
43
+	 * @return bool
44
+	 */
45
+	public function hasSuggestions();
46 46
 
47
-    /**
48
-     * Set the data type.
49
-     *
50
-     * @param string $dataType
51
-     * @return $this
52
-     */
53
-    public function setDataType($dataType);
47
+	/**
48
+	 * Set the data type.
49
+	 *
50
+	 * @param string $dataType
51
+	 * @return $this
52
+	 */
53
+	public function setDataType($dataType);
54 54
 
55
-    /**
56
-     * @return bool
57
-     */
58
-    public function canModifyMatcher();
55
+	/**
56
+	 * @return bool
57
+	 */
58
+	public function canModifyMatcher();
59 59
 
60
-    /**
61
-     * @param Matcher $matcher
62
-     * @param $value
63
-     * @return Matcher
64
-     */
65
-    public function modifyMatcher(Matcher $matcher, $value);
60
+	/**
61
+	 * @param Matcher $matcher
62
+	 * @param $value
63
+	 * @return Matcher
64
+	 */
65
+	public function modifyMatcher(Matcher $matcher, $value);
66 66
 }
Please login to merge, or discard this patch.
Classes/Facet/FacetSuggestionService.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -21,103 +21,103 @@
 block discarded – undo
21 21
  */
22 22
 class FacetSuggestionService
23 23
 {
24
-    /**
25
-     * Retrieve possible suggestions for a field name
26
-     *
27
-     * @param string $fieldNameAndPath
28
-     * @return array
29
-     */
30
-    public function getSuggestions($fieldNameAndPath): array
31
-    {
32
-        $values = [];
33
-
34
-        $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
35
-        $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
36
-
37
-        if (Tca::grid()->facet($fieldNameAndPath)->hasSuggestions()) {
38
-            $values = Tca::grid()->facet($fieldNameAndPath)->getSuggestions();
39
-        } elseif (Tca::table($dataType)->hasField($fieldName)) {
40
-            if (Tca::table($dataType)->field($fieldName)->hasRelation()) {
41
-                // Fetch the adequate repository
42
-                $foreignTable = Tca::table($dataType)->field($fieldName)->getForeignTable();
43
-                $contentRepository = ContentRepositoryFactory::getInstance($foreignTable);
44
-                $table = Tca::table($foreignTable);
45
-
46
-                // Initialize the matcher object.
47
-                $matcher = MatcherObjectFactory::getInstance()->getMatcher([], $foreignTable);
48
-
49
-                $numberOfValues = $contentRepository->countBy($matcher);
50
-                if ($numberOfValues <= $this->getLimit()) {
51
-                    $contents = $contentRepository->findBy($matcher);
52
-
53
-                    foreach ($contents as $content) {
54
-                        $values[] = array($content->getUid() => $content[$table->getLabelField()]);
55
-                    }
56
-                }
57
-            } elseif (!Tca::table($dataType)->field($fieldName)->isTextArea()) { // We don't want suggestion if field is text area.
58
-                // Fetch the adequate repository
59
-                /** @var ContentRepository $contentRepository */
60
-                $contentRepository = ContentRepositoryFactory::getInstance($dataType);
61
-
62
-                // Initialize some objects related to the query
63
-                $matcher = MatcherObjectFactory::getInstance()->getMatcher([], $dataType);
64
-
65
-                // Count the number of objects.
66
-                $numberOfValues = $contentRepository->countDistinctValues($fieldName, $matcher);
67
-
68
-                // Only returns suggestion if there are not too many for the browser.
69
-                if ($numberOfValues <= $this->getLimit()) {
70
-                    // Query the repository.
71
-                    $contents = $contentRepository->findDistinctValues($fieldName, $matcher);
72
-
73
-                    foreach ($contents as $content) {
74
-                        $value = $content[$fieldName];
75
-                        $label = $content[$fieldName];
76
-                        if (Tca::table($dataType)->field($fieldName)->isSelect()) {
77
-                            $label = Tca::table($dataType)->field($fieldName)->getLabelForItem($value);
78
-                        }
79
-
80
-                        $values[] = $label;
81
-                    }
82
-                }
83
-            }
84
-        }
85
-        return $values;
86
-    }
87
-
88
-    /**
89
-     * Return from settings the suggestion limit.
90
-     *
91
-     * @return int
92
-     */
93
-    protected function getLimit(): int
94
-    {
95
-        $settings = $this->getSettings();
96
-        $suggestionLimit = (int)$settings['suggestionLimit'];
97
-        if ($suggestionLimit <= 0) {
98
-            $suggestionLimit = 1000;
99
-        }
100
-        return $suggestionLimit;
101
-    }
102
-
103
-    /**
104
-     * @return FieldPathResolver|object
105
-     */
106
-    protected function getFieldPathResolver()
107
-    {
108
-        return GeneralUtility::makeInstance(FieldPathResolver::class);
109
-    }
110
-
111
-    /**
112
-     * Returns the module settings.
113
-     *
114
-     * @return array
115
-     */
116
-    protected function getSettings()
117
-    {
118
-        /** @var BackendConfigurationManager $backendConfigurationManager */
119
-        $backendConfigurationManager = GeneralUtility::makeInstance(BackendConfigurationManager::class);
120
-        $configuration = $backendConfigurationManager->getTypoScriptSetup();
121
-        return $configuration['module.']['tx_vidi.']['settings.'];
122
-    }
24
+	/**
25
+	 * Retrieve possible suggestions for a field name
26
+	 *
27
+	 * @param string $fieldNameAndPath
28
+	 * @return array
29
+	 */
30
+	public function getSuggestions($fieldNameAndPath): array
31
+	{
32
+		$values = [];
33
+
34
+		$dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
35
+		$fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
36
+
37
+		if (Tca::grid()->facet($fieldNameAndPath)->hasSuggestions()) {
38
+			$values = Tca::grid()->facet($fieldNameAndPath)->getSuggestions();
39
+		} elseif (Tca::table($dataType)->hasField($fieldName)) {
40
+			if (Tca::table($dataType)->field($fieldName)->hasRelation()) {
41
+				// Fetch the adequate repository
42
+				$foreignTable = Tca::table($dataType)->field($fieldName)->getForeignTable();
43
+				$contentRepository = ContentRepositoryFactory::getInstance($foreignTable);
44
+				$table = Tca::table($foreignTable);
45
+
46
+				// Initialize the matcher object.
47
+				$matcher = MatcherObjectFactory::getInstance()->getMatcher([], $foreignTable);
48
+
49
+				$numberOfValues = $contentRepository->countBy($matcher);
50
+				if ($numberOfValues <= $this->getLimit()) {
51
+					$contents = $contentRepository->findBy($matcher);
52
+
53
+					foreach ($contents as $content) {
54
+						$values[] = array($content->getUid() => $content[$table->getLabelField()]);
55
+					}
56
+				}
57
+			} elseif (!Tca::table($dataType)->field($fieldName)->isTextArea()) { // We don't want suggestion if field is text area.
58
+				// Fetch the adequate repository
59
+				/** @var ContentRepository $contentRepository */
60
+				$contentRepository = ContentRepositoryFactory::getInstance($dataType);
61
+
62
+				// Initialize some objects related to the query
63
+				$matcher = MatcherObjectFactory::getInstance()->getMatcher([], $dataType);
64
+
65
+				// Count the number of objects.
66
+				$numberOfValues = $contentRepository->countDistinctValues($fieldName, $matcher);
67
+
68
+				// Only returns suggestion if there are not too many for the browser.
69
+				if ($numberOfValues <= $this->getLimit()) {
70
+					// Query the repository.
71
+					$contents = $contentRepository->findDistinctValues($fieldName, $matcher);
72
+
73
+					foreach ($contents as $content) {
74
+						$value = $content[$fieldName];
75
+						$label = $content[$fieldName];
76
+						if (Tca::table($dataType)->field($fieldName)->isSelect()) {
77
+							$label = Tca::table($dataType)->field($fieldName)->getLabelForItem($value);
78
+						}
79
+
80
+						$values[] = $label;
81
+					}
82
+				}
83
+			}
84
+		}
85
+		return $values;
86
+	}
87
+
88
+	/**
89
+	 * Return from settings the suggestion limit.
90
+	 *
91
+	 * @return int
92
+	 */
93
+	protected function getLimit(): int
94
+	{
95
+		$settings = $this->getSettings();
96
+		$suggestionLimit = (int)$settings['suggestionLimit'];
97
+		if ($suggestionLimit <= 0) {
98
+			$suggestionLimit = 1000;
99
+		}
100
+		return $suggestionLimit;
101
+	}
102
+
103
+	/**
104
+	 * @return FieldPathResolver|object
105
+	 */
106
+	protected function getFieldPathResolver()
107
+	{
108
+		return GeneralUtility::makeInstance(FieldPathResolver::class);
109
+	}
110
+
111
+	/**
112
+	 * Returns the module settings.
113
+	 *
114
+	 * @return array
115
+	 */
116
+	protected function getSettings()
117
+	{
118
+		/** @var BackendConfigurationManager $backendConfigurationManager */
119
+		$backendConfigurationManager = GeneralUtility::makeInstance(BackendConfigurationManager::class);
120
+		$configuration = $backendConfigurationManager->getTypoScriptSetup();
121
+		return $configuration['module.']['tx_vidi.']['settings.'];
122
+	}
123 123
 }
Please login to merge, or discard this patch.
Classes/Grid/ColumnRendererAbstract.php 2 patches
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -19,190 +19,190 @@
 block discarded – undo
19 19
  */
20 20
 abstract class ColumnRendererAbstract implements ColumnRendererInterface
21 21
 {
22
-    /**
23
-     * The content object.
24
-     *
25
-     * @var Content
26
-     */
27
-    protected $object;
28
-
29
-    /**
30
-     * @var string
31
-     */
32
-    protected $fieldName;
33
-
34
-    /**
35
-     * @var int
36
-     */
37
-    protected $rowIndex;
38
-
39
-    /**
40
-     * @var array
41
-     */
42
-    protected $fieldConfiguration = [];
43
-
44
-    /**
45
-     * @var array
46
-     */
47
-    protected $gridRendererConfiguration = [];
48
-
49
-    /**
50
-     * @var array
51
-     */
52
-    protected $configuration = [];
53
-
54
-    /**
55
-     * Constructor of a Generic component in Vidi.
56
-     *
57
-     * @param array $configuration
58
-     * @param array $legacyParameterConfiguration
59
-     */
60
-    public function __construct($configuration = [], $legacyParameterConfiguration = array())
61
-    {
62
-        if (is_string($configuration)) {
63
-            $configuration = $legacyParameterConfiguration;
64
-            trigger_error('ColumnRendererAbstract: first parameter must now be an array. Please edit me in ' . get_class($this), E_USER_DEPRECATED);
65
-        }
66
-        $this->configuration = $configuration;
67
-    }
68
-
69
-    /**
70
-     * @return array
71
-     */
72
-    public function getConfiguration()
73
-    {
74
-        return $this->configuration;
75
-    }
76
-
77
-    /**
78
-     * @return Content
79
-     */
80
-    public function getObject()
81
-    {
82
-        return $this->object;
83
-    }
84
-
85
-    /**
86
-     * @param Content $object
87
-     * @return $this
88
-     */
89
-    public function setObject($object)
90
-    {
91
-        $this->object = $object;
92
-        return $this;
93
-    }
94
-
95
-    /**
96
-     * @return string
97
-     */
98
-    public function getFieldName()
99
-    {
100
-        return $this->fieldName;
101
-    }
102
-
103
-    /**
104
-     * @param string $fieldName
105
-     * @return $this
106
-     */
107
-    public function setFieldName($fieldName)
108
-    {
109
-        $this->fieldName = $fieldName;
110
-        return $this;
111
-    }
112
-
113
-    /**
114
-     * @return int
115
-     */
116
-    public function getRowIndex()
117
-    {
118
-        return $this->rowIndex;
119
-    }
120
-
121
-    /**
122
-     * @param int $rowIndex
123
-     * @return $this
124
-     */
125
-    public function setRowIndex($rowIndex)
126
-    {
127
-        $this->rowIndex = $rowIndex;
128
-        return $this;
129
-    }
130
-
131
-    /**
132
-     * @return array
133
-     */
134
-    public function getFieldConfiguration()
135
-    {
136
-        return $this->fieldConfiguration;
137
-    }
138
-
139
-    /**
140
-     * @param array $fieldConfiguration
141
-     * @return $this
142
-     */
143
-    public function setFieldConfiguration($fieldConfiguration)
144
-    {
145
-        $this->fieldConfiguration = $fieldConfiguration;
146
-        return $this;
147
-    }
148
-
149
-    /**
150
-     * @return array
151
-     */
152
-    public function getGridRendererConfiguration()
153
-    {
154
-        return $this->gridRendererConfiguration;
155
-    }
156
-
157
-    /**
158
-     * @param array $gridRendererConfiguration
159
-     * @return $this
160
-     */
161
-    public function setGridRendererConfiguration($gridRendererConfiguration)
162
-    {
163
-        $this->gridRendererConfiguration = $gridRendererConfiguration;
164
-        return $this;
165
-    }
166
-
167
-    /**
168
-     * Escapes special characters with their escaped counterparts as needed using PHPs htmlentities() function.
169
-     *
170
-     * @param string $value string to format
171
-     * @param bool $keepQuotes if TRUE, single and double quotes won't be replaced (sets ENT_NOQUOTES flag)
172
-     * @param string $encoding
173
-     * @return string
174
-     * @see http://www.php.net/manual/function.htmlentities.php
175
-     * @api
176
-     */
177
-    protected function secure($value, $keepQuotes = false, $encoding = 'UTF-8')
178
-    {
179
-        $flags = $keepQuotes ? ENT_NOQUOTES : ENT_COMPAT;
180
-        return htmlspecialchars($value, $flags, $encoding);
181
-    }
182
-
183
-    /**
184
-     * Get the Vidi Module Loader.
185
-     *
186
-     * @return object|ModuleLoader
187
-     */
188
-    protected function getModuleLoader()
189
-    {
190
-        return GeneralUtility::makeInstance(ModuleLoader::class);
191
-    }
192
-
193
-    /**
194
-     * @return object|IconFactory
195
-     */
196
-    protected function getIconFactory()
197
-    {
198
-        return GeneralUtility::makeInstance(IconFactory::class);
199
-    }
200
-
201
-    /**
202
-     * @return object|LanguageService
203
-     */
204
-    protected function getLanguageService()
205
-    {
206
-        return GeneralUtility::makeInstance(LanguageService::class);
207
-    }
22
+	/**
23
+	 * The content object.
24
+	 *
25
+	 * @var Content
26
+	 */
27
+	protected $object;
28
+
29
+	/**
30
+	 * @var string
31
+	 */
32
+	protected $fieldName;
33
+
34
+	/**
35
+	 * @var int
36
+	 */
37
+	protected $rowIndex;
38
+
39
+	/**
40
+	 * @var array
41
+	 */
42
+	protected $fieldConfiguration = [];
43
+
44
+	/**
45
+	 * @var array
46
+	 */
47
+	protected $gridRendererConfiguration = [];
48
+
49
+	/**
50
+	 * @var array
51
+	 */
52
+	protected $configuration = [];
53
+
54
+	/**
55
+	 * Constructor of a Generic component in Vidi.
56
+	 *
57
+	 * @param array $configuration
58
+	 * @param array $legacyParameterConfiguration
59
+	 */
60
+	public function __construct($configuration = [], $legacyParameterConfiguration = array())
61
+	{
62
+		if (is_string($configuration)) {
63
+			$configuration = $legacyParameterConfiguration;
64
+			trigger_error('ColumnRendererAbstract: first parameter must now be an array. Please edit me in ' . get_class($this), E_USER_DEPRECATED);
65
+		}
66
+		$this->configuration = $configuration;
67
+	}
68
+
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function getConfiguration()
73
+	{
74
+		return $this->configuration;
75
+	}
76
+
77
+	/**
78
+	 * @return Content
79
+	 */
80
+	public function getObject()
81
+	{
82
+		return $this->object;
83
+	}
84
+
85
+	/**
86
+	 * @param Content $object
87
+	 * @return $this
88
+	 */
89
+	public function setObject($object)
90
+	{
91
+		$this->object = $object;
92
+		return $this;
93
+	}
94
+
95
+	/**
96
+	 * @return string
97
+	 */
98
+	public function getFieldName()
99
+	{
100
+		return $this->fieldName;
101
+	}
102
+
103
+	/**
104
+	 * @param string $fieldName
105
+	 * @return $this
106
+	 */
107
+	public function setFieldName($fieldName)
108
+	{
109
+		$this->fieldName = $fieldName;
110
+		return $this;
111
+	}
112
+
113
+	/**
114
+	 * @return int
115
+	 */
116
+	public function getRowIndex()
117
+	{
118
+		return $this->rowIndex;
119
+	}
120
+
121
+	/**
122
+	 * @param int $rowIndex
123
+	 * @return $this
124
+	 */
125
+	public function setRowIndex($rowIndex)
126
+	{
127
+		$this->rowIndex = $rowIndex;
128
+		return $this;
129
+	}
130
+
131
+	/**
132
+	 * @return array
133
+	 */
134
+	public function getFieldConfiguration()
135
+	{
136
+		return $this->fieldConfiguration;
137
+	}
138
+
139
+	/**
140
+	 * @param array $fieldConfiguration
141
+	 * @return $this
142
+	 */
143
+	public function setFieldConfiguration($fieldConfiguration)
144
+	{
145
+		$this->fieldConfiguration = $fieldConfiguration;
146
+		return $this;
147
+	}
148
+
149
+	/**
150
+	 * @return array
151
+	 */
152
+	public function getGridRendererConfiguration()
153
+	{
154
+		return $this->gridRendererConfiguration;
155
+	}
156
+
157
+	/**
158
+	 * @param array $gridRendererConfiguration
159
+	 * @return $this
160
+	 */
161
+	public function setGridRendererConfiguration($gridRendererConfiguration)
162
+	{
163
+		$this->gridRendererConfiguration = $gridRendererConfiguration;
164
+		return $this;
165
+	}
166
+
167
+	/**
168
+	 * Escapes special characters with their escaped counterparts as needed using PHPs htmlentities() function.
169
+	 *
170
+	 * @param string $value string to format
171
+	 * @param bool $keepQuotes if TRUE, single and double quotes won't be replaced (sets ENT_NOQUOTES flag)
172
+	 * @param string $encoding
173
+	 * @return string
174
+	 * @see http://www.php.net/manual/function.htmlentities.php
175
+	 * @api
176
+	 */
177
+	protected function secure($value, $keepQuotes = false, $encoding = 'UTF-8')
178
+	{
179
+		$flags = $keepQuotes ? ENT_NOQUOTES : ENT_COMPAT;
180
+		return htmlspecialchars($value, $flags, $encoding);
181
+	}
182
+
183
+	/**
184
+	 * Get the Vidi Module Loader.
185
+	 *
186
+	 * @return object|ModuleLoader
187
+	 */
188
+	protected function getModuleLoader()
189
+	{
190
+		return GeneralUtility::makeInstance(ModuleLoader::class);
191
+	}
192
+
193
+	/**
194
+	 * @return object|IconFactory
195
+	 */
196
+	protected function getIconFactory()
197
+	{
198
+		return GeneralUtility::makeInstance(IconFactory::class);
199
+	}
200
+
201
+	/**
202
+	 * @return object|LanguageService
203
+	 */
204
+	protected function getLanguageService()
205
+	{
206
+		return GeneralUtility::makeInstance(LanguageService::class);
207
+	}
208 208
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
     {
62 62
         if (is_string($configuration)) {
63 63
             $configuration = $legacyParameterConfiguration;
64
-            trigger_error('ColumnRendererAbstract: first parameter must now be an array. Please edit me in ' . get_class($this), E_USER_DEPRECATED);
64
+            trigger_error('ColumnRendererAbstract: first parameter must now be an array. Please edit me in '.get_class($this), E_USER_DEPRECATED);
65 65
         }
66 66
         $this->configuration = $configuration;
67 67
     }
Please login to merge, or discard this patch.
Classes/Grid/RelationRenderer.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -20,150 +20,150 @@
 block discarded – undo
20 20
  */
21 21
 class RelationRenderer extends ColumnRendererAbstract
22 22
 {
23
-    /**
24
-     * Render a representation of the relation on the GUI.
25
-     *
26
-     * @return string
27
-     */
28
-    public function render()
29
-    {
30
-        if ($this->isBackendMode()) {
31
-            $output = $this->renderForBackend();
32
-        } else {
33
-            $output = $this->renderForFrontend();
34
-        }
35
-
36
-        return $output;
37
-    }
38
-
39
-    /**
40
-     * @return string
41
-     */
42
-    protected function renderForBackend()
43
-    {
44
-        $output = '';
45
-
46
-        // Get label of the foreign table.
47
-        $foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
48
-
49
-        if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
50
-            $foreignObject = $this->object[$this->fieldName];
51
-
52
-            if ($foreignObject) {
53
-                $output = sprintf(
54
-                    '<a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span>',
55
-                    $this->getEditUri($foreignObject),
56
-                    $this->object->getUid(),
57
-                    $this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
58
-                    $foreignObject[$foreignLabelField]
59
-                );
60
-            }
61
-        } elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
62
-            if (!empty($this->object[$this->fieldName])) {
63
-                /** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
64
-                foreach ($this->object[$this->fieldName] as $foreignObject) {
65
-                    $output .= sprintf(
66
-                        '<li><a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span></li>',
67
-                        $this->getEditUri($foreignObject),
68
-                        $this->object->getUid(),
69
-                        $this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
70
-                        $foreignObject[$foreignLabelField]
71
-                    );
72
-                }
73
-                $output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
74
-            }
75
-        }
76
-        return $output;
77
-    }
78
-
79
-    /**
80
-     * @return string
81
-     */
82
-    protected function renderForFrontend()
83
-    {
84
-        $output = '';
85
-
86
-        // Get label of the foreign table.
87
-        $foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
88
-
89
-        if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
90
-            $foreignObject = $this->object[$this->fieldName];
91
-
92
-            if ($foreignObject) {
93
-                $output = sprintf(
94
-                    '%s',
95
-                    $foreignObject[$foreignLabelField]
96
-                );
97
-            }
98
-        } elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
99
-            if (!empty($this->object[$this->fieldName])) {
100
-                /** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
101
-                foreach ($this->object[$this->fieldName] as $foreignObject) {
102
-                    $output .= sprintf(
103
-                        '<li>%s</li>',
104
-                        $foreignObject[$foreignLabelField]
105
-                    );
106
-                }
107
-                $output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
108
-            }
109
-        }
110
-        return $output;
111
-    }
112
-
113
-    /**
114
-     * Render an edit URI given an object.
115
-     *
116
-     * @param Content $object
117
-     * @return string
118
-     */
119
-    protected function getEditUri(Content $object)
120
-    {
121
-        $uri = BackendUtility::getModuleUrl(
122
-            'record_edit',
123
-            array(
124
-                $this->getEditParameterName($object) => 'edit',
125
-                'returnUrl' => $this->getModuleLoader()->getModuleUrl()
126
-            )
127
-        );
128
-        return $uri;
129
-    }
130
-
131
-    /**
132
-     * @param Content $object
133
-     * @return string
134
-     */
135
-    protected function getEditParameterName(Content $object)
136
-    {
137
-        return sprintf(
138
-            'edit[%s][%s]',
139
-            $object->getDataType(),
140
-            $object->getUid()
141
-        );
142
-    }
143
-
144
-    /**
145
-     * Return the label field of the foreign table.
146
-     *
147
-     * @param string $fieldName
148
-     * @return string
149
-     */
150
-    protected function getForeignTableLabelField($fieldName)
151
-    {
152
-        // Get TCA table service.
153
-        $table = Tca::table($this->object);
154
-
155
-        // Compute the label of the foreign table.
156
-        $relationDataType = $table->field($fieldName)->relationDataType();
157
-        return Tca::table($relationDataType)->getLabelField();
158
-    }
159
-
160
-    /**
161
-     * Returns whether the current mode is Frontend
162
-     *
163
-     * @return bool
164
-     */
165
-    protected function isBackendMode()
166
-    {
167
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
168
-    }
23
+	/**
24
+	 * Render a representation of the relation on the GUI.
25
+	 *
26
+	 * @return string
27
+	 */
28
+	public function render()
29
+	{
30
+		if ($this->isBackendMode()) {
31
+			$output = $this->renderForBackend();
32
+		} else {
33
+			$output = $this->renderForFrontend();
34
+		}
35
+
36
+		return $output;
37
+	}
38
+
39
+	/**
40
+	 * @return string
41
+	 */
42
+	protected function renderForBackend()
43
+	{
44
+		$output = '';
45
+
46
+		// Get label of the foreign table.
47
+		$foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
48
+
49
+		if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
50
+			$foreignObject = $this->object[$this->fieldName];
51
+
52
+			if ($foreignObject) {
53
+				$output = sprintf(
54
+					'<a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span>',
55
+					$this->getEditUri($foreignObject),
56
+					$this->object->getUid(),
57
+					$this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
58
+					$foreignObject[$foreignLabelField]
59
+				);
60
+			}
61
+		} elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
62
+			if (!empty($this->object[$this->fieldName])) {
63
+				/** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
64
+				foreach ($this->object[$this->fieldName] as $foreignObject) {
65
+					$output .= sprintf(
66
+						'<li><a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span></li>',
67
+						$this->getEditUri($foreignObject),
68
+						$this->object->getUid(),
69
+						$this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
70
+						$foreignObject[$foreignLabelField]
71
+					);
72
+				}
73
+				$output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
74
+			}
75
+		}
76
+		return $output;
77
+	}
78
+
79
+	/**
80
+	 * @return string
81
+	 */
82
+	protected function renderForFrontend()
83
+	{
84
+		$output = '';
85
+
86
+		// Get label of the foreign table.
87
+		$foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
88
+
89
+		if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
90
+			$foreignObject = $this->object[$this->fieldName];
91
+
92
+			if ($foreignObject) {
93
+				$output = sprintf(
94
+					'%s',
95
+					$foreignObject[$foreignLabelField]
96
+				);
97
+			}
98
+		} elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
99
+			if (!empty($this->object[$this->fieldName])) {
100
+				/** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
101
+				foreach ($this->object[$this->fieldName] as $foreignObject) {
102
+					$output .= sprintf(
103
+						'<li>%s</li>',
104
+						$foreignObject[$foreignLabelField]
105
+					);
106
+				}
107
+				$output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
108
+			}
109
+		}
110
+		return $output;
111
+	}
112
+
113
+	/**
114
+	 * Render an edit URI given an object.
115
+	 *
116
+	 * @param Content $object
117
+	 * @return string
118
+	 */
119
+	protected function getEditUri(Content $object)
120
+	{
121
+		$uri = BackendUtility::getModuleUrl(
122
+			'record_edit',
123
+			array(
124
+				$this->getEditParameterName($object) => 'edit',
125
+				'returnUrl' => $this->getModuleLoader()->getModuleUrl()
126
+			)
127
+		);
128
+		return $uri;
129
+	}
130
+
131
+	/**
132
+	 * @param Content $object
133
+	 * @return string
134
+	 */
135
+	protected function getEditParameterName(Content $object)
136
+	{
137
+		return sprintf(
138
+			'edit[%s][%s]',
139
+			$object->getDataType(),
140
+			$object->getUid()
141
+		);
142
+	}
143
+
144
+	/**
145
+	 * Return the label field of the foreign table.
146
+	 *
147
+	 * @param string $fieldName
148
+	 * @return string
149
+	 */
150
+	protected function getForeignTableLabelField($fieldName)
151
+	{
152
+		// Get TCA table service.
153
+		$table = Tca::table($this->object);
154
+
155
+		// Compute the label of the foreign table.
156
+		$relationDataType = $table->field($fieldName)->relationDataType();
157
+		return Tca::table($relationDataType)->getLabelField();
158
+	}
159
+
160
+	/**
161
+	 * Returns whether the current mode is Frontend
162
+	 *
163
+	 * @return bool
164
+	 */
165
+	protected function isBackendMode()
166
+	{
167
+		return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
168
+	}
169 169
 }
Please login to merge, or discard this patch.