From 2d6d6d968b61ec4acb19815190a2e7c2418dde75 Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Tue, 13 Jun 2017 10:56:06 +0200 Subject: [PATCH] add console command docs --- README.md | 11 +++- .../separate-frontend-and-backend-sessions.md | 6 ++ docs/installation/console-commands.md | 62 +++++++++++++++++++ src/User/Command/CreateController.php | 1 + src/User/Service/MailService.php | 5 +- 5 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 docs/installation/console-commands.md diff --git a/README.md b/README.md index ba53335..1d8efc9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Yii2 Usuario Extension +Yii 2 Usuario Extension ====================== [![Documentation Status](https://readthedocs.org/projects/yii2-usuario/badge/?version=latest)](http://yii2-usuario.readthedocs.io/en/latest/?badge=latest) @@ -39,5 +39,14 @@ Please, remember that we may not be online all the time. We expect that we can b Please, read our [CONTRIBUTION guidelines](CONTRIBUTING.md). +## Credits + +This module is highly inspired by the excellent work of [Dektrium](https://dektrium.com/) on both of its modules: + +- [Yii 2 User](https://github.com/dektrium/yii2-user) +- [Yii 2 RBAC](https://github.com/dektrium/yii2-rbac) + +In fact, we have used some of its processes, commands, views, and some of its attribute names to somehow standardize the +modules and make it easier for our developers to swap from [Dektrium's](https://dektrium.com) modules to our own. [![2amigOS!](https://s.gravatar.com/avatar/55363394d72945ff7ed312556ec041e0?s=80)](http://www.2amigos.us) diff --git a/docs/helpful-guides/separate-frontend-and-backend-sessions.md b/docs/helpful-guides/separate-frontend-and-backend-sessions.md index 8b13789..e6d246d 100644 --- a/docs/helpful-guides/separate-frontend-and-backend-sessions.md +++ b/docs/helpful-guides/separate-frontend-and-backend-sessions.md @@ -1 +1,7 @@ +Separate Frontend and Backend Sessions +====================================== +- TODO + + +© [2amigos](http://www.2amigos.us/) 2013-2017 diff --git a/docs/installation/console-commands.md b/docs/installation/console-commands.md new file mode 100644 index 0000000..b9c8e9f --- /dev/null +++ b/docs/installation/console-commands.md @@ -0,0 +1,62 @@ +Console Commands +================ + +The module comes with a set of console commands to facilitate some of the most common actions during development time: + +- `user/create` to create a new user +- `user/confirm` to confirm a user +- `user/delete` to delete a user +- `user/password` to update a user's password + + +Configuration +------------- + +To enable the commands add the following configuration details to your console config of your application: + +```php +// ... + +'modules' => [ + 'user' => Da\User\Module::class, +] +``` + +How to Use Them +--------------- + +#### user/create + +If password is not set, it will automatically generate it. The newly created user will receive an email message with its +new credentials. + +```php +./yii user/create [password] +``` + +#### user/confirm + +You can confirm a user whether by using its email or username. + +```php +./yii user/confirm +``` + +#### user/delete + +You can delete a user whether by using its email or username. + +```php +./yii user/delete +``` + +#### user/delete + +You can update a user's password whether by using its email or username. + +```php +./yii user/password +``` + + +© [2amigos](http://www.2amigos.us/) 2013-2017 diff --git a/src/User/Command/CreateController.php b/src/User/Command/CreateController.php index e313fdf..0534289 100644 --- a/src/User/Command/CreateController.php +++ b/src/User/Command/CreateController.php @@ -25,6 +25,7 @@ class CreateController extends Controller public function actionIndex($email, $username, $password = null) { + /** @var User $user */ $user = $this->make( User::class, ['scenario' => 'create', 'email' => $email, 'username' => $username, 'password' => $password] diff --git a/src/User/Service/MailService.php b/src/User/Service/MailService.php index fc80cb8..10655bf 100644 --- a/src/User/Service/MailService.php +++ b/src/User/Service/MailService.php @@ -5,6 +5,7 @@ namespace Da\User\Service; use Da\User\Contracts\ServiceInterface; use Yii; use yii\mail\BaseMailer; +use yii\mail\MailerInterface; class MailService implements ServiceInterface { @@ -25,9 +26,9 @@ class MailService implements ServiceInterface * @param string $subject * @param string $view * @param array $params - * @param MailerInterface $mailer + * @param BaseMailer|MailerInterface $mailer */ - public function __construct($from, $to, $subject, $view, array $params, BaseMailer $mailer) + public function __construct($from, $to, $subject, $view, array $params, MailerInterface $mailer) { $this->from = $from; $this->to = $to;