Skip to content

Commit 3acb37e

Browse files
authored
Merge pull request #117 from cakephp/no-bake
Don't fail to load console when bake is not installed
2 parents 3930120 + d3104c8 commit 3acb37e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Plugin.php

+16
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,27 @@
1616
*/
1717
namespace Authorization;
1818

19+
use Authorization\Command\PolicyCommand;
20+
use Cake\Console\CommandCollection;
1921
use Cake\Core\BasePlugin;
2022

2123
/**
2224
* Plugin definition for Authorization
2325
*/
2426
class Plugin extends BasePlugin
2527
{
28+
/**
29+
* Add console commands if bake is also available.
30+
*
31+
* @param \Cake\Console\CommandCollection $commands The command collection to update
32+
* @return \Cake\Console\CommandCollection
33+
*/
34+
public function console(CommandCollection $commands): CommandCollection
35+
{
36+
if (class_exists('Bake\Command\SimpleBakeCommand')) {
37+
$commands->add('bake policy', PolicyCommand::class);
38+
}
39+
40+
return $commands;
41+
}
2642
}

0 commit comments

Comments
 (0)