Skip to content

Commit

Permalink
fix old and unused tag structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kringkaste committed Oct 21, 2022
1 parent 7ad3b92 commit fd79158
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Release Notes for Instagram Feed Plugin

## Unreleased
## 2.1.0 - 2022-10-21

### Added

- Set referrer in proxy requests.
- Set plugin version in proxy requests.
- New tag structure v3.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "codemonauts/craft-instagram-feed",
"description": "Craft CMS plugin to receive Instagram feed data as variable in templates.",
"version": "2.0.1",
"version": "2.1.0",
"type": "craft-plugin",
"keywords": [
"craft",
Expand Down
6 changes: 6 additions & 0 deletions src/parsers/AccountVersion1Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class AccountVersion1Parser extends Parser
{
/**
* @inheritDoc
*/
public function getItems(array $response): array
{
$items = [];
Expand Down Expand Up @@ -31,6 +34,9 @@ public function getItems(array $response): array
return $items;
}

/**
* @inheritDoc
*/
protected function getPictureMapping(): array
{
return [
Expand Down
12 changes: 12 additions & 0 deletions src/parsers/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@

abstract class Parser
{
/**
* Returns the items from the given response.
*
* @param array $response The response from Instagram.
*
* @return array
*/
abstract public function getItems(array $response): array;

/**
* Returns the picture mapping of the structure.
*
* @return array
*/
abstract protected function getPictureMapping(): array;

/**
Expand Down
18 changes: 15 additions & 3 deletions src/parsers/TagVersion1Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@

class TagVersion1Parser extends Parser
{
/**
* @inheritDoc
*/
public function getItems(array $response): array
{
$itmes = [];
$items = [];

foreach ($mediaArray as $section) {
if (!isset($response['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'])) {
return $items;
}

$sections = array_slice($response['data']['recent']['sections'], 0, 12);

foreach ($sections as $section) {
foreach ($section['layout_content']['medias'] as $node) {
if ((int)$node['media']['media_type'] === 8) {
if (!isset($node['media']['carousel_media'][0]['image_versions2'])) {
Expand All @@ -33,9 +42,12 @@ public function getItems(array $response): array
}
}

return [];
return $items;
}

/**
* @inheritDoc
*/
protected function getPictureMapping(): array
{
return [
Expand Down
6 changes: 6 additions & 0 deletions src/parsers/TagVersion2Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class TagVersion2Parser extends Parser
{
/**
* @inheritDoc
*/
public function getItems(array $response): array
{
$items = [];
Expand Down Expand Up @@ -42,6 +45,9 @@ public function getItems(array $response): array
return $items;
}

/**
* @inheritDoc
*/
protected function getPictureMapping(): array
{
return [
Expand Down
6 changes: 6 additions & 0 deletions src/parsers/TagVersion3Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class TagVersion3Parser extends Parser
{
/**
* @inheritDoc
*/
public function getItems(array $response): array
{
$items = [];
Expand Down Expand Up @@ -33,6 +36,9 @@ public function getItems(array $response): array
return $items;
}

/**
* @inheritDoc
*/
protected function getPictureMapping(): array
{
return [
Expand Down

0 comments on commit fd79158

Please sign in to comment.