protected function principalMatchReport($path, Xml\Request\PrincipalMatchReport $report)
    {
        $depth = $this->server->getHTTPDepth(0);
        if (0 !== $depth) {
            throw new BadRequest('The principal-match report is only defined on Depth: 0');
        }

        $currentPrincipals = $this->getCurrentUserPrincipals();

        $result = [];

        if (Xml\Request\PrincipalMatchReport::SELF === $report->type) {
            // Finding all principals under the request uri that match the
            // current principal.
            foreach ($currentPrincipals as $currentPrincipal) {
                if ($currentPrincipal === $path || 0 === strpos($currentPrincipal, $path.'/')) {
                    $result[] = $currentPrincipal;
                }
            }
        } else {
            // We need to find all resources that have a property that matches
            // one of the current principals.
            $candidates = $this->server->getPropertiesForPath(
                $path,
                [$report->principalProperty],
                1
            );

            foreach ($candidates as $candidate) {
                if (!isset($candidate[200][$report->principalProperty])) {
                    continue;
                }

                $hrefs = $candidate[200][$report->principalProperty];

                if (!$hrefs instanceof Href) {
                    continue;
                }

                foreach ($hrefs->getHrefs() as $href) {
                    if (in_array(trim($href, '/'), $currentPrincipals)) {
                        $result[] = $candidate['href'];
                        continue 2;
                    }
                }
            }
        }

        $responses = [];

        foreach ($result as $item) {
            $properties = [];

            if ($report->properties) {
                $foo = $this->server->getPropertiesForPath($item, $report->properties);
                $foo = $foo[0];
                $item = $foo['href'];
                unset($foo['href']);
                $properties = $foo;
            }

            $responses[] = new DAV\Xml\Element\Response(
                $item,
                $properties,
                '200'
            );
        }

        $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
        $this->server->httpResponse->setStatus(207);
        $this->server->httpResponse->setBody(
            $this->server->xml->write(
                '{DAV:}multistatus',
                $responses,
                $this->server->getBaseUri()
            )
        );
    }
protected function principalMatchReport($path, Xml\Request\PrincipalMatchReport $report)
    {
        $depth = $this->server->getHTTPDepth(0);
        if (0 !== $depth) {
            throw new BadRequest('The principal-match report is only defined on Depth: 0');
        }

        $currentPrincipals = $this->getCurrentUserPrincipals();

        $result = [];

        if (Xml\Request\PrincipalMatchReport::SELF === $report->type) {
            // Finding all principals under the request uri that match the
            // current principal.
            foreach ($currentPrincipals as $currentPrincipal) {
                if ($currentPrincipal === $path || 0 === strpos($currentPrincipal, $path.'/')) {
                    $result[] = $currentPrincipal;
                }
            }
        } else {
            // We need to find all resources that have a property that matches
            // one of the current principals.
            $candidates = $this->server->getPropertiesForPath(
                $path,
                [$report->principalProperty],
                1
            );

            foreach ($candidates as $candidate) {
                if (!isset($candidate[200][$report->principalProperty])) {
                    continue;
                }

                $hrefs = $candidate[200][$report->principalProperty];

                if (!$hrefs instanceof Href) {
                    continue;
                }

                foreach ($hrefs->getHrefs() as $href) {
                    if (in_array(trim($href, '/'), $currentPrincipals)) {
                        $result[] = $candidate['href'];
                        continue 2;
                    }
                }
            }
        }

        $responses = [];

        foreach ($result as $item) {
            $properties = [];

            if ($report->properties) {
                $foo = $this->server->getPropertiesForPath($item, $report->properties);
                $foo = $foo[0];
                $item = $foo['href'];
                unset($foo['href']);
                $properties = $foo;
            }

            $responses[] = new DAV\Xml\Element\Response(
                $item,
                $properties,
                '200'
            );
        }

        $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
        $this->server->httpResponse->setStatus(207);
        $this->server->httpResponse->setBody(
            $this->server->xml->write(
                '{DAV:}multistatus',
                $responses,
                $this->server->getBaseUri()
            )
        );
    }
protected function principalMatchReport ( $ path , Xml \ Request \ PrincipalMatchReport $ report ) { $ depth = $ this -> server -> getHTTPDepth ( 0 ) ; if ( 0 !== $ depth ) { throw new BadRequest ( 'The principal-match report is only defined on Depth: 0' ) ; } $ currentPrincipals = $ this -> getCurrentUserPrincipals ( ) ; $ result = [ ] ; if ( Xml \ Request \ PrincipalMatchReport :: SELF === $ report -> type ) { // Finding all principals under the request uri that match the // current principal. foreach ( $ currentPrincipals as $ currentPrincipal ) { if ( $ currentPrincipal === $ path || 0 === strpos ( $ currentPrincipal , $ path . '/' ) ) { $ result [ ] = $ currentPrincipal ; } } } else { // We need to find all resources that have a property that matches // one of the current principals. $ candidates = $ this -> server -> getPropertiesForPath ( $ path , [ $ report -> principalProperty ] , 1 ) ; foreach ( $ candidates as $ candidate ) { if ( ! isset ( $ candidate [ 200 ] [ $ report -> principalProperty ] ) ) { continue ; } $ hrefs = $ candidate [ 200 ] [ $ report -> principalProperty ] ; if ( ! $ hrefs instanceof Href ) { continue ; } foreach ( $ hrefs -> getHrefs ( ) as $ href ) { if ( in_array ( trim ( $ href , '/' ) , $ currentPrincipals ) ) { $ result [ ] = $ candidate [ 'href' ] ; continue 2 ; } } } } $ responses = [ ] ; foreach ( $ result as $ item ) { $ properties = [ ] ; if ( $ report -> properties ) { $ foo = $ this -> server -> getPropertiesForPath ( $ item , $ report -> properties ) ; $ foo = $ foo [ 0 ] ; $ item = $ foo [ 'href' ] ; unset ( $ foo [ 'href' ] ) ; $ properties = $ foo ; } $ responses [ ] = new DAV \ Xml \ Element \ Response ( $ item , $ properties , '200' ) ; } $ this -> server -> httpResponse -> setHeader ( 'Content-Type' , 'application/xml; charset=utf-8' ) ; $ this -> server -> httpResponse -> setStatus ( 207 ) ; $ this -> server -> httpResponse -> setBody ( $ this -> server -> xml -> write ( '{DAV:}multistatus' , $ responses , $ this -> server -> getBaseUri ( ) ) ) ; }
The principal-match report is defined in RFC3744, section 9.3.

This report allows a client to figure out based on the current user,
or a principal URL, the principal URL and principal URLs of groups that
principal belongs to.

@param string                           $path
@param Xml\Request\PrincipalMatchReport $report
The principal - match report is defined in RFC3744 section 9 . 3 .