Created
August 17, 2017 07:22
-
-
Save thyseus/480b80aa2225c830375274fb03837b4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Wie kann ich das besser machen? | |
```php | |
if (isset(Yii::$app->user) | |
&& isset(Yii::$app->user->identity) | |
&& isset(Yii::$app->user->identity->profile) | |
&& isset(Yii::$app->user->identity->profile->language) | |
) { | |
$language = Yii::$app->user->identity->profile->language; | |
} | |
``` | |
In ruby gibts dafür .tap - gibts sowas in php?: | |
https://stackoverflow.com/questions/17493080/advantage-of-tap-method-in-ruby |
>>> $language = Yii::$app->user->identity->profile->language;
yii\base\UnknownMethodException with message 'Calling unknown method: yii\console\Application::getSession()'
>>> $language = Yii::$app->user->identity->profile->language ?? 'de';
=> "de"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$language = Yii::$app->user->identity->profile->language ?? 'de';