Last active
August 29, 2015 14:02
-
-
Save aurimasniekis/612bbcb0e31d5bd2c5f2 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
class User { | |
public function getRoles() | |
{ | |
if ($this->roles) { | |
return $this->roles; | |
} | |
/** @var UserGroup[] $userGroups */ | |
$userGroups = $this->getGroups(); | |
$roles = []; | |
foreach ($userGroups as $group) { | |
$roles = array_merge($roles, $group->getRoles()); | |
} | |
sort($roles); | |
$this->roles = array_unique($roles); | |
return $this->roles; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment