Add CSV Formatter in services and fix bug on diplaying export and imports
modifié: core/lib/Thelia/Config/Resources/config.xml modifié: core/lib/Thelia/Controller/Admin/ExportController.php modifié: core/lib/Thelia/Controller/Admin/ImportController.php modifié: core/lib/Thelia/Core/FileFormat/Formatting/Formatter/CSVFormatter.php modifié: core/lib/Thelia/Core/FileFormat/Formatting/FormatterData.php
This commit is contained in:
@@ -175,5 +175,9 @@
|
|||||||
<service id="thelia.formatter.json_formatter" class="Thelia\Core\FileFormat\Formatting\Formatter\JsonFormatter">
|
<service id="thelia.formatter.json_formatter" class="Thelia\Core\FileFormat\Formatting\Formatter\JsonFormatter">
|
||||||
<tag name="thelia.formatter" />
|
<tag name="thelia.formatter" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service id="thelia.formatter.csv_formatter" class="Thelia\Core\FileFormat\Formatting\Formatter\CSVFormatter">
|
||||||
|
<tag name="thelia.formatter" />
|
||||||
|
</service>
|
||||||
</services>
|
</services>
|
||||||
</config>
|
</config>
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class ExportController extends BaseAdminController
|
|||||||
$loop = new ExportLoop($this->container);
|
$loop = new ExportLoop($this->container);
|
||||||
|
|
||||||
$loop->initializeArgs([
|
$loop->initializeArgs([
|
||||||
"export" => $export->getId()
|
"id" => $export->getId()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$query = $loop->buildModelCriteria();
|
$query = $loop->buildModelCriteria();
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ class ImportController extends BaseAdminController
|
|||||||
$loop = new ImportLoop($this->container);
|
$loop = new ImportLoop($this->container);
|
||||||
|
|
||||||
$loop->initializeArgs([
|
$loop->initializeArgs([
|
||||||
"export" => $import->getId()
|
"id" => $id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$query = $loop->buildModelCriteria();
|
$query = $loop->buildModelCriteria();
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class CSVFormatter extends AbstractFormatter
|
|||||||
public function encode(FormatterData $data)
|
public function encode(FormatterData $data)
|
||||||
{
|
{
|
||||||
$string = "";
|
$string = "";
|
||||||
|
|
||||||
$firstRow = $data->getRow();
|
$firstRow = $data->getRow();
|
||||||
$delimiterLength = strlen($this->delimiter);
|
$delimiterLength = strlen($this->delimiter);
|
||||||
$lineReturnLength = strlen($this->lineReturn);
|
$lineReturnLength = strlen($this->lineReturn);
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ class FormatterData
|
|||||||
* @return array|bool
|
* @return array|bool
|
||||||
* @throws \OutOfBoundsException
|
* @throws \OutOfBoundsException
|
||||||
*/
|
*/
|
||||||
public function getRow($index = 0)
|
public function getRow($index = 0, $reverseAliases = false)
|
||||||
{
|
{
|
||||||
if (empty($this->data)) {
|
if (empty($this->data)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -199,7 +199,11 @@ class FormatterData
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = $this->reverseAliases($this->data[$index], $this->aliases);
|
$row = $this->data[$index];
|
||||||
|
|
||||||
|
if ($reverseAliases === true) {
|
||||||
|
$row = $this->reverseAliases($row, $this->aliases);
|
||||||
|
}
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user