]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/WebFinger/lib/webfingerresource.php
Merge branch 'master' into FeedPoller
[quix0rs-gnu-social.git] / plugins / WebFinger / lib / webfingerresource.php
1 <?php
2 /**
3  * WebFinger resource parent class
4  *
5  * @package   GNUsocial
6  * @author    Mikael Nordfeldth
7  * @copyright 2013 Free Software Foundation, Inc.
8  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
9  * @link      http://status.net/
10  */
11
12 abstract class WebFingerResource
13 {
14     protected $identities = array();
15
16     protected $object = null;
17     protected $type   = null;
18
19     public function __construct(Managed_DataObject $object)
20     {
21         $this->object = $object;
22     }
23
24     public function getObject()
25     {
26         if ($this->object === null) {
27             throw new ServerException('Object is not set');
28         }
29         return $this->object;
30     }
31
32     public function getAliases()
33     {
34         $aliases = array();
35
36         // Add the URI as an identity, this is _not_ necessarily an HTTP url
37         $aliases[] = $this->object->getUri();
38
39         try {
40             $aliases[] = $this->object->getUrl();
41         } catch (InvalidUrlException $e) {
42             // getUrl failed because no valid URL could be returned, just ignore it
43         }
44
45         return $aliases;
46     }
47
48     abstract public function updateXRD(XML_XRD $xrd);
49 }