Skip to content

Commit 3ae2686

Browse files
committed
Move route initialization from system to core sprinkle...
...as router service is located in the core sprinkle
1 parent eb2ec33 commit 3ae2686

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1515
- Sprinkle list in the bakery `debug` command to uses the new `sprinkle:list` table
1616
- `routerCacheFile` config now only contains filename. Locator is used to find the full path
1717
- Moved some constants from `app/defines.php` to `app/sprinkles/core/defines.php`
18+
- Move route initialization from system to core sprinkle as router service is located in the core sprinkle
1819

1920
### Fix
2021
- Fix for `Test` Bakery command

app/sprinkles/core/src/Core.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public static function getSubscribedEvents()
4444
return [
4545
'onSprinklesInitialized' => ['onSprinklesInitialized', 0],
4646
'onSprinklesRegisterServices' => ['onSprinklesRegisterServices', 0],
47-
'onAddGlobalMiddleware' => ['onAddGlobalMiddleware', 0]
47+
'onAddGlobalMiddleware' => ['onAddGlobalMiddleware', 0],
48+
'onAppInitialize' => ['onAppInitialize', 0]
4849
];
4950
}
5051

@@ -103,6 +104,16 @@ public function onSprinklesRegisterServices()
103104
$sh->register();
104105
}
105106

107+
/**
108+
* Register routes
109+
*
110+
* @param Event $event
111+
*/
112+
public function onAppInitialize(Event $event)
113+
{
114+
$this->ci->router->loadRoutes($event->getApp());
115+
}
116+
106117
/**
107118
* Add CSRF middleware.
108119
*

app/system/UserFrosting.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ protected function setupApp()
149149

150150
$this->fireEvent('onAppInitialize', $slimAppEvent);
151151

152-
// Set up all routes
153-
$this->ci->router->loadRoutes($this->app);
154-
155152
// Add global middleware
156153
$this->fireEvent('onAddGlobalMiddleware', $slimAppEvent);
157154
}

0 commit comments

Comments
 (0)