Skip to content

Commit 63bdf30

Browse files
authored
Merge pull request #129 from FriendsOfCake/transcoding-extension
Rename option "extension" to more intuitive "transcodingExtension".
2 parents ce1681d + bc7fc1c commit 63bdf30

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ The defaults are:
242242
** Only if those two variable are different your data will be converted to another encoding.
243243

244244
CsvView uses the `iconv` extension by default to encode your data. You can change
245-
the php extension used to encode your data by setting the `extension` option:
245+
the php extension used to encode your data by setting the `transcodingExtension` option:
246246

247247
```php
248-
$this->viewBuilder()->setOption('extension', 'mbstring');
248+
$this->viewBuilder()->setOption('transcodingExtension', 'mbstring');
249249
```
250250

251251
The currently supported encoding extensions are as follows:

src/View/CsvView.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class CsvView extends SerializedView
141141
* - 'setSeparator': (default false) Adds sep=[_delimiter] in the first line
142142
* - 'csvEncoding': (default 'UTF-8') CSV file encoding
143143
* - 'dataEncoding': (default 'UTF-8') Encoding of data to be serialized
144-
* - 'extension': (default 'iconv') PHP extension to use for character encoding conversion
144+
* - 'transcodingExtension': (default 'iconv') PHP extension to use for character encoding conversion
145145
*
146146
* @var array
147147
*/
@@ -159,7 +159,7 @@ class CsvView extends SerializedView
159159
'setSeparator' => false,
160160
'csvEncoding' => 'UTF-8',
161161
'dataEncoding' => 'UTF-8',
162-
'extension' => self::EXTENSION_ICONV,
162+
'transcodingExtension' => self::EXTENSION_ICONV,
163163
];
164164

165165
/**
@@ -178,10 +178,10 @@ public function initialize(): void
178178
];
179179

180180
if (
181-
$this->getConfig('extension') === self::EXTENSION_ICONV &&
181+
$this->getConfig('transcodingExtension') === static::EXTENSION_ICONV &&
182182
!extension_loaded(self::EXTENSION_ICONV)
183183
) {
184-
$this->setConfig('extension', self::EXTENSION_MBSTRING);
184+
$this->setConfig('transcodingExtension', static::EXTENSION_MBSTRING);
185185
}
186186

187187
parent::initialize();
@@ -354,10 +354,10 @@ protected function _generateRow(?array $row = null)
354354
$dataEncoding = $this->getConfig('dataEncoding');
355355
$csvEncoding = $this->getConfig('csvEncoding');
356356
if ($dataEncoding !== $csvEncoding) {
357-
$extension = $this->getConfig('extension');
358-
if ($extension === self::EXTENSION_ICONV) {
357+
$extension = $this->getConfig('transcodingExtension');
358+
if ($extension === static::EXTENSION_ICONV) {
359359
$csv = iconv($dataEncoding, $csvEncoding, $csv);
360-
} elseif ($extension === self::EXTENSION_MBSTRING) {
360+
} elseif ($extension === static::EXTENSION_MBSTRING) {
361361
$csv = mb_convert_encoding($csv, $csvEncoding, $dataEncoding);
362362
}
363363
}

0 commit comments

Comments
 (0)