diff --git a/composer.json b/composer.json index ec1ef53..5e0230f 100644 --- a/composer.json +++ b/composer.json @@ -5,6 +5,6 @@ }, "require" : { "level-2/maphper" : "^0.9", - "level-2/dice" : "^3.0" + "level-2/dice" : "^4.0" } } diff --git a/src/Json.php b/src/Json.php index 04c53e2..923379c 100644 --- a/src/Json.php +++ b/src/Json.php @@ -31,7 +31,7 @@ public function addLoader($datasourceType, DataSource $datasource) { } private function addMaphper($name, $config, DataSource $datasource) { - $this->dice->addRule('$Maphper_Source_' . $name, $datasource->load($config)); + $this->dice = $this->dice->addRule('$Maphper_Source_' . $name, $datasource->load($config)); $mapper = [ 'instanceOf' => 'Maphper\\Maphper', 'substitutions' => ['Maphper\\DataSource' => [\Dice\Dice::INSTANCE => '$Maphper_Source_' . $name]], @@ -48,12 +48,12 @@ private function addMaphper($name, $config, DataSource $datasource) { if (isset($config['resultClass'])) $mapper['constructParams'] = [['resultClass' => function () use ($config) { return $this->dice->create($config['resultClass']); }]]; - $this->dice->addRule('$Maphper_' . $name, $mapper); + $this->dice = $this->dice->addRule('$Maphper_' . $name, $mapper); } private function addRelation($relationRuleName, $relation) { if ($relation['type'] === "ManyMany") { - $this->dice->addRule($relationRuleName, [ + $this->dice = $this->dice->addRule($relationRuleName, [ 'instanceOf' => 'Maphper\Relation\ManyMany', 'constructParams' => [ [\Dice\Dice::INSTANCE => '$Maphper_' . $relation['intermediate']], @@ -63,7 +63,7 @@ private function addRelation($relationRuleName, $relation) { ]); } else { - $this->dice->addRule($relationRuleName, [ + $this->dice = $this->dice->addRule($relationRuleName, [ 'instanceOf' => 'Maphper\Relation\\' . ucwords($relation['type']), 'constructParams' => [ [\Dice\Dice::INSTANCE => '$Maphper_' . $relation['to']],