Created
August 17, 2012 17:30
-
-
Save radmiraal/3380833 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
class SomeController extends ... { | |
/** | |
* @var \TYPO3\FLOW3\Security\Context | |
* @FLOW3\Inject | |
*/ | |
protected $securityContext; | |
public function someAction() { | |
$roles = $this->securityContext->getRoles(); | |
} | |
} |
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
class SomeRepository extends \TYPO3\FLOW3\Security\AccountRepository { | |
/** | |
* @param \TYPO3\FLOW3\Security\Policy\Role $role | |
* @return array | |
*/ | |
public function findByRole(\TYPO3\FLOW3\Security\Policy\Role $role) { | |
// $query = $this->createQuery(); | |
// return $query->matching($query->in('roles', array((string)$role)))->execute(); | |
$result = array(); | |
$accounts = $this->findAll(); | |
foreach ($accounts as $account) { | |
if ($account->hasRole($role)) { | |
$result[] = $account; | |
} | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hm, that in() should work, but in the newsgroup someone asked about it just these days… we should try it and if it does not work, that's a bug.