Skip to content

Commit

Permalink
Merge pull request #992 from cakephp/bake-hasplugin
Browse files Browse the repository at this point in the history
Add a method to BakeHelper to check for other plugins.
  • Loading branch information
markstory authored Jun 17, 2024
2 parents b8f25d0 + e7413c1 commit 246a0ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/View/Helper/BakeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Brick\VarExporter\VarExporter;
use Cake\Core\Configure;
use Cake\Core\ConventionsTrait;
use Cake\Core\Plugin;
use Cake\Database\Schema\TableSchema;
use Cake\Database\Type\EnumType;
use Cake\Database\TypeFactory;
Expand Down Expand Up @@ -167,6 +168,16 @@ public function classInfo(string $class, string $type, string $suffix): array
];
}

/**
* Check if the current application has a plugin installed
*
* @param string $plugin The plugin name to check for.
*/
public function hasPlugin(string $plugin): bool
{
return Plugin::isLoaded($plugin);
}

/**
* Return list of fields to generate controls for.
*
Expand Down
6 changes: 6 additions & 0 deletions tests/TestCase/View/Helper/BakeHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,10 @@ public function testConcat(): void
$code
);
}

public function testHasPlugin(): void
{
$this->assertTrue($this->BakeHelper->hasPlugin('Bake'));
$this->assertFalse($this->BakeHelper->hasPlugin('Authentication'));
}
}

0 comments on commit 246a0ac

Please sign in to comment.