Skip to content

Commit

Permalink
Twig function to allow individual exhibitors to be queried for via th…
Browse files Browse the repository at this point in the history
…eir 'identifier' from Livebuzz
  • Loading branch information
Jake Noble committed Feb 4, 2020
1 parent 1b5cc69 commit 58fd219
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "burnthebook/craft3-livebuzz",
"description": "Pulls Exhibitors from the the LiveBuzz API to a website, it also updates and removes Exhibitors.",
"type": "craft-plugin",
"version": "1.0.2",
"version": "1.0.3",
"keywords": [
"craft",
"cms",
Expand Down
4 changes: 4 additions & 0 deletions src/services/TwigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public function exhibitors($criteria = null): ExhibitorQuery
}
return $query;
}

public function exhibitorByIdentifier($identifier) {
return Exhibitor::findOne(['identifier' => $identifier]);
}
}
3 changes: 2 additions & 1 deletion src/sync/JsonFeedSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,16 @@ private function storeExhibitorLogo(Exhibitor $exhibitorElement)
$parts = explode('.', $exhibitorElement->logo);
$filename = md5($exhibitorElement->logo) . '.' . end($parts);
$imagePath = CRAFT_BASE_PATH . '/web/images/uploads/' . $filename;
$imageUri = '/images/uploads/' . $filename;

if (file_exists($imagePath)) {
echo "Logo exists - do not store\n";
$exhibitorElement->logo = $imageUri;
return $exhibitorElement;
}

echo "Storing a new logo\n";

$imageUri = '/images/uploads/' . $filename;
file_put_contents($imagePath, file_get_contents($exhibitorElement->logo));
$exhibitorElement->logo = $imageUri;

Expand Down

0 comments on commit 58fd219

Please sign in to comment.