1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created for IG Client. |
4
|
|
|
* User: jakim <[email protected]> |
5
|
|
|
* Date: 16.03.2018 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Jakim\Query; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
use Jakim\Base\Query; |
12
|
|
|
use jakim\ig\Endpoint; |
13
|
|
|
use Jakim\Mapper\EdgeMedia; |
14
|
|
|
use Jakim\Mapper\ExploreTags; |
15
|
|
|
use Jakim\Model\MediaCollection; |
16
|
|
|
use Jakim\Model\Tag; |
17
|
|
|
|
18
|
|
|
class TagQuery extends Query |
19
|
|
|
{ |
20
|
|
|
protected $findOneByName; |
21
|
|
|
protected $findLatestMedia; |
22
|
|
|
protected $findTopPosts; |
23
|
|
|
|
24
|
|
|
public function __construct( |
25
|
|
|
$httpClient, |
26
|
|
|
ExploreTags $findOneByName = null, |
27
|
|
|
EdgeMedia $findLatestMedia = null, |
28
|
|
|
EdgeMedia $findTopPosts = null |
29
|
|
|
) |
30
|
|
|
{ |
31
|
|
|
parent::__construct($httpClient); |
32
|
|
|
$this->findOneByName = $findOneByName; |
33
|
|
|
$this->findLatestMedia = $findLatestMedia; |
34
|
|
|
$this->findTopPosts = $findTopPosts; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function findOneByName(string $tagName): Tag |
38
|
|
|
{ |
39
|
|
|
$url = Endpoint::exploreTags($tagName); |
40
|
|
|
|
41
|
|
|
return $this->createResult($url, $this->findOneByName, false); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function findLatestMedia(string $tagName, bool $relations = false): MediaCollection |
45
|
|
|
{ |
46
|
|
|
$url = Endpoint::exploreTags($tagName); |
47
|
|
|
|
48
|
|
|
return $this->createResult($url, $this->findLatestMedia, $relations); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function findTopPosts(string $tagName, bool $relations = false): MediaCollection |
52
|
|
|
{ |
53
|
|
|
$url = Endpoint::exploreTags($tagName); |
54
|
|
|
|
55
|
|
|
return $this->createResult($url, $this->findTopPosts, $relations); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
} |