Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update to Dice 4.0
  • Loading branch information
solleer committed Apr 12, 2019
commit 049935717088720fbdb5b4616129e2c9edba3c7c
9 changes: 4 additions & 5 deletions ModuleJson.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php
namespace Level2\Router\Config;
class ModuleJson implements \Level2\Router\Rule {
private $dice;
private $moduleDir;
private $configFile;
private $moduleNames;
private $jsonLoader;
private $request;

public function __construct(\Dice\Dice $dice, \Level2\Core\Request $request, $moduleDir = 'Modules', $configFile = 'manifest.json') {
Expand Down Expand Up @@ -76,7 +75,7 @@ private function mergeConfig($orig, $ext) {

private function getModel($settings, $name = '') {
if (class_exists($settings['instanceOf'])) {
$this->dice->addRule('$Model_' . $name, $settings);
$this->dice = $this->dice->addRule('$Model_' . $name, $settings);
$model = $this->dice->create('$Model_' . $name, [], []);
}
else {
Expand All @@ -86,7 +85,7 @@ private function getModel($settings, $name = '') {
}

private function getRoute($routeSettings, $route) {
$this->dice->addRule('$View', $routeSettings['view']);
$this->dice = $this->dice->addRule('$View', $routeSettings['view']);

if (isset($routeSettings['model'])) {
$model = $this->getModel($routeSettings['model']);
Expand All @@ -113,7 +112,7 @@ private function getRoute($routeSettings, $route) {
$controllerRule['call'][] = [$action, $route, function ($return) use (&$model) {
if (is_object($return)) $model = $return;
}];
$this->dice->addRule('$controller', $controllerRule);
$this->dice = $this->dice->addRule('$controller', $controllerRule);
if (is_array($model)) {
$controller = $this->dice->create('$Controller', [], array_merge(array_values($model), [$this->request]));
}
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
],
"require": {
"php": ">=5.5.0",
"level-2/router" : "dev-master"
"level-2/router" : "dev-master",
"level-2/dice" : "^4.0"
},
"autoload": {
"classmap": ["./"]
Expand Down