Regaez/grav-plugin-api

fix: processing plugin config file

Regaez opened this issue · 0 comments

The GravApi\Config\Config class is instantiated in a non-sensical way: the api.php class passes $settings to the GravApi\Api class, which then passes this to create a new Config::instance($settings).

This is entirely unnecessary since we could just use Grav::instance() in the Config constructor to get the required plugin config information, thereby removing the need to pass $settings.

Also, Config is currently causing problems with the AuthMiddleware because it has a mix of array and stdClass for some reason. Therefore, in the middleware, the $this->config–>auth check is not reliable due to not handling these different types. Creating some Settings classes to standardise the structure and some functions to access could simplify the AuthMiddleware and greatly improve the reliability of the configuration info.

Not to mention that this config file is able to be manipulated by users, so could be imported with an invalid format!

Note: issue #34 could be resolved as part of this one, too.