franklingu You have created a controller class, that's good. Now you do not instantiate that controller anywhere yourself, right? That's where some of Laravel's magic comes in.
In your controllers, constructor, you can define dependencies that your controller needs, like so:
use Flarum\Settings\SettingsRepositoryInterface;
class MyController {
public function __construct(SettingsRepositoryInterface $settings)
{ /* ... */ }
}
Flarum will try to create your controller for you. Based on the signature of the constructor, it can determine which kind of parameters you want passed in. In this case, an object that implements the SettingsRepositoryInterface
interface.
Because we have set that up for you, Flarum knows to inject the correct implementation. So now you have access to an object that you can store as a class property, which you can then use (for example in your handle
method) to read and write settings. Great, huh?
In fact, the Facebook OAuth extension does exactly that. Take a look at its controller code, it should help you along...