Skip to content

Instantly share code, notes, and snippets.

@radmiraal
Created August 17, 2012 17:30
Show Gist options
  • Save radmiraal/3380833 to your computer and use it in GitHub Desktop.
Save radmiraal/3380833 to your computer and use it in GitHub Desktop.
class SomeController extends ... {
/**
* @var \TYPO3\FLOW3\Security\Context
* @FLOW3\Inject
*/
protected $securityContext;
public function someAction() {
$roles = $this->securityContext->getRoles();
}
}
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;
}
}
@kdambekalns
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment