I was running a lint check on the examples module (see contrib) and IDE was picking up lots of warnings related to loggedInUser.
Making this small change removed 19 errors/warnings. ( 2% of total )
Looking at my IDE's report of the uses of $loggedInUser it is both variable I would want to be called $isUserLoggedIn and a \Drupal\Core\Session\AccountInterface object.
There is nothing particularly wrong with this design choice...
Writes to loggedInUser
WebTestBase::drupalLogin()
$this->loggedInUser = $account; // $account is of type \Drupal\Core\Session\AccountInterface;
WebTestBase::drupalLogout()
$this->loggedInUser = FALSE;
Read from loggedInUser
SimpleTestExampleTest::testSimeplTestExampleCreate()
reads $this->loggedInUser->getUsername(),
RouterTest::testUserAccount()
reads $this->loggedInUser->id()
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | loggedInUser-2360683-1.patch | 440 bytes | martin107 |
| loggedInUser-0.patch | 440 bytes | martin107 |
Comments
Comment #1
martin107 commentedOpps stray white space.
Comment #2
dawehneryeah, why not
Comment #3
jhodgdonIndeed. Thanks! Committed to 8.0.x.