mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 06:34:35 -04:00
Change JSON parser
This commit is contained in:
parent
8cbaac53c6
commit
6f1b4d4548
@ -96,7 +96,7 @@ class Import implements ShouldQueue
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $data;
|
private $data; //the file path - using a different JSON parser here.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Company
|
* @var Company
|
||||||
@ -163,7 +163,7 @@ class Import implements ShouldQueue
|
|||||||
* @param User $user
|
* @param User $user
|
||||||
* @param array $resources
|
* @param array $resources
|
||||||
*/
|
*/
|
||||||
public function __construct(array $data, Company $company, User $user, array $resources = [])
|
public function __construct(string $data, Company $company, User $user, array $resources = [])
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
@ -180,9 +180,9 @@ class Import implements ShouldQueue
|
|||||||
{
|
{
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
info(print_r(array_keys($this->data),1));
|
$jsonStream = \JsonMachine\JsonMachine::fromFile($this->data, "/data");
|
||||||
|
|
||||||
foreach ($this->data as $key => $resource) {
|
foreach ($jsonStream as $key => $resource) {
|
||||||
if (! in_array($key, $this->available_imports)) {
|
if (! in_array($key, $this->available_imports)) {
|
||||||
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
||||||
info("Resource {$key} is not available for migration.");
|
info("Resource {$key} is not available for migration.");
|
||||||
@ -779,8 +779,8 @@ info(print_r(array_keys($this->data),1));
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function processPayments(array $data): void
|
private function processPayments(array $data): void
|
||||||
{info(print_r($this->ids,1));
|
{
|
||||||
|
|
||||||
Payment::reguard();
|
Payment::reguard();
|
||||||
|
|
||||||
$rules = [
|
$rules = [
|
||||||
|
@ -107,9 +107,9 @@ class StartMigration implements ShouldQueue
|
|||||||
throw new NonExistingMigrationFile('Migration file does not exist, or it is corrupted.');
|
throw new NonExistingMigrationFile('Migration file does not exist, or it is corrupted.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = json_decode(file_get_contents($file), 1);
|
//$data = json_decode(file_get_contents($file), 1);
|
||||||
|
//Import::dispatchNow($data['data'], $this->company, $this->user);
|
||||||
Import::dispatchNow($data['data'], $this->company, $this->user);
|
Import::dispatchNow($file, $this->company, $this->user);
|
||||||
} catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
|
} catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
|
||||||
|
|
||||||
Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
|
Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
"fzaninotto/faker": "^1.4",
|
"fzaninotto/faker": "^1.4",
|
||||||
"google/apiclient": "^2.7",
|
"google/apiclient": "^2.7",
|
||||||
"guzzlehttp/guzzle": "^7.0.1",
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
|
"halaxa/json-machine": "^0.4.0",
|
||||||
"hashids/hashids": "^3.0",
|
"hashids/hashids": "^3.0",
|
||||||
"intervention/image": "^2.5",
|
"intervention/image": "^2.5",
|
||||||
"laracasts/presenter": "^0.2.1",
|
"laracasts/presenter": "^0.2.1",
|
||||||
|
50
composer.lock
generated
50
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "7e448a70f9bd66e655c3a9dab1159d66",
|
"content-hash": "a178576541f03dbaf5e757fb4c89b474",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "asgrim/ofxparser",
|
"name": "asgrim/ofxparser",
|
||||||
@ -2287,6 +2287,54 @@
|
|||||||
},
|
},
|
||||||
"time": "2020-09-30T07:37:11+00:00"
|
"time": "2020-09-30T07:37:11+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "halaxa/json-machine",
|
||||||
|
"version": "0.4.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/halaxa/json-machine.git",
|
||||||
|
"reference": "b99d7a9a1efc8ba633da4581cf079b3a6f1ed219"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/halaxa/json-machine/zipball/b99d7a9a1efc8ba633da4581cf079b3a6f1ed219",
|
||||||
|
"reference": "b99d7a9a1efc8ba633da4581cf079b3a6f1ed219",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.6"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"guzzlehttp/guzzle": "^6",
|
||||||
|
"phpunit/phpunit": "^5.7.27"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"JsonMachine\\": "src/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/functions.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"Apache-2.0"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Filip Halaxa",
|
||||||
|
"email": "filip@halaxa.cz"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Efficient, easy-to-use and fast JSON pull parser",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/halaxa/json-machine/issues",
|
||||||
|
"source": "https://github.com/halaxa/json-machine/tree/0.4.0"
|
||||||
|
},
|
||||||
|
"time": "2020-11-09T13:28:55+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "hashids/hashids",
|
"name": "hashids/hashids",
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user