webfingerresource.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. abstract class WebFingerResource
  12. {
  13. protected $identities = array();
  14. protected $object = null;
  15. protected $type = null;
  16. public function __construct(Managed_DataObject $object)
  17. {
  18. $this->object = $object;
  19. }
  20. public function getObject()
  21. {
  22. if ($this->object === null) {
  23. throw new ServerException('Object is not set');
  24. }
  25. return $this->object;
  26. }
  27. public function getAliases()
  28. {
  29. $aliases = array();
  30. // Add the URI as an identity, this is _not_ necessarily an HTTP url
  31. $aliases[] = $this->object->getUri();
  32. try {
  33. $aliases[] = $this->object->getUrl();
  34. } catch (InvalidUrlException $e) {
  35. // getUrl failed because no valid URL could be returned, just ignore it
  36. }
  37. return $aliases;
  38. }
  39. abstract public function updateXRD(XML_XRD $xrd);
  40. }