Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev: Make command to create new OAuth #35

Merged
merged 11 commits into from
Apr 18, 2023
73 changes: 73 additions & 0 deletions src/Commands/Generators/NewShieldOauthGenerator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace Datamweb\ShieldOAuth\Commands\Generators;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\CLI\GeneratorTrait;

class NewShieldOauthGenerator extends BaseCommand
{
use GeneratorTrait;

/**
* The Command's Group
*
* @var string
*/
protected $group = 'ShieldOAuth';

/**
* The Command's Name
*
* @var string
*/
protected $name = 'make:oauth';

/**
* The Command's Description
*
* @var string
*/
protected $description = 'Adds new OAuth to Shield OAuth.';

/**
* The Command's Usage
*
* @var string
*/
protected $usage = 'make:oauth [<name>] [options]';

/**
* The Command's Arguments
*
* @var array
sammyskills marked this conversation as resolved.
Show resolved Hide resolved
*/
protected $arguments = [
'name' => 'The name of the new OAuth without the `OAuth` suffix. The `OAuth` suffix will be automatically added for you.'
];

/**
* The Command's Options
*
* @var array
sammyskills marked this conversation as resolved.
Show resolved Hide resolved
*/
protected $options = [
'--force' => 'Force overwrite existing file.',
sammyskills marked this conversation as resolved.
Show resolved Hide resolved
];

/**
* Actually execute a command.
*
* @param array $params
*/
public function run(array $params)
{
$this->component = 'Library';
$this->directory = 'Libraries/ShieldOAuth';
$this->template = 'newoauth.tpl.php';

// @TODO execute() is deprecated in CI v4.3.0.
$this->execute($params); // @phpstan-ignore-line suppress deprecated error.
}
}