Skip to content

Commit e5fec6a

Browse files
authored
Merge pull request #50 from keboola/tf2-manifest-json-file-helper
Use JsonFileHelper to read/write manifests
2 parents 5c7c604 + eb101b9 commit e5fec6a

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
},
2828
"require": {
2929
"php": "^7.1",
30+
"ext-json": "*",
3031
"monolog/monolog": "^1.23",
3132
"symfony/config": "^4.0",
3233
"symfony/filesystem": "^4.0",

src/Manifest/ManifestManager.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
namespace Keboola\Component\Manifest;
66

77
use InvalidArgumentException;
8+
use Keboola\Component\JsonFileHelper;
89
use Keboola\Component\Manifest\ManifestManager\Options\OutFileManifestOptions;
910
use Keboola\Component\Manifest\ManifestManager\Options\OutTableManifestOptions;
1011
use Symfony\Component\Filesystem\Filesystem;
11-
use Symfony\Component\Serializer\Encoder\JsonEncoder;
12-
use const PATHINFO_EXTENSION;
13-
use function file_get_contents;
1412
use function pathinfo;
13+
use const PATHINFO_EXTENSION;
1514

1615
/**
1716
* Handles everything related to generating and reading manifests for tables and files.
@@ -98,8 +97,7 @@ private function loadManifest(string $fileName, string $baseDir): array
9897
return [];
9998
}
10099

101-
$decoder = new JsonEncoder();
102-
return $decoder->decode(file_get_contents($manifestFilename), JsonEncoder::FORMAT);
100+
return JsonFileHelper::read($manifestFilename);
103101
}
104102

105103
/**
@@ -108,10 +106,7 @@ private function loadManifest(string $fileName, string $baseDir): array
108106
*/
109107
private function internalWriteManifest(string $manifestAbsolutePath, array $manifestContents): void
110108
{
111-
$encoder = new JsonEncoder();
112-
$manifestJson = $encoder->encode($manifestContents, JsonEncoder::FORMAT);
113-
$filesystem = new Filesystem();
114-
$filesystem->dumpFile($manifestAbsolutePath, $manifestJson . "\n");
109+
JsonFileHelper::write($manifestAbsolutePath, $manifestContents, false);
115110
}
116111

117112
/**

0 commit comments

Comments
 (0)