public function principalMatchesPrincipal($checkPrincipal, $currentPrincipal = null)
    {
        if (is_null($currentPrincipal)) {
            $currentPrincipal = $this->getCurrentUserPrincipal();
        }
        if ($currentPrincipal === $checkPrincipal) {
            return true;
        }
        if (is_null($currentPrincipal)) {
            return false;
        }

        return in_array(
            $checkPrincipal,
            $this->getPrincipalMembership($currentPrincipal)
        );
    }
public function principalMatchesPrincipal($checkPrincipal, $currentPrincipal = null)
    {
        if (is_null($currentPrincipal)) {
            $currentPrincipal = $this->getCurrentUserPrincipal();
        }
        if ($currentPrincipal === $checkPrincipal) {
            return true;
        }
        if (is_null($currentPrincipal)) {
            return false;
        }

        return in_array(
            $checkPrincipal,
            $this->getPrincipalMembership($currentPrincipal)
        );
    }
public function principalMatchesPrincipal ( $ checkPrincipal , $ currentPrincipal = null ) { if ( is_null ( $ currentPrincipal ) ) { $ currentPrincipal = $ this -> getCurrentUserPrincipal ( ) ; } if ( $ currentPrincipal === $ checkPrincipal ) { return true ; } if ( is_null ( $ currentPrincipal ) ) { return false ; } return in_array ( $ checkPrincipal , $ this -> getPrincipalMembership ( $ currentPrincipal ) ) ; }
Find out of a principal equals another principal.

This is a quick way to find out whether a principal URI is part of a
group, or any subgroups.

The first argument is the principal URI you want to check against. For
example the principal group, and the second argument is the principal of
which you want to find out of it is the same as the first principal, or
in a member of the first principal's group or subgroups.

So the arguments are not interchangeable. If principal A is in group B,
passing 'B', 'A' will yield true, but 'A', 'B' is false.

If the second argument is not passed, we will use the current user
principal.

@param string $checkPrincipal
@param string $currentPrincipal

@return bool
Find out of a principal equals another principal .