Newer
Older
<?php
namespace Config;
// Create a new instance of our RouteCollection class.
$routes = Services::routes();
// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php')) {
require SYSTEMPATH . 'Config/Routes.php';
}
/**
* --------------------------------------------------------------------
* Router Setup
* --------------------------------------------------------------------
*/
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(false);

Yassine Doghri
committed
$routes->addPlaceholder('podcastName', '[a-zA-Z0-9\_]{1,191}');
$routes->addPlaceholder('episodeSlug', '[a-zA-Z0-9\-]{1,191}');

Yassine Doghri
committed
$routes->addPlaceholder('username', '[a-zA-Z0-9 ]{3,}');
/**
* --------------------------------------------------------------------
* Route Definitions
* --------------------------------------------------------------------
*/
// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'Home::index', ['as' => 'home']);
// Public routes
$routes->group('@(:podcastName)', function ($routes) {
$routes->get('/', 'Podcast/$1', ['as' => 'podcast']);

Yassine Doghri
committed
$routes->get('feed.xml', 'Feed/$1', ['as' => 'podcast_feed']);
$routes->get('episodes/(:episodeSlug)', 'Episode/$1/$2', [

Yassine Doghri
committed
'as' => 'episode',
// Route for podcast audio file analytics (/stats/podcast_id/episode_id/podcast_folder/filename.mp3)
$routes->add('stats/(:num)/(:num)/(:any)', 'Analytics::hit/$1/$2/$3', [
'as' => 'analytics_hit',
]);
// Show the Unknown UserAgents
$routes->get('.well-known/unknown-useragents', 'UnknownUserAgents');
$routes->get('.well-known/unknown-useragents/(:num)', 'UnknownUserAgents/$1');

Yassine Doghri
committed
// Admin area
$routes->group(
config('App')->adminGateway,
['namespace' => 'App\Controllers\Admin'],
function ($routes) {
$routes->get('/', 'Home', [

Yassine Doghri
committed
]);
$routes->get('podcasts', 'Podcast::list', [
'as' => 'podcast_list',
'filter' => 'permission:podcasts-list',
]);
$routes->get('new-podcast', 'Podcast::create', [

Yassine Doghri
committed
'as' => 'podcast_create',
'filter' => 'permission:podcasts-create',
]);
$routes->post('new-podcast', 'Podcast::attemptCreate', [
'filter' => 'permission:podcasts-create',

Yassine Doghri
committed
]);
// Use ids in admin area to help permission and group lookups
$routes->group('podcasts/(:num)', function ($routes) {
$routes->get('/', 'Podcast::view/$1', [
'as' => 'podcast_view',
]);
$routes->get('edit', 'Podcast::edit/$1', [

Yassine Doghri
committed
'as' => 'podcast_edit',
]);
$routes->post('edit', 'Podcast::attemptEdit/$1');

Yassine Doghri
committed
$routes->add('delete', 'Podcast::delete/$1', [
'as' => 'podcast_delete',
]);
// Podcast episodes
$routes->get('episodes', 'Episode::list/$1', [
'as' => 'episode_list',
]);
$routes->get('new-episode', 'Episode::create/$1', [

Yassine Doghri
committed
'as' => 'episode_create',
]);
$routes->post('new-episode', 'Episode::attemptCreate/$1');
$routes->get('episodes/(:num)', 'Episode::view/$1/$2', [
'as' => 'episode_view',
]);
$routes->get('episodes/(:num)/edit', 'Episode::edit/$1/$2', [
'as' => 'episode_edit',
]);
$routes->post('episodes/(:num)/edit', 'Episode::attemptEdit/$1/$2');
$routes->add('episodes/(:num)/delete', 'Episode::delete/$1/$2', [
'as' => 'episode_delete',

Yassine Doghri
committed
]);
// Podcast contributors
$routes->get('contributors', 'Contributor::list/$1', [
'as' => 'contributor_list',
]);
$routes->get('add-contributor', 'Contributor::add/$1', [
'as' => 'contributor_add',
]);
$routes->post('add-contributor', 'Contributor::attemptAdd/$1');
$routes->get(
'contributors/(:num)/edit',
'Contributor::edit/$1/$2',

Yassine Doghri
committed
[
'as' => 'contributor_edit',

Yassine Doghri
committed
]
);
$routes->post(
'contributors/(:num)/edit',
'Contributor::attemptEdit/$1/$2'
);

Yassine Doghri
committed
$routes->add(
'contributors/(:num)/remove',
'Contributor::remove/$1/$2',
['as' => 'contributor_remove']

Yassine Doghri
committed
);
});
// Users
$routes->get('users', 'User::list', [
'as' => 'user_list',
'filter' => 'permission:users-list',
]);
$routes->get('new-user', 'User::create', [
'as' => 'user_create',
'filter' => 'permission:users-create',
]);
$routes->post('new-user', 'User::attemptCreate', [
'filter' => 'permission:users-create',
]);

Yassine Doghri
committed
$routes->add('users/(:num)/ban', 'User::ban/$1', [

Yassine Doghri
committed
'as' => 'user_ban',
'filter' => 'permission:users-manage_bans',

Yassine Doghri
committed
]);
$routes->add('users/(:num)/unban', 'User::unBan/$1', [

Yassine Doghri
committed
'as' => 'user_unban',
'filter' => 'permission:users-manage_bans',

Yassine Doghri
committed
]);
$routes->add(
'users/(:num)/force-pass-reset',

Yassine Doghri
committed
'User::forcePassReset/$1',
[
'as' => 'user_force_pass_reset',
'filter' => 'permission:users-force_pass_reset',

Yassine Doghri
committed
]
);
$routes->add('users/(:num)/delete', 'User::delete/$1', [

Yassine Doghri
committed
'as' => 'user_delete',
'filter' => 'permission:users-delete',

Yassine Doghri
committed
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
]);
// My account
$routes->get('my-account', 'Myaccount', [
'as' => 'myAccount',
]);
$routes->get(
'my-account/change-password',
'Myaccount::changePassword/$1',
[
'as' => 'myAccount_change-password',
]
);
$routes->post(
'my-account/change-password',
'Myaccount::attemptChange/$1',
[
'as' => 'myAccount_change-password',
]
);
}
);
/**
* Overwriting Myth:auth routes file
*/
$routes->group(config('App')->authGateway, function ($routes) {
// Login/out
$routes->get('login', 'Auth::login', ['as' => 'login']);
$routes->post('login', 'Auth::attemptLogin');
$routes->get('logout', 'Auth::logout', ['as' => 'logout']);
// Registration
$routes->get('register', 'Auth::register', [
'as' => 'register',
]);
$routes->post('register', 'Auth::attemptRegister');
// Activation
$routes->get('activate-account', 'Auth::activateAccount', [
'as' => 'activate-account',
]);
$routes->get('resend-activate-account', 'Auth::resendActivateAccount', [
'as' => 'resend-activate-account',
]);
// Forgot/Resets
$routes->get('forgot', 'Auth::forgotPassword', [
'as' => 'forgot',
]);
$routes->post('forgot', 'Auth::attemptForgot');
$routes->get('reset-password', 'Auth::resetPassword', [
'as' => 'reset-password',
]);
$routes->post('reset-password', 'Auth::attemptReset');
$routes->get('change-password', 'Auth::changePassword', [
'as' => 'change_pass',
]);
$routes->post('change-password', 'Auth::attemptChange');
});
/**
* --------------------------------------------------------------------
* Additional Routing
* --------------------------------------------------------------------
*
* There will often be times that you need additional routing and you
* need to it be able to override any defaults in this file. Environment
* based routes is one such time. require() additional route files here
* to make that happen.
*
* You will have access to the $routes object within that file without
* needing to reload it.
*/
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';