Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logical Theme System: Add event to register web routes #4663

Closed
ssddanbrown opened this issue Nov 9, 2023 · 2 comments
Closed

Logical Theme System: Add event to register web routes #4663

ssddanbrown opened this issue Nov 9, 2023 · 2 comments

Comments

@ssddanbrown
Copy link
Member

To allow easy registration of extra routes that require session and middlware.
Potentially have an option for registering auth routes? Maybe extra event or a passed parameter?

@ssddanbrown
Copy link
Member Author

Added via 22a9cf1

@ssddanbrown
Copy link
Member Author

Usage Example

<?php

use BookStack\Theming\ThemeEvents;
use BookStack\Facades\Theme;
use Illuminate\Routing\Router;

Theme::listen(ThemeEvents::ROUTES_REGISTER_WEB, function (Router $router) {

    $router->get('/counter', function () {
        $count = session()->get('counter', 0) + 1;
        session()->put('counter', $count);
        return "Count: {$count}";
    });
});

Theme::listen(ThemeEvents::ROUTES_REGISTER_WEB_AUTH, function (Router $router) {

    $router->get('/counter-auth', function () {
        $count = session()->get('secret-counter', 0) + 1;
        session()->put('secret-counter', $count);
        return "Count Authed: {$count}";
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant