]> git.mxchange.org Git - friendica.git/blobdiff - src/Factory/Api/Mastodon/Mention.php
Tests ...
[friendica.git] / src / Factory / Api / Mastodon / Mention.php
index 5ab82d710f3d6c18288c0c8b31f4525dfdbd5fdb..597f205db8f0338f910308ae956f8d806d579bc6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -23,44 +23,36 @@ namespace Friendica\Factory\Api\Mastodon;
 
 use Friendica\App\BaseURL;
 use Friendica\BaseFactory;
+use Friendica\Collection\Api\Mastodon\Mentions;
 use Friendica\Model\Contact;
 use Friendica\Model\Tag;
 use Friendica\Network\HTTPException;
-use Friendica\Repository\ProfileField;
 use Psr\Log\LoggerInterface;
 
 class Mention extends BaseFactory
 {
        /** @var BaseURL */
-       protected $baseUrl;
-       /** @var ProfileField */
-       protected $profileField;
-       /** @var Field */
-       protected $mstdnField;
+       private $baseUrl;
 
-       public function __construct(LoggerInterface $logger, BaseURL $baseURL, ProfileField $profileField, Field $mstdnField)
+       public function __construct(LoggerInterface $logger, BaseURL $baseURL)
        {
                parent::__construct($logger);
 
                $this->baseUrl = $baseURL;
-               $this->profileField = $profileField;
-               $this->mstdnField = $mstdnField;
        }
 
        /**
         * @param int $uriId Uri-ID of the item
-        * @return array
+        * @return Mentions
         * @throws HTTPException\InternalServerErrorException
-        * @throws \ImagickException
         */
-       public function createFromUriId(int $uriId)
+       public function createFromUriId(int $uriId): Mentions
        {
-               $mentions = [];
-               $tags = Tag::getByURIId($uriId, [Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION]);
+               $mentions = new Mentions();
+               $tags     = Tag::getByURIId($uriId, [Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION]);
                foreach ($tags as $tag) {
-                       $contact = Contact::getByURL($tag['url'], false);
-                       $mention = new \Friendica\Object\Api\Mastodon\Mention($this->baseUrl, $tag, $contact);
-                       $mentions[] = $mention->toArray();
+                       $contact    = Contact::getByURL($tag['url'], false);
+                       $mentions[] = new \Friendica\Object\Api\Mastodon\Mention($this->baseUrl, $tag, $contact);
                }
                return $mentions;
        }