Skip to content

Commit e34bd22

Browse files
committed
Bugfixes
1 parent 1fe41f4 commit e34bd22

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

Model/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(array $data)
5959
$this->name = $data['name'];
6060
$this->slug = $data['slug'];
6161
$this->taxonomy = $data['taxonomy'];
62-
$this->parentId = $data['parentId'];
62+
$this->parentId = $data['parent'];
6363
}
6464

6565
/**

Parser/MessageParser.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public function parseMenu(array $data): ?Menu
7171
public function parseCategories(array $data): array
7272
{
7373
$collection = [];
74+
if (isset($data['id'])) {
75+
$data = [$data];
76+
}
7477
foreach ($data as $d) {
7578
try {
7679
$category = new Category($d);
@@ -92,6 +95,9 @@ public function parseCategories(array $data): array
9295
public function parseMedia(array $data): array
9396
{
9497
$collection = [];
98+
if (isset($data['id'])) {
99+
$data = [$data];
100+
}
95101
foreach ($data as $d) {
96102
try {
97103
$media = new Media($d);

Service/Wordpress.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function getMenu(string $slug): ?Menu
9595
public function getCategories(string $slug = ''): array
9696
{
9797
return $this->cache->get($this->getCacheKey('categories', $slug), function (/*ItemInterface*/ CacheItemInterface $item) use ($slug) {
98-
$data = $this->client->get('/wp/v2/categories'.$slug);
98+
$data = $this->client->getUri('/wp/v2/categories'.$slug);
9999
if (!$this->isValidResponse($data)) {
100100
$item->expiresAfter(300);
101101

@@ -111,7 +111,7 @@ public function getCategories(string $slug = ''): array
111111
public function getMedia(string $slug = ''): array
112112
{
113113
return $this->cache->get($this->getCacheKey('media', $slug), function (/*ItemInterface*/ CacheItemInterface $item) use ($slug) {
114-
$data = $this->client->get('/wp/v2/media'.$slug);
114+
$data = $this->client->getUri('/wp/v2/media'.$slug);
115115
if (!$this->isValidResponse($data)) {
116116
$item->expiresAfter(300);
117117

@@ -137,6 +137,8 @@ public function purgeCache(string $identifier): void
137137
// Get item and force recompute.
138138
$this->cache->get($this->getCacheKey('page', $identifier), $callback, INF);
139139
$this->cache->get($this->getCacheKey('menu', $identifier), $callback, INF);
140+
$this->cache->get($this->getCacheKey('categories', $identifier), $callback, INF);
141+
$this->cache->get($this->getCacheKey('media', $identifier), $callback, INF);
140142
$this->cache->get($this->getCacheKey('query', $identifier), $callback, INF);
141143
}
142144

Twig/WordpressExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public function getFunctions()
2323
return [
2424
new \Twig_SimpleFunction('getWpMenu', [$this->wordpress, 'getMenu']),
2525
new \Twig_SimpleFunction('getWpPage', [$this->wordpress, 'getPage']),
26-
new \Twig_SimpleFunction('getCategoryById', [$this, 'getCategoryById']),
27-
new \Twig_SimpleFunction('getMediaById', [$this, 'getMediaById']),
26+
new \Twig_SimpleFunction('getWpCategoryById', [$this, 'getCategoryById']),
27+
new \Twig_SimpleFunction('getWpMediaById', [$this, 'getMediaById']),
2828
];
2929
}
3030

0 commit comments

Comments
 (0)