Skip to content

Instantly share code, notes, and snippets.

@drajathasan
Created December 30, 2023 07:44
Show Gist options
  • Save drajathasan/5cb45f0ae309d7db3e1df1213509ae13 to your computer and use it in GitHub Desktop.
Save drajathasan/5cb45f0ae309d7db3e1df1213509ae13 to your computer and use it in GitHub Desktop.
SLiMS Plugin Maker Command
<?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