本文整理汇总了PHP中Symfony\Component\Security\Acl\Model\SecurityIdentityInterface::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityIdentityInterface::getId方法的具体用法?PHP SecurityIdentityInterface::getId怎么用?PHP SecurityIdentityInterface::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Security\Acl\Model\SecurityIdentityInterface
的用法示例。
在下文中一共展示了SecurityIdentityInterface::getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: equals
/**
* {@inheritdoc}
*/
public function equals(SecurityIdentityInterface $sid)
{
if (!$sid instanceof self) {
return false;
}
return $this->id === $sid->getId() && $this->class === $sid->getClass();
}
示例2: getFormattedName
/**
* @param SecurityIdentityInterface $sid
*
* @return string
*/
protected function getFormattedName(SecurityIdentityInterface $sid)
{
if ($sid instanceof UserSecurityIdentity && $sid->getUsername()) {
$user = $this->manager->getRepository('OroUserBundle:User')->findOneBy(['username' => $sid->getUsername()]);
if ($user) {
return $this->nameFormatter->format($user);
}
} elseif ($sid instanceof BusinessUnitSecurityIdentity) {
$businessUnit = $this->manager->getRepository('OroOrganizationBundle:BusinessUnit')->find($sid->getId());
if ($businessUnit) {
return $businessUnit->getName();
}
}
return '';
}
示例3: getSecurityIdentityId
/**
* @param SecurityIdentityInterface $sid
*
* @return mixed
*/
protected function getSecurityIdentityId(SecurityIdentityInterface $sid)
{
if ($sid instanceof UserSecurityIdentity) {
$identifier = $sid->getClass() . '-' . $sid->getUsername();
$username = true;
} elseif ($sid instanceof RoleSecurityIdentity) {
//skip Role SID because we didn't share records for Role
return null;
} elseif ($sid instanceof BusinessUnitSecurityIdentity) {
$identifier = $sid->getClass() . '-' . $sid->getId();
$username = false;
} else {
throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity or RoleSecurityIdentity ' . 'or BusinessUnitSecurityIdentity.');
}
return $this->getObjectManager()->getRepository('OroSecurityBundle:AclSecurityIdentity')->findOneBy(['identifier' => $identifier, 'username' => $username]);
}
示例4: getSecurityIdentifier
/**
* Get Security Identifier and Username flag to create SQL queries
*
* @param SecurityIdentityInterface $sid
*
* @throws \InvalidArgumentException
*
* @return array
*/
protected function getSecurityIdentifier(SecurityIdentityInterface $sid)
{
if ($sid instanceof UserSecurityIdentity) {
return [$sid->getClass() . '-' . $sid->getUsername(), true];
} elseif ($sid instanceof RoleSecurityIdentity) {
return [$sid->getRole(), false];
} elseif ($sid instanceof BusinessUnitSecurityIdentity) {
return [$sid->getClass() . '-' . $sid->getId(), false];
} else {
throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity or RoleSecurityIdentity' . ' or BusinessUnitSecurityIdentity.');
}
}