1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- declare(strict_types = 1);
- namespace Component\FreeNetwork\Util\WebfingerResource;
- use App\Core\Event;
- use App\Entity\Note;
- use Component\FreeNetwork\Util\WebfingerResource;
- use PharIo\Manifest\InvalidUrlException;
- use XML_XRD;
- use XML_XRD_Element_Link;
- class WebfingerResourceNote extends WebfingerResource
- {
- public function __construct(?Note $object = null)
- {
-
- parent::__construct($object);
- }
-
- public function updateXRD(XML_XRD $xrd)
- {
- if (Event::handle('StartWebFingerNoticeLinks', [$xrd, $this->object])) {
- if ($this->object->isLocal()) {
- $xrd->links[] = new XML_XRD_Element_Link(
- 'alternate',
- common_local_url(
- 'ApiStatusesShow',
- ['id' => $this->object->id,
- 'format' => 'atom', ],
- ),
- 'application/atom+xml',
- );
- $xrd->links[] = new XML_XRD_Element_Link(
- 'alternate',
- common_local_url(
- 'ApiStatusesShow',
- ['id' => $this->object->id,
- 'format' => 'json', ],
- ),
- 'application/json',
- );
- } else {
- try {
- $xrd->links[] = new XML_XRD_Element_Link(
- 'alternate',
- $this->object->getUrl(),
- 'text/html',
- );
- } catch (InvalidUrlException $e) {
-
- }
- }
- Event::handle('EndWebFingerNoticeLinks', [$xrd, $this->object]);
- }
- }
- }
|