-
Notifications
You must be signed in to change notification settings - Fork 69
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
Replace direct access to sites with getSites #305
Replace direct access to sites with getSites #305
Conversation
Looking good! As far as I'm concerned, this can be merged! |
@@ -119,18 +119,19 @@ public function readTarget($target) | |||
$environment = $exploded[1]; | |||
} | |||
|
|||
if (!array_key_exists($site, $this->sites)) { | |||
$sites = $this->getSites(); |
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.
@LOBsTerr By calling the $this->getSites();
method the this->sites
array wiill be filled with sites data.
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.
@jmolivas a proposal by nvaken here hechoendrupal/drupal-console#3761 to have a single point of access to sites property.
Theoretically, the $this->site
can be empty, if we didn't call $this->getSite()
before in https://github.com/hechoendrupal/drupal-console-core/blob/master/src/Command/Debug/SiteCommand.php#L70
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.
@LOBsTerr What I mean is to add the $this->getSites();
above this line:
if (!array_key_exists($site, $this->sites)) {
Then $this->sites
will contain data since $this->getSites();
call will add that.
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.
So what you’re saying is call $this->getSites() without assigning it to $sites and just keep getting data from $this->sites directly? I think assigning it to a local variable (like @LOBsTerr did) is best practice performance wise, isn’t it?
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.
@nvaken exactly I was trying to say that but is true local scope var is faster than the class one, we can keep this PR as it is.
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.
I will go ahead and merge it
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.
Awesome!👏👏
No description provided.