Closed sukihub closed 7 years ago
PHPCS does not like the code in OAuthController
, it can be moved to bootstrap.php
, but that would require adding 'bootstrap' => true
option while loading the plugin.
I don't think a hardcoded App\Controller\AppController
is a bad thing. In fact it is a standard amongst all CakePHP plugins that have a controller. I would rather document how to create a class alias in the application code if you are not using the standard App
namespace.
Hm, I never came across a plugin that required me to create a class alias. Can you maybe give me an example?
The CakeDC Users plugin is one such example: https://github.com/CakeDC/users/blob/master/src/Controller/AppController.php
It doesn't require you to create a class alias, rather you need to create one if you are not using the standard App/
namespace.
I see.
What would you do, if you wanted to use 2 such plugins in one project, and wanted each to extend different app controller? You can't alias App\Controller\AppController twice. But each plugin can have its own alias.
Users and OAuthServer might not be the best examples, because they both deal with users :-)
But for example we want to have oauth's app controller separate from the rest of the app (mainly because the main app controller does things that we don't want to do in oauth - like load shopping cart, etc.).
But for example we want to have oauth's app controller separate from the rest of the app (mainly because the main app controller does things that we don't want to do in oauth - like load shopping cart, etc.).
Our solution here is conditional loading of things in our app controller. At this stage I'm not entirely sure what the best solution is though :)
Should be perfectly backwards compatible (not tested though).
Usage, in
app.php
: