-
Notifications
You must be signed in to change notification settings - Fork 18
FIPRO-37 Refactor AdminUser Class #13
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,8 @@ | |
| */ | ||
| namespace Vaimo\AdminAutoLogin\Model\Config\Source; | ||
|
|
||
| use function __; | ||
|
|
||
| class AdminUser implements \Magento\Framework\Option\ArrayInterface | ||
| class AdminUsernameList | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ArrayInterface is actually needed, for the dropdown in module's admin config when selecting the admin user to automatically log in as. So please refactor like this:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow totally missed that 😁. That's a smart idea, thank you! Regarding the indentation I'm not sure I agree.. But maybe we should change the whole styling of this module anyways. It's kind of weird / out dated.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should style according to Magento coding standard guidelines with phpcs! |
||
| { | ||
|
|
||
| /** | ||
| * @var \Magento\User\Model\ResourceModel\User\Collection | ||
| */ | ||
|
|
@@ -21,12 +18,13 @@ class AdminUser implements \Magento\Framework\Option\ArrayInterface | |
| private $users; | ||
|
|
||
| /** | ||
| * AdminUser constructor. | ||
| * AdminUsernameList constructor. | ||
| * | ||
| * @param \Magento\User\Model\ResourceModel\User\Collection $userCollection | ||
| */ | ||
| public function __construct(\Magento\User\Model\ResourceModel\User\Collection $userCollection) | ||
| { | ||
| public function __construct( | ||
| \Magento\User\Model\ResourceModel\User\Collection $userCollection | ||
| ) { | ||
| $this->userCollection = $userCollection; | ||
| } | ||
|
|
||
|
|
@@ -36,7 +34,7 @@ public function __construct(\Magento\User\Model\ResourceModel\User\Collection $u | |
| * @param bool $includeEmptyChoice | ||
| * @return array | ||
| */ | ||
| public function toArray($includeEmptyChoice = true) | ||
| public function get($includeEmptyChoice = true) | ||
| { | ||
| if ($this->users === null) { | ||
| $this->users = []; | ||
|
|
@@ -56,20 +54,4 @@ public function toArray($includeEmptyChoice = true) | |
| return $this->users; | ||
| } | ||
|
|
||
| /** | ||
| * Options getter | ||
| * | ||
| * @return array | ||
| */ | ||
| public function toOptionArray() | ||
| { | ||
| $users = []; | ||
|
|
||
| foreach ($this->toArray() as $value => $label) { | ||
| $users[] = ['value' => $value, 'label' => $label]; | ||
| } | ||
|
|
||
| return $users; | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of the fancy indentation, it's a pain to upkeep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm.. maybe we should change the whole styling of the code anyway.