3 namespace wcf\data\article
;
5 use wcf\data\like\ILikeObjectTypeProvider
;
6 use wcf\data\like\
object\ILikeObject
;
7 use wcf\data\
object\type\AbstractObjectTypeProvider
;
8 use wcf\system\like\IViewableLikeProvider
;
12 * Like Object type provider for cms articles.
15 * @copyright 2001-2019 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
19 * @method LikeableArticle getObjectByID($objectID)
20 * @method LikeableArticle[] getObjectsByIDs(array $objectIDs)
22 class LikeableArticleProvider
extends AbstractObjectTypeProvider
implements
23 ILikeObjectTypeProvider
,
29 public $className = Article
::class;
34 public $listClassName = ArticleList
::class;
39 public $decoratorClassName = LikeableArticle
::class;
44 public function checkPermissions(ILikeObject
$object)
46 /** @var LikeableArticle $object */
47 return $object->articleID
&& $object->canRead();
53 public function prepare(array $likes)
56 foreach ($likes as $like) {
57 $articleIDs[] = $like->objectID
;
61 $articleList = new ViewableArticleList();
62 $articleList->setObjectIDs($articleIDs);
63 $articleList->readObjects();
64 $articles = $articleList->getObjects();
67 foreach ($likes as $like) {
68 if (isset($articles[$like->objectID
])) {
69 $article = $articles[$like->objectID
];
72 if (!$article->canRead()) {
75 $like->setIsAccessible();
78 $text = WCF
::getLanguage()->getDynamicVariable('wcf.like.title.com.woltlab.wcf.likeableArticle', [
79 'article' => $article,
81 // @deprecated 5.3 Use `$reaction` instead
84 $like->setTitle($text);
87 $like->setDescription($article->getTeaser());