-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix plugin with
/
in the name (#553)
* Fix plugin with `/` in the name
- Loading branch information
Showing
5 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/test_app/plugins/Orgname/Special/src/Controller/MyController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Orgname\Special\Controller; | ||
|
||
use SwaggerBake\Lib\Attribute\OpenApiResponse; | ||
|
||
class MyController | ||
{ | ||
/** | ||
* Just an example of a plugin. | ||
* | ||
* @return \Cake\Http\Response | ||
*/ | ||
#[OpenApiResponse(description: 'my', mimeTypes: ['text/plain'])] | ||
public function index() | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Orgname\Special; | ||
|
||
use Cake\Core\BasePlugin; | ||
use Cake\Core\PluginApplicationInterface; | ||
use Cake\Http\MiddlewareQueue; | ||
use Cake\Routing\RouteBuilder; | ||
use Cake\Console\CommandCollection; | ||
|
||
/** | ||
* Plugin for Orgname\Special | ||
*/ | ||
class Plugin extends BasePlugin | ||
{ | ||
/** | ||
* Load all the plugin configuration and bootstrap logic. | ||
* | ||
* The host application is provided as an argument. This allows you to load | ||
* additional plugin dependencies, or attach events. | ||
* | ||
* @param \Cake\Core\PluginApplicationInterface $app The host application | ||
* @return void | ||
*/ | ||
public function bootstrap(PluginApplicationInterface $app): void | ||
{ | ||
} | ||
|
||
/** | ||
* Add routes for the plugin. | ||
* | ||
* If your plugin has many routes and you would like to isolate them into a separate file, | ||
* you can create `$plugin/config/routes.php` and delete this method. | ||
* | ||
* @param \Cake\Routing\RouteBuilder $routes The route builder to update. | ||
* @return void | ||
*/ | ||
public function routes(RouteBuilder $routes): void | ||
{ | ||
$routes->plugin( | ||
'Orgname/Special', | ||
['path' => '/special'], | ||
function (RouteBuilder $builder) { | ||
// Add custom routes here | ||
$builder->setExtensions(['json','xml']); | ||
$builder->resources('My', ['only' => 'index']); | ||
$builder->fallbacks(); | ||
} | ||
); | ||
parent::routes($routes); | ||
} | ||
|
||
/** | ||
* Add middleware for the plugin. | ||
* | ||
* @param \Cake\Http\MiddlewareQueue $middleware The middleware queue to update. | ||
* @return \Cake\Http\MiddlewareQueue | ||
*/ | ||
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue | ||
{ | ||
// Add your middlewares here | ||
|
||
return $middlewareQueue; | ||
} | ||
|
||
/** | ||
* Add commands for the plugin. | ||
* | ||
* @param \Cake\Console\CommandCollection $commands The command collection to update. | ||
* @return \Cake\Console\CommandCollection | ||
*/ | ||
public function console(CommandCollection $commands) : CommandCollection | ||
{ | ||
// Add your commands here | ||
|
||
$commands = parent::console($commands); | ||
|
||
return $commands; | ||
} | ||
} |