Skip to content

Instantly share code, notes, and snippets.

@drajathasan
Created September 30, 2023 07:52
Show Gist options
  • Save drajathasan/7b08c2991b4f0b49a9882c67637e5880 to your computer and use it in GitHub Desktop.
Save drajathasan/7b08c2991b4f0b49a9882c67637e5880 to your computer and use it in GitHub Desktop.
slims-plugin-maker.console
<?php
namespace Commands;
use SLiMS\Cli\Command;
use SLiMS\Filesystems\Storage;
class PluginMaker extends Command
{
/**
* Signature is combination of command name
* argument and options
*
* @var string
*/
protected string $signature = 'make:plugin {pluginname}';
/**
* Command description
*
* @var string
*/
protected string $description = 'Create plugin base';
/**
* Handle command process
*
* @return void
*/
public function handle()
{
$pluginName = $this->argument('pluginname');
Storage::plugin()->makeDirectory($pluginName);
Storage::plugin()->put($pluginName . DS . $pluginName . '.plugin.php', $this->setContent($pluginName));
$this->success('Plugin ' . $pluginName . ' has beed created');
}
private function setContent(string $pluginName)
{
return str_replace('<plugin_name>', $pluginName, '<?php
/**
* Plugin Name: <plugin_name>
* Plugin URI: -
* Description: -
* Version: 1.0.0
* Author: -
* Author URI: -
*/
use SLiMS\Plugins;');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment